Spaces:
Running
on
Zero
Running
on
Zero
Kvikontent
commited on
Commit
•
c472b15
1
Parent(s):
52a07d6
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
4 |
+
from diffusers.utils import export_to_video
|
5 |
+
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
|
7 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
8 |
+
pipe.enable_model_cpu_offload()
|
9 |
+
|
10 |
+
@spaces.GPU(duration=250)
|
11 |
+
def generate(prompt, num_inference_steps=25):
|
12 |
+
video_frames = pipe(prompt, num_inference_steps).frames
|
13 |
+
video_path = export_to_video(video_frames)
|
14 |
+
return video_path
|
15 |
+
|
16 |
+
prompt = gr.Textbox("Enter prompt to generate a video")
|
17 |
+
num_inference_steps = gr.Slider(10, 50, value=25)
|
18 |
+
|
19 |
+
interface = gr.Interface(
|
20 |
+
generate,
|
21 |
+
inputs=[prompt, num_inference_steps],
|
22 |
+
examples=[["Astronaut riding a horse", 25], ["Darth vader surfing in waves", 20]]
|
23 |
+
outputs="video",
|
24 |
+
cache_examples=False,
|
25 |
+
theme="soft"
|
26 |
+
)
|