Skip to content

Commit ff9f5b9

Browse files
committed
support random seed
1 parent 661b98c commit ff9f5b9

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

gradio_app.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def dynamicrafter_demo(result_dir='./tmp/', res=1024):
7373
with gr.Row():
7474
i2v_input_text = gr.Text(label='Prompts')
7575
with gr.Row():
76-
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
7776
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
7877
i2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5, elem_id="i2v_cfg_scale")
7978
with gr.Row():
@@ -112,7 +111,6 @@ def dynamicrafter_demo(result_dir='./tmp/', res=1024):
112111
with gr.Row():
113112
i2v_input_text = gr.Text(label='Prompts')
114113
with gr.Row():
115-
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
116114
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
117115
i2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5, elem_id="i2v_cfg_scale")
118116
with gr.Row():
@@ -151,7 +149,6 @@ def dynamicrafter_demo(result_dir='./tmp/', res=1024):
151149
with gr.Row():
152150
i2v_input_text = gr.Text(label='Prompts')
153151
with gr.Row():
154-
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
155152
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
156153
i2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5, elem_id="i2v_cfg_scale")
157154
with gr.Row():

gradio_app_interp_and_loop.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os, argparse
22
import sys
33
import gradio as gr
4+
import random
45
from scripts.gradio.i2v_test_application import Image2Video
56
sys.path.insert(1, os.path.join(sys.path[0], 'lvdm'))
67

@@ -16,18 +17,19 @@
1617
['prompts/512_loop/40.png', 'flowers swaying in the wind', 50, 7.5, 1.0, 5, 234],
1718
]
1819

20+
max_seed = 2 ** 31
1921

2022

2123
def dynamicrafter_demo(result_dir='./tmp/', res=512):
2224
if res == 1024:
2325
resolution = '576_1024'
24-
css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height:576px}"""
26+
css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height:576px} #random_button {max-width: 100px !important}"""
2527
elif res == 512:
2628
resolution = '320_512'
27-
css = """#input_img {max-width: 512px !important} #output_vid {max-width: 512px; max-height: 320px} #input_img2 {max-width: 512px !important} #output_vid {max-width: 512px; max-height: 320px}"""
29+
css = """#input_img {max-width: 512px !important} #output_vid {max-width: 512px; max-height: 320px} #random_button {max-width: 100px !important} #input_img2 {max-width: 512px !important} #output_vid {max-width: 512px; max-height: 320px}"""
2830
elif res == 256:
2931
resolution = '256_256'
30-
css = """#input_img {max-width: 256px !important} #output_vid {max-width: 256px; max-height: 256px}"""
32+
css = """#input_img {max-width: 256px !important} #output_vid {max-width: 256px; max-height: 256px} #random_button {max-width: 100px !important}"""
3133
else:
3234
raise NotImplementedError(f"Unsupported resolution: {res}")
3335
image2video = Image2Video(result_dir, resolution=resolution)
@@ -55,12 +57,19 @@ def dynamicrafter_demo(result_dir='./tmp/', res=512):
5557
with gr.Row():
5658
i2v_input_text = gr.Text(label='Prompts')
5759
with gr.Row():
58-
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=50000, step=1, value=123)
5960
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
6061
i2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5, elem_id="i2v_cfg_scale")
6162
with gr.Row():
6263
i2v_steps = gr.Slider(minimum=1, maximum=60, step=1, elem_id="i2v_steps", label="Sampling steps", value=50)
6364
i2v_motion = gr.Slider(minimum=5, maximum=30, step=1, elem_id="i2v_motion", label="FPS", value=10)
65+
with gr.Row():
66+
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=max_seed, step=1, value=123)
67+
random_button = gr.Button('\U0001f3b2\ufe0f', elem_id="random_button")
68+
random_button.click(
69+
fn=lambda: random.randint(0, max_seed),
70+
outputs=i2v_seed,
71+
queue=False
72+
)
6473
i2v_end_btn = gr.Button("Generate")
6574
with gr.Column():
6675
with gr.Row():
@@ -88,12 +97,19 @@ def dynamicrafter_demo(result_dir='./tmp/', res=512):
8897
with gr.Row():
8998
i2v_input_text = gr.Text(label='Prompts')
9099
with gr.Row():
91-
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=50000, step=1, value=123)
92100
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
93101
i2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5, elem_id="i2v_cfg_scale")
94102
with gr.Row():
95103
i2v_steps = gr.Slider(minimum=1, maximum=60, step=1, elem_id="i2v_steps", label="Sampling steps", value=50)
96104
i2v_motion = gr.Slider(minimum=5, maximum=30, step=1, elem_id="i2v_motion", label="FPS", value=5)
105+
with gr.Row():
106+
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=max_seed, step=1, value=123)
107+
random_button = gr.Button('\U0001f3b2\ufe0f', elem_id="random_button")
108+
random_button.click(
109+
fn=lambda: random.randint(0, max_seed),
110+
outputs=i2v_seed,
111+
queue=False
112+
)
97113
i2v_end_btn = gr.Button("Generate")
98114
# with gr.Tab(label='Result'):
99115
with gr.Row():

0 commit comments

Comments
 (0)