Fabrice-TIERCELIN commited on
Commit
d7514c8
·
verified ·
1 Parent(s): 511b862

total_second_length

Browse files
Files changed (1) hide show
  1. app_endframe.py +23 -3
app_endframe.py CHANGED
@@ -64,7 +64,7 @@ vae = AutoencoderKLHunyuanVideo.from_pretrained("Fabrice-TIERCELIN/HunyuanVideo"
64
  feature_extractor = SiglipImageProcessor.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='feature_extractor')
65
  image_encoder = SiglipVisionModel.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='image_encoder', torch_dtype=torch.float16).cpu()
66
 
67
- transformer = HunyuanVideoTransformer3DModelPacked.from_pretrained('Fabrice-TIERCELIN/FramePackI2V_HY', torch_dtype=torch.bfloat16).cpu()
68
 
69
  vae.eval()
70
  text_encoder.eval()
@@ -108,7 +108,8 @@ outputs_folder = './outputs/'
108
  os.makedirs(outputs_folder, exist_ok=True)
109
 
110
  input_video_debug_value = None
111
- prompt_debug_value = None
 
112
 
113
  # 20250506 pftq: Added function to encode input video frames into latents
114
  @torch.no_grad()
@@ -666,11 +667,14 @@ def worker(input_video, end_frame, end_frame_weight, prompt, n_prompt, seed, bat
666
 
667
  # 20250506 pftq: Modified process to pass clean frame count, etc
668
  def get_duration(input_video, end_frame, end_frame_weight, 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):
 
 
 
669
  return total_second_length * 60
670
 
671
  @spaces.GPU(duration=get_duration)
672
  def process(input_video, end_frame, end_frame_weight, 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):
673
- global stream, high_vram, input_video_debug_value, prompt_debug_value
674
 
675
  if input_video_debug_value is not None:
676
  input_video = input_video_debug_value
@@ -680,6 +684,10 @@ def process(input_video, end_frame, end_frame_weight, prompt, n_prompt, seed, ba
680
  prompt = prompt_debug_value
681
  prompt_debug_value = None
682
 
 
 
 
 
683
  # 20250506 pftq: Updated assertion for video input
684
  assert input_video is not None, 'No input video!'
685
 
@@ -798,6 +806,7 @@ with block:
798
  with gr.Row():
799
  input_video_debug = gr.Video(sources='upload', label="Input Video Debug", height=320)
800
  prompt_debug = gr.Textbox(label="Prompt Debug", value='')
 
801
 
802
  with gr.Column():
803
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
@@ -857,6 +866,11 @@ with block:
857
  prompt_debug_value = input
858
  return []
859
 
 
 
 
 
 
860
  input_video_debug.upload(
861
  fn=handle_input_video_debug_upload,
862
  inputs=[input_video_debug],
@@ -868,5 +882,11 @@ with block:
868
  inputs=[prompt_debug],
869
  outputs=[]
870
  )
 
 
 
 
 
 
871
 
872
  block.launch(share=True)
 
64
  feature_extractor = SiglipImageProcessor.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='feature_extractor')
65
  image_encoder = SiglipVisionModel.from_pretrained("lllyasviel/flux_redux_bfl", subfolder='image_encoder', torch_dtype=torch.float16).cpu()
66
 
67
+ transformer = HunyuanVideoTransformer3DModelPacked.from_pretrained('lllyasviel/FramePackI2V_HY', torch_dtype=torch.bfloat16).cpu()
68
 
69
  vae.eval()
70
  text_encoder.eval()
 
108
  os.makedirs(outputs_folder, exist_ok=True)
109
 
110
  input_video_debug_value = None
111
+ prompt_debug_valuetotal_second_length_debug_value
112
+ total_second_length_debug_value
113
 
114
  # 20250506 pftq: Added function to encode input video frames into latents
115
  @torch.no_grad()
 
667
 
668
  # 20250506 pftq: Modified process to pass clean frame count, etc
669
  def get_duration(input_video, end_frame, end_frame_weight, 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):
670
+ global total_second_length_debug_value
671
+ if total_second_length_debug_value is not None:
672
+ return total_second_length_debug_value * 60
673
  return total_second_length * 60
674
 
675
  @spaces.GPU(duration=get_duration)
676
  def process(input_video, end_frame, end_frame_weight, 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):
677
+ global stream, high_vram, input_video_debug_value, prompt_debug_value, total_second_length_debug_value
678
 
679
  if input_video_debug_value is not None:
680
  input_video = input_video_debug_value
 
684
  prompt = prompt_debug_value
685
  prompt_debug_value = None
686
 
687
+ if total_second_length_debug_value is not None:
688
+ total_second_length = total_second_length_debug_value
689
+ total_second_length_debug_value = None
690
+
691
  # 20250506 pftq: Updated assertion for video input
692
  assert input_video is not None, 'No input video!'
693
 
 
806
  with gr.Row():
807
  input_video_debug = gr.Video(sources='upload', label="Input Video Debug", height=320)
808
  prompt_debug = gr.Textbox(label="Prompt Debug", value='')
809
+ total_second_length_debug = gr.Slider(label="Additional Video Length to Generate (Seconds) Debug", minimum=1, maximum=120, value=5, step=0.1)
810
 
811
  with gr.Column():
812
  preview_image = gr.Image(label="Next Latents", height=200, visible=False)
 
866
  prompt_debug_value = input
867
  return []
868
 
869
+ def handle_total_second_length_debug_change(input):
870
+ global total_second_length_debug_value
871
+ total_second_length_debug_value = input
872
+ return []
873
+
874
  input_video_debug.upload(
875
  fn=handle_input_video_debug_upload,
876
  inputs=[input_video_debug],
 
882
  inputs=[prompt_debug],
883
  outputs=[]
884
  )
885
+
886
+ total_second_length_debug.change(
887
+ fn=handle_total_second_length_debug_change,
888
+ inputs=[total_second_length_debug],
889
+ outputs=[]
890
+ )
891
 
892
  block.launch(share=True)