Fabrice-TIERCELIN commited on
Commit
9b03991
·
verified ·
1 Parent(s): b214256

Synchronize

Browse files
Files changed (1) hide show
  1. app_endframe.py +1 -77
app_endframe.py CHANGED
@@ -108,8 +108,6 @@ stream = AsyncStream()
108
  outputs_folder = './outputs/'
109
  os.makedirs(outputs_folder, exist_ok=True)
110
 
111
- input_video_debug_value = prompt_debug_value = total_second_length_debug_value = None
112
-
113
  # 20250506 pftq: Added function to encode input video frames into latents
114
  @torch.no_grad()
115
  def video_encode(video_path, resolution, no_resize, vae, vae_batch_size=16, device="cuda", width=None, height=None):
@@ -671,9 +669,6 @@ def get_duration(
671
  randomize_seed,
672
  seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache,
673
  no_resize, mp4_crf, num_clean_frames, vae_batch):
674
- global total_second_length_debug_value
675
- if total_second_length_debug_value is not None:
676
- return min(total_second_length_debug_value * 60 * 2, 600)
677
  return total_second_length * 60 * 2
678
 
679
  @spaces.GPU(duration=get_duration)
@@ -682,18 +677,12 @@ def process(
682
  randomize_seed,
683
  seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache,
684
  no_resize, mp4_crf, num_clean_frames, vae_batch):
685
- global stream, high_vram, input_video_debug_value, prompt_debug_value, total_second_length_debug_value
686
 
687
  if torch.cuda.device_count() == 0:
688
  gr.Warning('Set this space to GPU config to make it work.')
689
  return None, None, None, None, None, None
690
 
691
- if input_video_debug_value is not None or prompt_debug_value is not None or total_second_length_debug_value is not None:
692
- input_video = input_video_debug_value
693
- prompt = prompt_debug_value
694
- total_second_length = total_second_length_debug_value
695
- input_video_debug_value = prompt_debug_value = total_second_length_debug_value = None
696
-
697
  if randomize_seed:
698
  seed = random.randint(0, np.iinfo(np.int32).max)
699
 
@@ -819,80 +808,15 @@ with block:
819
 
820
  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. ")
821
 
822
- with gr.Accordion("Debug", open=False):
823
- input_video_debug = gr.Video(sources='upload', label="Input Video Debug", height=320)
824
- prompt_debug = gr.Textbox(label="Prompt Debug", value='')
825
- total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
826
-
827
  with gr.Column():
828
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
829
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
830
  progress_desc = gr.Markdown('', elem_classes='no-generating-animation')
831
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
832
 
833
- with gr.Row(visible=False):
834
- gr.Examples(
835
- examples = [
836
- [
837
- "./img_examples/Example1.mp4", # input_video
838
- None, # end_frame
839
- 0.0, # end_frame_weight
840
- "View of the sea as far as the eye can see, from the seaside, a piece of land is barely visible on the horizon at the middle, the sky is radiant, reflections of the sun in the water, photorealistic, realistic, intricate details, 8k, insanely detailed",
841
- "Missing arm, unrealistic position, blurred, blurry", # n_prompt
842
- True, # randomize_seed
843
- 42, # seed
844
- 1, # batch
845
- 640, # resolution
846
- 1, # total_second_length
847
- 9, # latent_window_size
848
- 25, # steps
849
- 1.0, # cfg
850
- 10.0, # gs
851
- 0.0, # rs
852
- 6, # gpu_memory_preservation
853
- True, # use_teacache
854
- False, # no_resize
855
- 16, # mp4_crf
856
- 5, # num_clean_frames
857
- default_vae
858
- ],
859
- ],
860
- run_on_click = True,
861
- fn = process,
862
- inputs = [input_video, end_frame, end_frame_weight, prompt, n_prompt, randomize_seed, 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],
863
- outputs = [result_video, preview_image, progress_desc, progress_bar, start_button, end_button],
864
- cache_examples = True,
865
- )
866
-
867
  # 20250506 pftq: Updated inputs to include num_clean_frames
868
  ips = [input_video, end_frame, end_frame_weight, prompt, n_prompt, randomize_seed, 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]
869
  start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
870
  end_button.click(fn=end_process)
871
 
872
-
873
- def handle_field_debug_change(input_video_debug_data, prompt_debug_data, total_second_length_debug_data):
874
- global input_video_debug_value, prompt_debug_value, total_second_length_debug_value
875
- input_video_debug_value = input_video_debug_data
876
- prompt_debug_value = prompt_debug_data
877
- total_second_length_debug_value = total_second_length_debug_data
878
- return []
879
-
880
- input_video_debug.upload(
881
- fn=handle_field_debug_change,
882
- inputs=[input_video_debug, prompt_debug, total_second_length_debug],
883
- outputs=[]
884
- )
885
-
886
- prompt_debug.change(
887
- fn=handle_field_debug_change,
888
- inputs=[input_video_debug, prompt_debug, total_second_length_debug],
889
- outputs=[]
890
- )
891
-
892
- total_second_length_debug.change(
893
- fn=handle_field_debug_change,
894
- inputs=[input_video_debug, prompt_debug, total_second_length_debug],
895
- outputs=[]
896
- )
897
-
898
  block.launch(share=True)
 
108
  outputs_folder = './outputs/'
109
  os.makedirs(outputs_folder, exist_ok=True)
110
 
 
 
111
  # 20250506 pftq: Added function to encode input video frames into latents
112
  @torch.no_grad()
113
  def video_encode(video_path, resolution, no_resize, vae, vae_batch_size=16, device="cuda", width=None, height=None):
 
669
  randomize_seed,
670
  seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache,
671
  no_resize, mp4_crf, num_clean_frames, vae_batch):
 
 
 
672
  return total_second_length * 60 * 2
673
 
674
  @spaces.GPU(duration=get_duration)
 
677
  randomize_seed,
678
  seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache,
679
  no_resize, mp4_crf, num_clean_frames, vae_batch):
680
+ global stream, high_vram
681
 
682
  if torch.cuda.device_count() == 0:
683
  gr.Warning('Set this space to GPU config to make it work.')
684
  return None, None, None, None, None, None
685
 
 
 
 
 
 
 
686
  if randomize_seed:
687
  seed = random.randint(0, np.iinfo(np.int32).max)
688
 
 
808
 
809
  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. ")
810
 
 
 
 
 
 
811
  with gr.Column():
812
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
813
  result_video = gr.Video(label="Finished Frames", autoplay=True, show_share_button=False, height=512, loop=True)
814
  progress_desc = gr.Markdown('', elem_classes='no-generating-animation')
815
  progress_bar = gr.HTML('', elem_classes='no-generating-animation')
816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
  # 20250506 pftq: Updated inputs to include num_clean_frames
818
  ips = [input_video, end_frame, end_frame_weight, prompt, n_prompt, randomize_seed, 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]
819
  start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
820
  end_button.click(fn=end_process)
821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
822
  block.launch(share=True)