sohaihanjra commited on
Commit
fb18f06
·
verified ·
1 Parent(s): 2becad2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableVideoDiffusionPipeline
3
+ import torch
4
+
5
+ # Model Load
6
+ model_id = "stabilityai/stable-video-diffusion-img2vid"
7
+ pipe = StableVideoDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
8
+
9
+ # Function to Generate Video
10
+ def generate_video(prompt):
11
+ video = pipe(prompt, num_inference_steps=30).videos
12
+ video_path = "generated_video.mp4"
13
+ video[0].save(video_path)
14
+ return video_path
15
+
16
+ # Gradio Interface
17
+ iface = gr.Interface(fn=generate_video, inputs="text", outputs="video")
18
+ iface.launch()