Fabrice-TIERCELIN commited on
Commit
de06100
·
verified ·
1 Parent(s): aa5119c

Generation mode

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1622,7 +1622,7 @@ def process_video_on_gpu(input_video, end_frame, prompts, generation_mode, n_pro
1622
  stream = AsyncStream()
1623
 
1624
  # 20250506 pftq: Pass num_clean_frames, vae_batch, etc
1625
- async_run(worker_video if generation_mode == "video" else worker_video_end, input_video, end_frame, prompts, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch)
1626
 
1627
  output_filename = None
1628
 
@@ -1692,7 +1692,7 @@ def process_video(input_video, end_frame, prompt, generation_mode, n_prompt, ran
1692
  if cfg > 1:
1693
  gs = 1
1694
 
1695
- yield from process_video_on_gpu(input_video, prompts, generation_mode, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch)
1696
 
1697
  def end_process():
1698
  stream.input_queue.push('end')
@@ -1765,9 +1765,9 @@ with block:
1765
  generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Start & end frames", "start_end"], ["Video Extension", "video"], ["Video & end frame", "video_end"]], elem_id="generation-mode", label="Input mode", value = "image")
1766
  text_to_video_hint = gr.HTML("Text-to-Video badly works with a flash effect at the start. I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
1767
  input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
1768
- end_image = gr.Image(sources='upload', type="numpy", label="End Frame (optional)", height=320)
1769
  image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
1770
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
 
1771
  timeless_prompt = gr.Textbox(label="Timeless prompt", info='Used on the whole duration of the generation', value='', placeholder="The creature starts to move, fast motion, fixed camera, focus motion, consistent arm, consistent position, mute colors, insanely detailed")
1772
  prompt_number = gr.Slider(label="Timed prompt number", minimum=0, maximum=1000, value=0, step=1, info='Prompts will automatically appear')
1773
 
@@ -2550,6 +2550,22 @@ with block:
2550
  gr.update(visible = True), # prompt_hint
2551
  gr.update(visible = False) # fps_number
2552
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2553
 
2554
  def handle_field_debug_change(input_image_debug_data, input_video_debug_data, end_image_debug_data, prompt_debug_data, total_second_length_debug_data):
2555
  print("handle_field_debug_change")
 
1622
  stream = AsyncStream()
1623
 
1624
  # 20250506 pftq: Pass num_clean_frames, vae_batch, etc
1625
+ async_run(worker_video_end if generation_mode == "video_end" else worker_video, input_video, end_frame, prompts, n_prompt, seed, batch, resolution, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch)
1626
 
1627
  output_filename = None
1628
 
 
1692
  if cfg > 1:
1693
  gs = 1
1694
 
1695
+ yield from process_video_on_gpu(input_video, end_frame, prompt, generation_mode, n_prompt, seed, batch, resolution, total_second_length, allocation_time, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, enable_preview, use_teacache, no_resize, mp4_crf, num_clean_frames, vae_batch)
1696
 
1697
  def end_process():
1698
  stream.input_queue.push('end')
 
1765
  generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Start & end frames", "start_end"], ["Video Extension", "video"], ["Video & end frame", "video_end"]], elem_id="generation-mode", label="Input mode", value = "image")
1766
  text_to_video_hint = gr.HTML("Text-to-Video badly works with a flash effect at the start. I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
1767
  input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
 
1768
  image_position = gr.Slider(label="Image position", minimum=0, maximum=100, value=0, step=1, info='0=Video start; 100=Video end (lower quality)')
1769
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
1770
+ end_image = gr.Image(sources='upload', type="numpy", label="End Frame (optional)", height=320)
1771
  timeless_prompt = gr.Textbox(label="Timeless prompt", info='Used on the whole duration of the generation', value='', placeholder="The creature starts to move, fast motion, fixed camera, focus motion, consistent arm, consistent position, mute colors, insanely detailed")
1772
  prompt_number = gr.Slider(label="Timed prompt number", minimum=0, maximum=1000, value=0, step=1, info='Prompts will automatically appear')
1773
 
 
2550
  gr.update(visible = True), # prompt_hint
2551
  gr.update(visible = False) # fps_number
2552
  ]
2553
+ elif generation_mode_data == "video_end":
2554
+ return [
2555
+ gr.update(visible = False), # text_to_video_hint
2556
+ gr.update(visible = False), # image_position
2557
+ gr.update(visible = False), # input_image
2558
+ gr.update(visible = True), # end_image
2559
+ gr.update(visible = True), # input_video
2560
+ gr.update(visible = False), # start_button
2561
+ gr.update(visible = True), # start_button_video
2562
+ gr.update(visible = True), # no_resize
2563
+ gr.update(visible = True), # batch
2564
+ gr.update(visible = True), # num_clean_frames
2565
+ gr.update(visible = True), # vae_batch
2566
+ gr.update(visible = True), # prompt_hint
2567
+ gr.update(visible = False) # fps_number
2568
+ ]
2569
 
2570
  def handle_field_debug_change(input_image_debug_data, input_video_debug_data, end_image_debug_data, prompt_debug_data, total_second_length_debug_data):
2571
  print("handle_field_debug_change")