Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions demo_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import argparse
import math
import random

from PIL import Image
from diffusers import AutoencoderKLHunyuanVideo
Expand Down Expand Up @@ -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()

Expand All @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -397,7 +402,7 @@ def end_process():
gr.HTML('<div style="text-align:center; margin-top:20px;">Share your results and find ideas at the <a href="https://x.com/search?q=framepack&f=live" target="_blank">FramePack Twitter (X) thread</a></div>')

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)


Expand Down
17 changes: 11 additions & 6 deletions demo_gradio_f1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import argparse
import math
import random

from PIL import Image
from diffusers import AutoencoderKLHunyuanVideo
Expand Down Expand Up @@ -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()

Expand All @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -378,7 +383,7 @@ def end_process():
gr.HTML('<div style="text-align:center; margin-top:20px;">Share your results and find ideas at the <a href="https://x.com/search?q=framepack&f=live" target="_blank">FramePack Twitter (X) thread</a></div>')

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)


Expand Down