openfree commited on
Commit
8b2bf4c
Β·
verified Β·
1 Parent(s): fa24ce6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -3
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
- # Parse storyboard to extract prompts
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