Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,13 +29,11 @@ import os
|
|
| 29 |
import gradio as gr
|
| 30 |
|
| 31 |
def turn_into_video(input_images, output_images, prompt, progress=gr.Progress(track_tqdm=True)):
|
| 32 |
-
"""Calls multimodalart/wan-2-2-first-last-frame space to generate a video."""
|
| 33 |
if not input_images or not output_images:
|
| 34 |
raise gr.Error("Please generate an output image first.")
|
| 35 |
|
| 36 |
progress(0.02, desc="Preparing images...")
|
| 37 |
|
| 38 |
-
# Safely extract PIL images from Gradio galleries
|
| 39 |
def extract_pil(img_entry):
|
| 40 |
if isinstance(img_entry, tuple) and isinstance(img_entry[0], Image.Image):
|
| 41 |
return img_entry[0]
|
|
@@ -56,21 +54,23 @@ def turn_into_video(input_images, output_images, prompt, progress=gr.Progress(tr
|
|
| 56 |
start_img.save(tmp_start.name)
|
| 57 |
end_img.save(tmp_end.name)
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
progress(0.35, desc="generating video...")
|
| 64 |
-
result = client.predict(
|
| 65 |
-
start_image_pil=start_img,
|
| 66 |
-
end_image_pil=end_img,
|
| 67 |
-
prompt=prompt or "smooth cinematic transition",
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
progress(0.95, desc="Finalizing...")
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
|
|
|
|
| 29 |
import gradio as gr
|
| 30 |
|
| 31 |
def turn_into_video(input_images, output_images, prompt, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 32 |
if not input_images or not output_images:
|
| 33 |
raise gr.Error("Please generate an output image first.")
|
| 34 |
|
| 35 |
progress(0.02, desc="Preparing images...")
|
| 36 |
|
|
|
|
| 37 |
def extract_pil(img_entry):
|
| 38 |
if isinstance(img_entry, tuple) and isinstance(img_entry[0], Image.Image):
|
| 39 |
return img_entry[0]
|
|
|
|
| 54 |
start_img.save(tmp_start.name)
|
| 55 |
end_img.save(tmp_end.name)
|
| 56 |
|
| 57 |
+
progress(0.20, desc="Connecting to Wan space...")
|
| 58 |
|
| 59 |
+
client = Client("multimodalart/wan-2-2-first-last-frame")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
progress(0.35, desc="Generating video...")
|
| 62 |
+
|
| 63 |
+
result = client.predict(
|
| 64 |
+
start_image_pil=handle_file(tmp_start.name),
|
| 65 |
+
end_image_pil=handle_file(tmp_end.name),
|
| 66 |
+
prompt=prompt or "smooth cinematic transition",
|
| 67 |
+
api_name="/generate_video"
|
| 68 |
+
)
|
| 69 |
|
| 70 |
progress(0.95, desc="Finalizing...")
|
| 71 |
+
|
| 72 |
+
return result[0]
|
| 73 |
+
|
| 74 |
|
| 75 |
|
| 76 |
|