|
|
import gradio as gr |
|
|
from diffusers import StableVideoDiffusionPipeline |
|
|
import torch |
|
|
|
|
|
|
|
|
pipe = StableVideoDiffusionPipeline.from_pretrained( |
|
|
"stabilityai/stable-video-diffusion-img2vid", |
|
|
torch_dtype=torch.float32 |
|
|
) |
|
|
|
|
|
|
|
|
def generate_video(image, prompt): |
|
|
video = pipe(image, prompt=prompt).frames |
|
|
return video |
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=generate_video, |
|
|
inputs=[ |
|
|
gr.Image(label="Upload an image"), |
|
|
gr.Textbox(label="Enter Animation Prompt", placeholder="e.g. A cat running in a forest"), |
|
|
], |
|
|
outputs=gr.Video(label="Generated Video"), |
|
|
title="AI Video Generator", |
|
|
description="Upload an image and enter a prompt to generate an AI video." |
|
|
) |
|
|
|
|
|
iface.launch() |