Spaces:
Running
Running
| import gradio as gr | |
| from diffusers import StableVideoDiffusionPipeline | |
| import torch | |
| # Load AI Model | |
| model_id = "stabilityai/stable-video-diffusion-img2vid" | |
| pipe = StableVideoDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
| pipe.to("cuda") # GPU use karein for better speed | |
| # Define Function to Convert Image to Video | |
| def image_to_video(input_image): | |
| video_frames = pipe(input_image).frames | |
| return video_frames | |
| # Create Web Interface | |
| demo = gr.Interface( | |
| fn=image_to_video, | |
| inputs=gr.Image(type="pil"), | |
| outputs="video", | |
| title="Free AI Image to Video Generator", | |
| description="Upload an image and get an AI-generated video.", | |
| ) | |
| # Launch Website | |
| demo.launch() | |