File size: 940 Bytes
9bdf0ae
00afe0a
9bdf0ae
 
 
 
00afe0a
9bdf0ae
 
 
00afe0a
 
9bdf0ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00afe0a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from transformers import pipeline
import torch

# Load the model and pipeline
model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
pipe = pipeline("text-to-video-generation", model=model_id, torch_dtype=torch.float16, device="cuda")

def generate_video(image, prompt):
    # Generate the video from the image and prompt
    video = pipe(prompt, image, num_inference_steps=50, guidance_scale=7.5)
    return video

# Create the Gradio interface
iface = gr.Interface(
    fn=generate_video,
    inputs=[
        gr.Image(type="pil", label="Input Image"),
        gr.Textbox(lines=2, placeholder="Enter a prompt...", label="Prompt")
    ],
    outputs=gr.Video(label="Generated Video"),
    title="Stable Video Diffusion img2vid-xt",
    description="Generate a video from an image using the stabilityai/stable-video-diffusion-img2vid-xt model."
)

# Launch the interface
if __name__ == "__main__":
    iface.launch()