Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,8 @@ from funcs import (
|
|
20 |
save_videos
|
21 |
)
|
22 |
|
|
|
|
|
23 |
def download_model():
|
24 |
REPO_ID = 'Doubiiu/DynamiCrafter_1024'
|
25 |
filename_list = ['model.ckpt']
|
@@ -31,7 +33,12 @@ def download_model():
|
|
31 |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='./checkpoints/dynamicrafter_1024_v1/', force_download=True)
|
32 |
|
33 |
|
34 |
-
def infer(image, prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123):
|
|
|
|
|
|
|
|
|
|
|
35 |
resolution = (576, 1024)
|
36 |
download_model()
|
37 |
ckpt_path='checkpoints/dynamicrafter_1024_v1/model.ckpt'
|
@@ -95,18 +102,6 @@ def infer(image, prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123):
|
|
95 |
return video_path
|
96 |
|
97 |
|
98 |
-
i2v_examples = [
|
99 |
-
['prompts/1024/astronaut04.png', 'a man in an astronaut suit playing a guitar', 50, 7.5, 1.0, 6, 123],
|
100 |
-
['prompts/1024/bloom01.png', 'time-lapse of a blooming flower with leaves and a stem', 50, 7.5, 1.0, 10, 123],
|
101 |
-
['prompts/1024/girl07.png', 'a beautiful woman with long hair and a dress blowing in the wind', 50, 7.5, 1.0, 10, 123],
|
102 |
-
['prompts/1024/pour_bear.png', 'pouring beer into a glass of ice and beer', 50, 7.5, 1.0, 10, 123],
|
103 |
-
['prompts/1024/robot01.png', 'a robot is walking through a destroyed city', 50, 7.5, 1.0, 10, 123],
|
104 |
-
['prompts/1024/firework03.png', 'fireworks display', 50, 7.5, 1.0, 10, 123],
|
105 |
-
]
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height: 576px}"""
|
111 |
|
112 |
with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
|
@@ -126,30 +121,20 @@ with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
|
|
126 |
with gr.Tab(label='ImageAnimation_576x1024'):
|
127 |
with gr.Column():
|
128 |
with gr.Row():
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
with gr.Row():
|
144 |
-
i2v_output_video = gr.Video(label="Generated Video",elem_id="output_vid",autoplay=True,show_share_button=True)
|
145 |
-
|
146 |
-
gr.Examples(examples=i2v_examples,
|
147 |
-
inputs=[i2v_input_image, i2v_input_text, i2v_steps, i2v_cfg_scale, i2v_eta, i2v_motion, i2v_seed],
|
148 |
-
outputs=[i2v_output_video],
|
149 |
-
fn = infer,
|
150 |
-
cache_examples=True,
|
151 |
-
)
|
152 |
-
i2v_end_btn.click(inputs=[i2v_input_image, i2v_input_text, i2v_steps, i2v_cfg_scale, i2v_eta, i2v_motion, i2v_seed],
|
153 |
outputs=[i2v_output_video],
|
154 |
fn = infer
|
155 |
)
|
|
|
20 |
save_videos
|
21 |
)
|
22 |
|
23 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
24 |
+
|
25 |
def download_model():
|
26 |
REPO_ID = 'Doubiiu/DynamiCrafter_1024'
|
27 |
filename_list = ['model.ckpt']
|
|
|
33 |
hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='./checkpoints/dynamicrafter_1024_v1/', force_download=True)
|
34 |
|
35 |
|
36 |
+
def infer(secret_token, image, prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123):
|
37 |
+
if secret_token != SECRET_TOKEN:
|
38 |
+
raise gr.Error(
|
39 |
+
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
40 |
+
|
41 |
+
|
42 |
resolution = (576, 1024)
|
43 |
download_model()
|
44 |
ckpt_path='checkpoints/dynamicrafter_1024_v1/model.ckpt'
|
|
|
102 |
return video_path
|
103 |
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height: 576px}"""
|
106 |
|
107 |
with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
|
|
|
121 |
with gr.Tab(label='ImageAnimation_576x1024'):
|
122 |
with gr.Column():
|
123 |
with gr.Row():
|
124 |
+
secret_token = gr.Text(label='Secret Token', max_lines=1)
|
125 |
+
i2v_input_image = gr.Image(label="Input Image",elem_id="input_img")
|
126 |
+
i2v_input_text = gr.Text(label='Prompts')
|
127 |
+
i2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
|
128 |
+
i2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0, elem_id="i2v_eta")
|
129 |
+
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")
|
130 |
+
i2v_steps = gr.Slider(minimum=1, maximum=60, step=1, elem_id="i2v_steps", label="Sampling steps", value=50)
|
131 |
+
i2v_motion = gr.Slider(minimum=5, maximum=20, step=1, elem_id="i2v_motion", label="FPS", value=10)
|
132 |
+
i2v_end_btn = gr.Button("Generate")
|
133 |
+
|
134 |
+
with gr.Row():
|
135 |
+
i2v_output_video = gr.Video(label="Generated Video",elem_id="output_vid",autoplay=True,show_share_button=True)
|
136 |
+
|
137 |
+
i2v_end_btn.click(inputs=[secret_token, i2v_input_image, i2v_input_text, i2v_steps, i2v_cfg_scale, i2v_eta, i2v_motion, i2v_seed],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
outputs=[i2v_output_video],
|
139 |
fn = infer
|
140 |
)
|