Fabrice-TIERCELIN commited on
Commit
8520b0a
·
verified ·
1 Parent(s): 65a628f
Files changed (1) hide show
  1. app.py +61 -1
app.py CHANGED
@@ -92,6 +92,10 @@ examples = [
92
  ["img_examples/3.png", "The woman dances elegantly among the blossoms, spinning slowly with flowing sleeves and graceful hand movements."],
93
  ]
94
 
 
 
 
 
95
  def generate_examples(input_image, prompt):
96
 
97
  t2v=False
@@ -338,8 +342,13 @@ def worker(input_image, prompt, n_prompt, seed, total_second_length, latent_wind
338
  return
339
 
340
  def get_duration(input_image, prompt, t2v, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, mp4_crf):
 
 
 
 
341
  return total_second_length * 60
342
 
 
343
  @spaces.GPU(duration=get_duration)
344
  def process(input_image, prompt,
345
  t2v=False,
@@ -355,7 +364,19 @@ def process(input_image, prompt,
355
  use_teacache=True,
356
  mp4_crf=16
357
  ):
358
- global stream
 
 
 
 
 
 
 
 
 
 
 
 
359
 
360
  # assert input_image is not None, 'No input image!'
361
  if t2v:
@@ -464,6 +485,11 @@ adapted from the officical code repo [FramePack](https://github.com/lllyasviel/F
464
 
465
  mp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")
466
 
 
 
 
 
 
467
  with gr.Column():
468
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
469
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
@@ -511,4 +537,38 @@ adapted from the officical code repo [FramePack](https://github.com/lllyasviel/F
511
  )
512
 
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  block.launch(share=True, mcp_server=True)
 
92
  ["img_examples/3.png", "The woman dances elegantly among the blossoms, spinning slowly with flowing sleeves and graceful hand movements."],
93
  ]
94
 
95
+ input_image_debug_value = None
96
+ prompt_debug_value = None
97
+ total_second_length_debug_value = None
98
+
99
  def generate_examples(input_image, prompt):
100
 
101
  t2v=False
 
342
  return
343
 
344
  def get_duration(input_image, prompt, t2v, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, mp4_crf):
345
+ global total_second_length_debug_value
346
+
347
+ if total_second_length_debug_value is not None:
348
+ return total_second_length_debug_value * 60
349
  return total_second_length * 60
350
 
351
+
352
  @spaces.GPU(duration=get_duration)
353
  def process(input_image, prompt,
354
  t2v=False,
 
364
  use_teacache=True,
365
  mp4_crf=16
366
  ):
367
+ global stream, input_image_debug_value, prompt_debug_value, total_second_length_debug_value
368
+
369
+ if input_image_debug_value is not None:
370
+ input_image = input_image_debug_value
371
+ input_image_debug_value = None
372
+
373
+ if prompt_debug_value is not None:
374
+ prompt = prompt_debug_value
375
+ prompt_debug_value = None
376
+
377
+ if total_second_length_debug_value is not None:
378
+ total_second_length = total_second_length_debug_value
379
+ total_second_length_debug_value = None
380
 
381
  # assert input_image is not None, 'No input image!'
382
  if t2v:
 
485
 
486
  mp4_crf = gr.Slider(label="MP4 Compression", minimum=0, maximum=100, value=16, step=1, info="Lower means better quality. 0 is uncompressed. Change to 16 if you get black outputs. ")
487
 
488
+ with gr.Accordion("Debug", open=False):
489
+ input_image_debug = gr.Image(type="numpy", label="Image Debug", height=320)
490
+ prompt_debug = gr.Textbox(label="Prompt Debug", value='')
491
+ total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
492
+
493
  with gr.Column():
494
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
495
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
 
537
  )
538
 
539
 
540
+ def handle_input_image_debug_upload(input):
541
+ global input_image_debug_value
542
+ input_image_debug_value = input
543
+ return []
544
+
545
+ def handle_prompt_debug_change(input):
546
+ global prompt_debug_value
547
+ prompt_debug_value = input
548
+ return []
549
+
550
+ def handle_total_second_length_debug_change(input):
551
+ global total_second_length_debug_value
552
+ total_second_length_debug_value = input
553
+ return []
554
+
555
+ input_image_debug.upload(
556
+ fn=handle_input_image_debug_upload,
557
+ inputs=[input_image_debug],
558
+ outputs=[]
559
+ )
560
+
561
+ prompt_debug.change(
562
+ fn=handle_prompt_debug_change,
563
+ inputs=[prompt_debug],
564
+ outputs=[]
565
+ )
566
+
567
+ total_second_length_debug.change(
568
+ fn=handle_total_second_length_debug_change,
569
+ inputs=[total_second_length_debug],
570
+ outputs=[]
571
+ )
572
+
573
+
574
  block.launch(share=True, mcp_server=True)