indrasn0wal commited on
Commit
8690be7
·
verified ·
1 Parent(s): bbce297

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
3
+ from diffusers.utils import export_to_video
4
+ import gradio as gr
5
+
6
+ # Load the DiffusionPipeline
7
+ pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
8
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
9
+ pipe.enable_model_cpu_offload()
10
+
11
+ def generate_video(prompt):
12
+ video_frames = pipe(prompt, num_inference_steps=25).frames
13
+ video_path = export_to_video(video_frames[0])
14
+ return video_path
15
+
16
+ # Create the Gradio Interface
17
+ interface = gr.Interface(
18
+ fn=generate_video,
19
+ inputs=gr.Textbox(label="Enter your prompt"),
20
+ outputs=gr.Video(label="Generated Video"),
21
+ title="Text-to-Video Generator",
22
+ description="Enter a prompt to generate a video using diffusion models."
23
+ )
24
+
25
+ # Launch the Gradio app
26
+ interface.launch()