Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1269,6 +1269,21 @@ def create_interface():
|
|
1269 |
with gr.Row():
|
1270 |
generate_all_btn = gr.Button("π¨ λͺ¨λ μ΄λ―Έμ§ μμ±", variant="primary")
|
1271 |
clear_images_btn = gr.Button("ποΈ μ΄λ―Έμ§ μ΄κΈ°ν", variant="secondary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1272 |
|
1273 |
with gr.Tab("π μ¬μ© κ°μ΄λ"):
|
1274 |
gr.Markdown("""
|
@@ -1348,13 +1363,13 @@ def create_interface():
|
|
1348 |
logger.error(f"Download error: {e}")
|
1349 |
gr.Warning(f"λ€μ΄λ‘λ μ€ μ€λ₯ λ°μ: {str(e)}")
|
1350 |
return None
|
1351 |
-
|
1352 |
def generate_all_images(session_id, storyboard_content, character_profiles):
|
1353 |
"""Generate images for all panels using multi-threading"""
|
1354 |
if not REPLICATE_API_TOKEN:
|
1355 |
return "<p style='color: red;'>Replicate API ν ν°μ΄ μ€μ λμ§ μμμ΅λλ€.</p>"
|
1356 |
|
1357 |
-
|
1358 |
panel_prompts = []
|
1359 |
lines = storyboard_content.split('\n')
|
1360 |
current_panel_num = 0
|
@@ -1372,6 +1387,20 @@ def create_interface():
|
|
1372 |
current_prompt = ""
|
1373 |
elif 'μ΄λ―Έμ§ ν둬ννΈ:' in line or 'Image prompt:' in line:
|
1374 |
current_prompt = line.split(':', 1)[1].strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1375 |
|
1376 |
# Add last panel if exists
|
1377 |
if current_prompt and current_panel_num > 0:
|
@@ -1497,7 +1526,7 @@ def create_interface():
|
|
1497 |
|
1498 |
generate_all_btn.click(
|
1499 |
fn=generate_all_images,
|
1500 |
-
inputs=[current_session_id, storyboard_state],
|
1501 |
outputs=[image_display_area]
|
1502 |
)
|
1503 |
|
|
|
1269 |
with gr.Row():
|
1270 |
generate_all_btn = gr.Button("π¨ λͺ¨λ μ΄λ―Έμ§ μμ±", variant="primary")
|
1271 |
clear_images_btn = gr.Button("ποΈ μ΄λ―Έμ§ μ΄κΈ°ν", variant="secondary")
|
1272 |
+
|
1273 |
+
|
1274 |
+
# κ°λ³ ν¨λ μ¬μμ±μ μν μ¨κ²¨μ§ μ»΄ν¬λνΈ μΆκ° (Tab λ΄λΆμ)
|
1275 |
+
with gr.Row(visible=False):
|
1276 |
+
panel_id_for_regen = gr.Textbox(label="Panel ID for Regeneration")
|
1277 |
+
panel_prompt_for_regen = gr.Textbox(label="Panel Prompt for Regeneration")
|
1278 |
+
regen_trigger_btn = gr.Button("Trigger Regeneration")
|
1279 |
+
regenerated_result = gr.JSON(label="Regeneration Result")
|
1280 |
+
|
1281 |
+
# μ¬μμ± ν¨μμ μ°κ²°
|
1282 |
+
regen_trigger_btn.click(
|
1283 |
+
fn=lambda pid, prompt, sid: regenerate_single_panel(pid, prompt, sid),
|
1284 |
+
inputs=[panel_id_for_regen, panel_prompt_for_regen, current_session_id],
|
1285 |
+
outputs=[regenerated_result]
|
1286 |
+
)
|
1287 |
|
1288 |
with gr.Tab("π μ¬μ© κ°μ΄λ"):
|
1289 |
gr.Markdown("""
|
|
|
1363 |
logger.error(f"Download error: {e}")
|
1364 |
gr.Warning(f"λ€μ΄λ‘λ μ€ μ€λ₯ λ°μ: {str(e)}")
|
1365 |
return None
|
1366 |
+
|
1367 |
def generate_all_images(session_id, storyboard_content, character_profiles):
|
1368 |
"""Generate images for all panels using multi-threading"""
|
1369 |
if not REPLICATE_API_TOKEN:
|
1370 |
return "<p style='color: red;'>Replicate API ν ν°μ΄ μ€μ λμ§ μμμ΅λλ€.</p>"
|
1371 |
|
1372 |
+
# Parse storyboard to extract prompts
|
1373 |
panel_prompts = []
|
1374 |
lines = storyboard_content.split('\n')
|
1375 |
current_panel_num = 0
|
|
|
1387 |
current_prompt = ""
|
1388 |
elif 'μ΄λ―Έμ§ ν둬ννΈ:' in line or 'Image prompt:' in line:
|
1389 |
current_prompt = line.split(':', 1)[1].strip()
|
1390 |
+
|
1391 |
+
|
1392 |
+
for line in lines:
|
1393 |
+
if 'ν¨λ' in line or 'Panel' in line:
|
1394 |
+
if current_prompt and current_panel_num > 0:
|
1395 |
+
panel_prompts.append({
|
1396 |
+
'panel_id': f"ep1_panel{current_panel_num}",
|
1397 |
+
'panel_num': current_panel_num,
|
1398 |
+
'prompt': current_prompt
|
1399 |
+
})
|
1400 |
+
current_panel_num += 1
|
1401 |
+
current_prompt = ""
|
1402 |
+
elif 'μ΄λ―Έμ§ ν둬ννΈ:' in line or 'Image prompt:' in line:
|
1403 |
+
current_prompt = line.split(':', 1)[1].strip()
|
1404 |
|
1405 |
# Add last panel if exists
|
1406 |
if current_prompt and current_panel_num > 0:
|
|
|
1526 |
|
1527 |
generate_all_btn.click(
|
1528 |
fn=generate_all_images,
|
1529 |
+
inputs=[current_session_id, storyboard_state, character_profiles_state],
|
1530 |
outputs=[image_display_area]
|
1531 |
)
|
1532 |
|