diff --git a/demo_gradio.py b/demo_gradio.py index c59ed58a..1a793594 100644 --- a/demo_gradio.py +++ b/demo_gradio.py @@ -12,6 +12,7 @@ import numpy as np import argparse import math +import random from PIL import Image from diffusers import AutoencoderKLHunyuanVideo @@ -319,7 +320,11 @@ def process(input_image, prompt, n_prompt, seed, total_second_length, latent_win global stream assert input_image is not None, 'No input image!' - yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True) + if(not seed): + seed = random.randint(1, 2**32) + yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.update(value=seed) + else: + yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.skip() stream = AsyncStream() @@ -332,14 +337,14 @@ def process(input_image, prompt, n_prompt, seed, total_second_length, latent_win if flag == 'file': output_filename = data - yield output_filename, gr.update(), gr.update(), gr.update(), gr.update(interactive=False), gr.update(interactive=True) + yield output_filename, gr.update(), gr.update(), gr.update(), gr.update(interactive=False), gr.update(interactive=True), gr.skip() if flag == 'progress': preview, desc, html = data - yield gr.update(), gr.update(visible=True, value=preview), desc, html, gr.update(interactive=False), gr.update(interactive=True) + yield gr.update(), gr.update(visible=True, value=preview), desc, html, gr.update(interactive=False), gr.update(interactive=True), gr.skip() if flag == 'end': - yield output_filename, gr.update(visible=False), gr.update(), '', gr.update(interactive=True), gr.update(interactive=False) + yield output_filename, gr.update(visible=False), gr.update(), '', gr.update(interactive=True), gr.update(interactive=False), gr.skip() break @@ -373,7 +378,7 @@ def end_process(): use_teacache = gr.Checkbox(label='Use TeaCache', value=True, info='Faster speed, but often makes hands and fingers slightly worse.') n_prompt = gr.Textbox(label="Negative Prompt", value="", visible=False) # Not used - seed = gr.Number(label="Seed", value=31337, precision=0) + seed = gr.Number(label="Seed", value=-1, precision=0) total_second_length = gr.Slider(label="Total Video Length (Seconds)", minimum=1, maximum=120, value=5, step=0.1) latent_window_size = gr.Slider(label="Latent Window Size", minimum=1, maximum=33, value=9, step=1, visible=False) # Should not change @@ -397,7 +402,7 @@ def end_process(): gr.HTML('
Share your results and find ideas at the FramePack Twitter (X) thread
') ips = [input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, mp4_crf] - start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button]) + start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button, seed], show_progress_on=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button]) end_button.click(fn=end_process) diff --git a/demo_gradio_f1.py b/demo_gradio_f1.py index bb9133de..157d9d24 100644 --- a/demo_gradio_f1.py +++ b/demo_gradio_f1.py @@ -12,6 +12,7 @@ import numpy as np import argparse import math +import random from PIL import Image from diffusers import AutoencoderKLHunyuanVideo @@ -301,7 +302,11 @@ def process(input_image, prompt, n_prompt, seed, total_second_length, latent_win global stream assert input_image is not None, 'No input image!' - yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True) + if(not seed): + seed = random.randint(1, 2**32) + yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.update(value=seed) + else: + yield None, None, '', '', gr.update(interactive=False), gr.update(interactive=True), gr.skip() stream = AsyncStream() @@ -314,14 +319,14 @@ def process(input_image, prompt, n_prompt, seed, total_second_length, latent_win if flag == 'file': output_filename = data - yield output_filename, gr.update(), gr.update(), gr.update(), gr.update(interactive=False), gr.update(interactive=True) + yield output_filename, gr.update(), gr.update(), gr.update(), gr.update(interactive=False), gr.update(interactive=True), gr.skip() if flag == 'progress': preview, desc, html = data - yield gr.update(), gr.update(visible=True, value=preview), desc, html, gr.update(interactive=False), gr.update(interactive=True) + yield gr.update(), gr.update(visible=True, value=preview), desc, html, gr.update(interactive=False), gr.update(interactive=True), gr.skip() if flag == 'end': - yield output_filename, gr.update(visible=False), gr.update(), '', gr.update(interactive=True), gr.update(interactive=False) + yield output_filename, gr.update(visible=False), gr.update(), '', gr.update(interactive=True), gr.update(interactive=False), gr.skip() break @@ -355,7 +360,7 @@ def end_process(): use_teacache = gr.Checkbox(label='Use TeaCache', value=True, info='Faster speed, but often makes hands and fingers slightly worse.') n_prompt = gr.Textbox(label="Negative Prompt", value="", visible=False) # Not used - seed = gr.Number(label="Seed", value=31337, precision=0) + seed = gr.Number(label="Seed", value=-1, precision=0) total_second_length = gr.Slider(label="Total Video Length (Seconds)", minimum=1, maximum=120, value=5, step=0.1) latent_window_size = gr.Slider(label="Latent Window Size", minimum=1, maximum=33, value=9, step=1, visible=False) # Should not change @@ -378,7 +383,7 @@ def end_process(): gr.HTML('
Share your results and find ideas at the FramePack Twitter (X) thread
') ips = [input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache, mp4_crf] - start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button]) + start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button, seed], show_progress_on=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button]) end_button.click(fn=end_process)