openfree commited on
Commit
cbd8e4c
Β·
verified Β·
1 Parent(s): 0446b4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -10
app.py CHANGED
@@ -228,6 +228,7 @@ preset_options = [
228
  def preset_changed(preset):
229
  if preset != "Custom":
230
  selected = next(item for item in preset_options if item["label"] == preset)
 
231
  return (
232
  selected["height"],
233
  selected["width"],
@@ -246,6 +247,7 @@ def preset_changed(preset):
246
  gr.update(visible=True),
247
  )
248
 
 
249
  def generate_video_from_text(
250
  prompt="",
251
  enhance_prompt_toggle=False,
@@ -502,6 +504,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
502
  visible=False
503
  )
504
 
 
 
 
 
 
505
  txt2vid_preset = gr.Dropdown(
506
  choices=[p["label"] for p in preset_options],
507
  value="512x320, 10.3초",
@@ -555,9 +562,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
555
  visible=False
556
  )
557
 
 
 
 
 
 
558
  img2vid_preset = gr.Dropdown(
559
  choices=[p["label"] for p in preset_options],
560
- value="768x512, 97 frames",
561
  label="Step 3: 해상도 프리셋 선택",
562
  )
563
 
@@ -582,9 +594,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
582
 
583
  # Event handlers
584
  txt2vid_preset.change(
585
- fn=preset_changed,
586
- inputs=[txt2vid_preset],
587
- outputs=txt2vid_advanced[3:]
 
 
 
 
 
588
  )
589
 
590
  txt2vid_enhance_toggle.change(
@@ -600,7 +617,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
600
  txt2vid_enhance_toggle,
601
  txt2vid_negative_prompt,
602
  txt2vid_frame_rate,
603
- *txt2vid_advanced,
 
 
 
604
  ],
605
  outputs=txt2vid_output,
606
  concurrency_limit=1,
@@ -609,9 +629,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
609
  )
610
 
611
  img2vid_preset.change(
612
- fn=preset_changed,
613
- inputs=[img2vid_preset],
614
- outputs=img2vid_advanced[3:]
 
 
 
 
 
615
  )
616
 
617
  img2vid_enhance_toggle.change(
@@ -628,7 +653,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
628
  img2vid_enhance_toggle,
629
  img2vid_negative_prompt,
630
  img2vid_frame_rate,
631
- *img2vid_advanced,
 
 
 
632
  ],
633
  outputs=img2vid_output,
634
  concurrency_limit=1,
@@ -639,4 +667,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
639
  if __name__ == "__main__":
640
  iface.queue(max_size=64, default_concurrency_limit=1, api_open=False).launch(
641
  share=True, show_api=False
642
- )
 
228
  def preset_changed(preset):
229
  if preset != "Custom":
230
  selected = next(item for item in preset_options if item["label"] == preset)
231
+ # height, width, num_frames 값을 global λ³€μˆ˜λ‘œ μ—…λ°μ΄νŠΈ
232
  return (
233
  selected["height"],
234
  selected["width"],
 
247
  gr.update(visible=True),
248
  )
249
 
250
+
251
  def generate_video_from_text(
252
  prompt="",
253
  enhance_prompt_toggle=False,
 
504
  visible=False
505
  )
506
 
507
+ # ν˜„μž¬ μ„ νƒλœ 값듀을 μ €μž₯ν•  μƒνƒœ λ³€μˆ˜λ“€
508
+ txt2vid_current_height = gr.State(value=512)
509
+ txt2vid_current_width = gr.State(value=320)
510
+ txt2vid_current_num_frames = gr.State(value=257)
511
+
512
  txt2vid_preset = gr.Dropdown(
513
  choices=[p["label"] for p in preset_options],
514
  value="512x320, 10.3초",
 
562
  visible=False
563
  )
564
 
565
+ # ν˜„μž¬ μ„ νƒλœ 값듀을 μ €μž₯ν•  μƒνƒœ λ³€μˆ˜λ“€
566
+ img2vid_current_height = gr.State(value=512)
567
+ img2vid_current_width = gr.State(value=768)
568
+ img2vid_current_num_frames = gr.State(value=97)
569
+
570
  img2vid_preset = gr.Dropdown(
571
  choices=[p["label"] for p in preset_options],
572
+ value="768x512, 3.9초",
573
  label="Step 3: 해상도 프리셋 선택",
574
  )
575
 
 
594
 
595
  # Event handlers
596
  txt2vid_preset.change(
597
+ fn=preset_changed,
598
+ inputs=[txt2vid_preset],
599
+ outputs=[
600
+ txt2vid_current_height,
601
+ txt2vid_current_width,
602
+ txt2vid_current_num_frames,
603
+ *txt2vid_advanced[3:]
604
+ ]
605
  )
606
 
607
  txt2vid_enhance_toggle.change(
 
617
  txt2vid_enhance_toggle,
618
  txt2vid_negative_prompt,
619
  txt2vid_frame_rate,
620
+ *txt2vid_advanced[:3], # seed, inference_steps, guidance_scale
621
+ txt2vid_current_height,
622
+ txt2vid_current_width,
623
+ txt2vid_current_num_frames,
624
  ],
625
  outputs=txt2vid_output,
626
  concurrency_limit=1,
 
629
  )
630
 
631
  img2vid_preset.change(
632
+ fn=preset_changed,
633
+ inputs=[img2vid_preset],
634
+ outputs=[
635
+ img2vid_current_height,
636
+ img2vid_current_width,
637
+ img2vid_current_num_frames,
638
+ *img2vid_advanced[3:]
639
+ ]
640
  )
641
 
642
  img2vid_enhance_toggle.change(
 
653
  img2vid_enhance_toggle,
654
  img2vid_negative_prompt,
655
  img2vid_frame_rate,
656
+ *img2vid_advanced[:3], # seed, inference_steps, guidance_scale
657
+ img2vid_current_height,
658
+ img2vid_current_width,
659
+ img2vid_current_num_frames,
660
  ],
661
  outputs=img2vid_output,
662
  concurrency_limit=1,
 
667
  if __name__ == "__main__":
668
  iface.queue(max_size=64, default_concurrency_limit=1, api_open=False).launch(
669
  share=True, show_api=False
670
+ )