openfree commited on
Commit
99ef2e5
โ€ข
1 Parent(s): 1434d9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -30
app.py CHANGED
@@ -212,15 +212,16 @@ pipeline = XoraVideoPipeline(
212
  vae=vae,
213
  ).to(device)
214
 
215
- # State ๋ณ€์ˆ˜๋“ค์˜ ์ดˆ๊ธฐ๊ฐ’ ์ˆ˜์ •
216
- txt2vid_current_height = gr.State(value=320)
217
- txt2vid_current_width = gr.State(value=512)
218
- txt2vid_current_num_frames = gr.State(value=257) # 10.3์ดˆ
219
 
220
- img2vid_current_height = gr.State(value=320)
221
- img2vid_current_width = gr.State(value=512)
222
- img2vid_current_num_frames = gr.State(value=257) # 10.3์ดˆ
223
 
 
 
 
 
 
 
 
 
224
 
225
  # Preset options for resolution and frame configuration
226
  # Convert frames to seconds assuming 25 FPS
@@ -251,19 +252,19 @@ preset_options = [
251
  {"label": "[16:9] 544x320, 9.6์ดˆ", "width": 544, "height": 320, "num_frames": 241},
252
  {"label": "[16:9] 512x320, 10.3์ดˆ", "width": 512, "height": 320, "num_frames": 257},
253
  ]
254
- # preset_changed ํ•จ์ˆ˜ ๋‹จ์ˆœํ™”
 
 
255
  def preset_changed(preset):
256
  selected = next(item for item in preset_options if item["label"] == preset)
257
- return (
258
- selected["height"],
259
- selected["width"],
260
- selected["num_frames"],
261
- gr.update(visible=False),
262
- gr.update(visible=False),
263
- gr.update(visible=False),
264
- )
265
-
266
-
267
 
268
  def generate_video_from_text(
269
  prompt="",
@@ -604,24 +605,26 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
604
  with gr.Column():
605
  img2vid_output = gr.Video(label="์ƒ์„ฑ๋œ ๋น„๋””์˜ค")
606
 
607
- # Event handlers
608
  txt2vid_preset.change(
609
  fn=preset_changed,
610
  inputs=[txt2vid_preset],
611
- outputs=[
612
- txt2vid_current_height,
613
- txt2vid_current_width,
614
- txt2vid_current_num_frames,
615
- *txt2vid_advanced[3:]
616
- ]
 
 
617
  )
618
 
 
619
  txt2vid_enhance_toggle.change(
620
  fn=update_prompt_t2v,
621
  inputs=[txt2vid_prompt, txt2vid_enhance_toggle],
622
  outputs=txt2vid_prompt
623
  )
624
-
625
  txt2vid_generate.click(
626
  fn=generate_video_from_text,
627
  inputs=[
@@ -630,16 +633,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
630
  txt2vid_negative_prompt,
631
  txt2vid_frame_rate,
632
  *txt2vid_advanced[:3], # seed, inference_steps, guidance_scale
633
- txt2vid_current_height,
634
- txt2vid_current_width,
635
- txt2vid_current_num_frames,
636
- ],
637
  outputs=txt2vid_output,
638
  concurrency_limit=1,
639
  concurrency_id="generate_video",
640
  queue=True,
641
  )
642
 
 
643
  img2vid_preset.change(
644
  fn=preset_changed,
645
  inputs=[img2vid_preset],
 
212
  vae=vae,
213
  ).to(device)
214
 
 
 
 
 
215
 
 
 
 
216
 
217
+ # State ๋ณ€์ˆ˜๋“ค์„ ๋ช…์‹œ์ ์ธ ID์™€ ํ•จ๊ป˜ ์ดˆ๊ธฐํ™”
218
+ txt2vid_current_height = gr.State(value=320, label="txt2vid_height")
219
+ txt2vid_current_width = gr.State(value=512, label="txt2vid_width")
220
+ txt2vid_current_num_frames = gr.State(value=257, label="txt2vid_frames")
221
+
222
+ img2vid_current_height = gr.State(value=320, label="img2vid_height")
223
+ img2vid_current_width = gr.State(value=512, label="img2vid_width")
224
+ img2vid_current_num_frames = gr.State(value=257, label="img2vid_frames")
225
 
226
  # Preset options for resolution and frame configuration
227
  # Convert frames to seconds assuming 25 FPS
 
252
  {"label": "[16:9] 544x320, 9.6์ดˆ", "width": 544, "height": 320, "num_frames": 241},
253
  {"label": "[16:9] 512x320, 10.3์ดˆ", "width": 512, "height": 320, "num_frames": 257},
254
  ]
255
+
256
+
257
+ # preset_changed ํ•จ์ˆ˜ ์ˆ˜์ •
258
  def preset_changed(preset):
259
  selected = next(item for item in preset_options if item["label"] == preset)
260
+ return {
261
+ "txt2vid_height": selected["height"],
262
+ "txt2vid_width": selected["width"],
263
+ "txt2vid_frames": selected["num_frames"],
264
+ "height_slider": gr.update(visible=False),
265
+ "width_slider": gr.update(visible=False),
266
+ "num_frames_slider": gr.update(visible=False),
267
+ }
 
 
268
 
269
  def generate_video_from_text(
270
  prompt="",
 
605
  with gr.Column():
606
  img2vid_output = gr.Video(label="์ƒ์„ฑ๋œ ๋น„๋””์˜ค")
607
 
608
+ # preset ๋ณ€๊ฒฝ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์ˆ˜์ •
609
  txt2vid_preset.change(
610
  fn=preset_changed,
611
  inputs=[txt2vid_preset],
612
+ outputs={
613
+ txt2vid_current_height: "txt2vid_height",
614
+ txt2vid_current_width: "txt2vid_width",
615
+ txt2vid_current_num_frames: "txt2vid_frames",
616
+ txt2vid_advanced[3]: "height_slider",
617
+ txt2vid_advanced[4]: "width_slider",
618
+ txt2vid_advanced[5]: "num_frames_slider",
619
+ }
620
  )
621
 
622
+
623
  txt2vid_enhance_toggle.change(
624
  fn=update_prompt_t2v,
625
  inputs=[txt2vid_prompt, txt2vid_enhance_toggle],
626
  outputs=txt2vid_prompt
627
  )
 
628
  txt2vid_generate.click(
629
  fn=generate_video_from_text,
630
  inputs=[
 
633
  txt2vid_negative_prompt,
634
  txt2vid_frame_rate,
635
  *txt2vid_advanced[:3], # seed, inference_steps, guidance_scale
636
+ txt2vid_current_height, # State ๋ณ€์ˆ˜ ์ฐธ์กฐ
637
+ txt2vid_current_width, # State ๋ณ€์ˆ˜ ์ฐธ์กฐ
638
+ txt2vid_current_num_frames, # State ๋ณ€์ˆ˜ ์ฐธ์กฐ
639
+ ],
640
  outputs=txt2vid_output,
641
  concurrency_limit=1,
642
  concurrency_id="generate_video",
643
  queue=True,
644
  )
645
 
646
+
647
  img2vid_preset.change(
648
  fn=preset_changed,
649
  inputs=[img2vid_preset],