Spaces:
Runtime error
Runtime error
On GPU
Browse files
app.py
CHANGED
|
@@ -180,7 +180,6 @@ def resize_and_crop_to_match(target_image, reference_image):
|
|
| 180 |
left, top = (new_width - ref_width) // 2, (new_height - ref_height) // 2
|
| 181 |
return resized.crop((left, top, left + ref_width, top + ref_height))
|
| 182 |
|
| 183 |
-
@spaces.GPU(duration=120)
|
| 184 |
def generate_video(
|
| 185 |
start_image_pil,
|
| 186 |
end_image_pil,
|
|
@@ -193,6 +192,34 @@ def generate_video(
|
|
| 193 |
seed=42,
|
| 194 |
randomize_seed=False,
|
| 195 |
progress=gr.Progress(track_tqdm=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
):
|
| 197 |
"""
|
| 198 |
Generates a video by interpolating between a start and end image, guided by a text prompt,
|
|
@@ -302,7 +329,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as app:
|
|
| 302 |
generate_button = gr.Button("Generate Video", variant="primary")
|
| 303 |
|
| 304 |
with gr.Column():
|
| 305 |
-
output_video = gr.Video(label="Generated Video", autoplay=True)
|
| 306 |
|
| 307 |
# Main video generation button
|
| 308 |
ui_inputs = [
|
|
@@ -378,7 +405,9 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as app:
|
|
| 378 |
outputs=[]
|
| 379 |
)
|
| 380 |
|
| 381 |
-
gr.
|
|
|
|
|
|
|
| 382 |
examples = [
|
| 383 |
["poli_tower.png", "tower_takes_off.png", "the man turns around"],
|
| 384 |
["ugly_sonic.jpeg", "squatting_sonic.png", "the character dodges the missiles"],
|
|
@@ -390,6 +419,18 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as app:
|
|
| 390 |
run_on_click = True,
|
| 391 |
cache_examples = True,
|
| 392 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
if __name__ == "__main__":
|
| 395 |
app.launch(share=True)
|
|
|
|
| 180 |
left, top = (new_width - ref_width) // 2, (new_height - ref_height) // 2
|
| 181 |
return resized.crop((left, top, left + ref_width, top + ref_height))
|
| 182 |
|
|
|
|
| 183 |
def generate_video(
|
| 184 |
start_image_pil,
|
| 185 |
end_image_pil,
|
|
|
|
| 192 |
seed=42,
|
| 193 |
randomize_seed=False,
|
| 194 |
progress=gr.Progress(track_tqdm=True)
|
| 195 |
+
):
|
| 196 |
+
return generate_video(
|
| 197 |
+
start_image_pil,
|
| 198 |
+
end_image_pil,
|
| 199 |
+
prompt,
|
| 200 |
+
negative_prompt=default_negative_prompt,
|
| 201 |
+
duration_seconds,
|
| 202 |
+
steps,
|
| 203 |
+
guidance_scale,
|
| 204 |
+
guidance_scale_2,
|
| 205 |
+
seed,
|
| 206 |
+
randomize_seed,
|
| 207 |
+
progress
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
@spaces.GPU(duration=120)
|
| 211 |
+
def generate_video_on_gpu(
|
| 212 |
+
start_image_pil,
|
| 213 |
+
end_image_pil,
|
| 214 |
+
prompt,
|
| 215 |
+
negative_prompt=default_negative_prompt,
|
| 216 |
+
duration_seconds=2.1,
|
| 217 |
+
steps=8,
|
| 218 |
+
guidance_scale=1,
|
| 219 |
+
guidance_scale_2=1,
|
| 220 |
+
seed=42,
|
| 221 |
+
randomize_seed=False,
|
| 222 |
+
progress=gr.Progress(track_tqdm=True)
|
| 223 |
):
|
| 224 |
"""
|
| 225 |
Generates a video by interpolating between a start and end image, guided by a text prompt,
|
|
|
|
| 329 |
generate_button = gr.Button("Generate Video", variant="primary")
|
| 330 |
|
| 331 |
with gr.Column():
|
| 332 |
+
output_video = gr.Video(label="Generated Video", autoplay = True, loop = True)
|
| 333 |
|
| 334 |
# Main video generation button
|
| 335 |
ui_inputs = [
|
|
|
|
| 405 |
outputs=[]
|
| 406 |
)
|
| 407 |
|
| 408 |
+
with gr.Row(elem_id="image_examples", visible=False):
|
| 409 |
+
gr.Examples(
|
| 410 |
+
label = "Examples from images",
|
| 411 |
examples = [
|
| 412 |
["poli_tower.png", "tower_takes_off.png", "the man turns around"],
|
| 413 |
["ugly_sonic.jpeg", "squatting_sonic.png", "the character dodges the missiles"],
|
|
|
|
| 419 |
run_on_click = True,
|
| 420 |
cache_examples = True,
|
| 421 |
)
|
| 422 |
+
|
| 423 |
+
gr.Examples(
|
| 424 |
+
examples = [
|
| 425 |
+
["poli_tower.png", "tower_takes_off.png", "the man turns around"],
|
| 426 |
+
["ugly_sonic.jpeg", "squatting_sonic.png", "the character dodges the missiles"],
|
| 427 |
+
["capyabara_zoomed.png", "capyabara.webp", "a dramatic dolly zoom"],
|
| 428 |
+
],
|
| 429 |
+
inputs = [start_image, end_image, prompt],
|
| 430 |
+
outputs = ui_outputs,
|
| 431 |
+
fn = generate_video,
|
| 432 |
+
cache_examples = False,
|
| 433 |
+
)
|
| 434 |
|
| 435 |
if __name__ == "__main__":
|
| 436 |
app.launch(share=True)
|