Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import DiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
import imageio
|
| 5 |
+
|
| 6 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 7 |
+
"cerspense/zeroscope_v2_576w",
|
| 8 |
+
torch_dtype=torch.float32
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
pipe.enable_model_cpu_offload()
|
| 12 |
+
|
| 13 |
+
def generate(prompt):
|
| 14 |
+
|
| 15 |
+
result = pipe(
|
| 16 |
+
prompt,
|
| 17 |
+
num_inference_steps=15,
|
| 18 |
+
num_frames=16
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
frames = result.frames
|
| 22 |
+
|
| 23 |
+
output_path = "video.mp4"
|
| 24 |
+
|
| 25 |
+
imageio.mimsave(output_path, frames, fps=8)
|
| 26 |
+
|
| 27 |
+
return output_path
|
| 28 |
+
|
| 29 |
+
demo = gr.Interface(
|
| 30 |
+
fn=generate,
|
| 31 |
+
inputs=gr.Textbox(label="Prompt"),
|
| 32 |
+
outputs=gr.Video(),
|
| 33 |
+
title="Free AI Video Generator"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
demo.launch()
|