Fabrice-TIERCELIN commited on
Commit
39fcc22
·
verified ·
1 Parent(s): 7ad42f2

@spaces.GPU(duration=get_duration)

Browse files
Files changed (1) hide show
  1. app_v2v.py +32 -3
app_v2v.py CHANGED
@@ -112,6 +112,10 @@ stream = AsyncStream()
112
  outputs_folder = './outputs/'
113
  os.makedirs(outputs_folder, exist_ok=True)
114
 
 
 
 
 
115
  @spaces.GPU()
116
  @torch.no_grad()
117
  def video_encode(video_path, resolution, no_resize, vae, vae_batch_size=16, device="cuda", width=None, height=None):
@@ -531,9 +535,28 @@ def worker(input_video, prompt, n_prompt, seed, batch, resolution, total_second_
531
  stream.output_queue.push(('end', None))
532
  return
533
 
534
- @spaces.GPU()
 
 
 
 
 
 
535
  def process(input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
536
- global stream, high_vram
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  # 20250506 pftq: Updated assertion for video input
538
  assert input_video is not None, 'No input video!'
539
 
@@ -636,13 +659,19 @@ with block:
636
 
637
  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. ")
638
 
 
 
 
 
 
639
  with gr.Column():
640
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
641
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
642
  progress_desc = gr.Markdown('', elem_classes='no-generating-animation')
643
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
644
 
645
- gr.Examples(
 
646
  examples = [
647
  [
648
  "./img_examples/Example1.mp4", # input_video
 
112
  outputs_folder = './outputs/'
113
  os.makedirs(outputs_folder, exist_ok=True)
114
 
115
+ input_video_debug_value = None
116
+ prompt_debug_value = None
117
+ total_second_length_debug_value = None
118
+
119
  @spaces.GPU()
120
  @torch.no_grad()
121
  def video_encode(video_path, resolution, no_resize, vae, vae_batch_size=16, device="cuda", width=None, height=None):
 
535
  stream.output_queue.push(('end', None))
536
  return
537
 
538
+ def get_duration(input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
539
+ global total_second_length_debug_value
540
+ if total_second_length_debug_value is not None:
541
+ return total_second_length_debug_value * 60 * 2
542
+ return total_second_length * 60 * 2
543
+
544
+ @spaces.GPU(duration=get_duration)
545
  def process(input_video, prompt, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch):
546
+ global stream, high_vram, input_video_debug_value, prompt_debug_value, total_second_length_debug_value
547
+
548
+ if input_video_debug_value is not None:
549
+ input_video = input_video_debug_value
550
+ input_video_debug_value = None
551
+
552
+ if prompt_debug_value is not None:
553
+ prompt = prompt_debug_value
554
+ prompt_debug_value = None
555
+
556
+ if total_second_length_debug_value is not None:
557
+ total_second_length = total_second_length_debug_value
558
+ total_second_length_debug_value = None
559
+
560
  # 20250506 pftq: Updated assertion for video input
561
  assert input_video is not None, 'No input video!'
562
 
 
659
 
660
  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. ")
661
 
662
+ with gr.Row():
663
+ input_video_debug = gr.Video(sources='upload', label="Input Video Debug", height=320)
664
+ prompt_debug = gr.Textbox(label="Prompt Debug", value='')
665
+ total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
666
+
667
  with gr.Column():
668
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
669
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
670
  progress_desc = gr.Markdown('', elem_classes='no-generating-animation')
671
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
672
 
673
+ with gr.Row(visible=False):
674
+ gr.Examples(
675
  examples = [
676
  [
677
  "./img_examples/Example1.mp4", # input_video