File size: 433 Bytes
5d9832a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from diffusers import StableVideoDiffusionPipeline
import torch

# Model Load
pipe = StableVideoDiffusionPipeline.from_pretrained(
    "stabilityai/stable-video-diffusion-img2vid",
    torch_dtype=torch.float16
).to("cuda")

def generate_video(prompt):
    video = pipe(prompt, num_inference_steps=25).frames
    video_path = "generated_video.mp4"
    video[0].save(video_path)  # Save the first generated video
    return video_path