Runwaymlfaiz / app.py
Faizbulbul's picture
Update app.py
d88a4e9 verified
raw
history blame
726 Bytes
from diffusers import StableVideoDiffusionPipeline
import torch
from PIL import Image
# Model Load
pipe = StableVideoDiffusionPipeline.from_pretrained(
"stabilityai/stable-video-diffusion-img2vid",
torch_dtype=torch.float16
).to("cuda")
def generate_video(image_path, prompt):
image = Image.open(image_path).convert("RGB") # Load image properly
video = pipe(prompt=prompt, image=image, num_inference_steps=25).frames
video_path = "generated_video.mp4"
video[0].save(video_path) # Save the first generated video
return video_path
# Example Usage
video_file = generate_video("sample_image.jpg", "A beautiful mountain landscape with a sunset")
print(f"Video generated and saved at: {video_file}")