Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableVideoDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Load AI Model
|
| 6 |
+
model_id = "stabilityai/stable-video-diffusion-img2vid"
|
| 7 |
+
pipe = StableVideoDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 8 |
+
pipe.to("cuda") # GPU use karein for better speed
|
| 9 |
+
|
| 10 |
+
# Define Function to Convert Image to Video
|
| 11 |
+
def image_to_video(input_image):
|
| 12 |
+
video_frames = pipe(input_image).frames
|
| 13 |
+
return video_frames
|
| 14 |
+
|
| 15 |
+
# Create Web Interface
|
| 16 |
+
demo = gr.Interface(
|
| 17 |
+
fn=image_to_video,
|
| 18 |
+
inputs=gr.Image(type="pil"),
|
| 19 |
+
outputs="video",
|
| 20 |
+
title="Free AI Image to Video Generator",
|
| 21 |
+
description="Upload an image and get an AI-generated video.",
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Launch Website
|
| 25 |
+
demo.launch()
|