Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import spaces
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from diffusers import DiffusionPipeline
|
@@ -29,9 +28,13 @@ pipe.transformer.compile()
|
|
29 |
pipe.to("cuda")
|
30 |
|
31 |
# Gradio inference function
|
32 |
-
|
33 |
-
def generate_video(prompt, num_frames, seed):
|
34 |
generator = torch.manual_seed(seed) if seed else None
|
|
|
|
|
|
|
|
|
|
|
35 |
video_frames = pipe(
|
36 |
prompt=prompt,
|
37 |
num_frames=num_frames,
|
@@ -41,22 +44,21 @@ def generate_video(prompt, num_frames, seed):
|
|
41 |
# Save as GIF for Gradio preview
|
42 |
import imageio
|
43 |
out_path = "output.gif"
|
44 |
-
imageio.mimsave(out_path, video_frames, fps=
|
45 |
return out_path
|
46 |
|
47 |
# Build Gradio UI
|
48 |
with gr.Blocks() as demo:
|
49 |
-
gr.Markdown("## 🚀 Wan2.1 T2V - Text to Video Generator")
|
50 |
with gr.Row():
|
51 |
with gr.Column():
|
52 |
prompt = gr.Textbox(label="Prompt", lines=3, value="A futuristic cityscape with flying cars and neon lights.")
|
53 |
-
num_frames = gr.Slider(8, 64, value=16, step=1, label="Frames")
|
54 |
seed = gr.Number(value=42, label="Seed (optional)")
|
55 |
run_btn = gr.Button("Generate Video")
|
56 |
with gr.Column():
|
57 |
output_video = gr.Video(label="Generated Video")
|
58 |
|
59 |
-
run_btn.click(fn=generate_video, inputs=[prompt,
|
60 |
|
61 |
# Launch demo
|
62 |
demo.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from diffusers import DiffusionPipeline
|
|
|
28 |
pipe.to("cuda")
|
29 |
|
30 |
# Gradio inference function
|
31 |
+
def generate_video(prompt, seed):
|
|
|
32 |
generator = torch.manual_seed(seed) if seed else None
|
33 |
+
|
34 |
+
# Force ~2 second video (e.g., fps=8, frames=16)
|
35 |
+
num_frames = 16
|
36 |
+
fps = 8
|
37 |
+
|
38 |
video_frames = pipe(
|
39 |
prompt=prompt,
|
40 |
num_frames=num_frames,
|
|
|
44 |
# Save as GIF for Gradio preview
|
45 |
import imageio
|
46 |
out_path = "output.gif"
|
47 |
+
imageio.mimsave(out_path, video_frames, fps=fps)
|
48 |
return out_path
|
49 |
|
50 |
# Build Gradio UI
|
51 |
with gr.Blocks() as demo:
|
52 |
+
gr.Markdown("## 🚀 Wan2.1 T2V - Text to Video Generator (2 sec duration)")
|
53 |
with gr.Row():
|
54 |
with gr.Column():
|
55 |
prompt = gr.Textbox(label="Prompt", lines=3, value="A futuristic cityscape with flying cars and neon lights.")
|
|
|
56 |
seed = gr.Number(value=42, label="Seed (optional)")
|
57 |
run_btn = gr.Button("Generate Video")
|
58 |
with gr.Column():
|
59 |
output_video = gr.Video(label="Generated Video")
|
60 |
|
61 |
+
run_btn.click(fn=generate_video, inputs=[prompt, seed], outputs=output_video)
|
62 |
|
63 |
# Launch demo
|
64 |
demo.launch()
|