Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,25 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from PIL import Image
|
| 3 |
import gradio as gr
|
| 4 |
from diffusers import StableVideoDiffusionPipeline
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
"stabilityai/stable-video-diffusion-img2vid",
|
| 9 |
-
torch_dtype=torch.float32
|
| 10 |
-
)
|
| 11 |
|
|
|
|
| 12 |
def generate_video(image):
|
| 13 |
-
|
| 14 |
-
video
|
| 15 |
-
video_path = "generated_video.mp4"
|
| 16 |
-
video[0].save(video_path) # ✅ Video को Save करें
|
| 17 |
-
return video_path
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
fn=generate_video,
|
| 22 |
-
inputs=gr.Image(
|
| 23 |
-
outputs=gr.Video()
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
-
|
| 27 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import StableVideoDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
# Model Load करो (CPU के लिए)
|
| 6 |
+
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
| 7 |
"stabilityai/stable-video-diffusion-img2vid",
|
| 8 |
+
torch_dtype=torch.float32
|
| 9 |
+
)
|
| 10 |
|
| 11 |
+
# Function जो Image से Video Generate करेगा
|
| 12 |
def generate_video(image):
|
| 13 |
+
video = pipe(image).frames
|
| 14 |
+
return video
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Gradio Interface बनाओ
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
fn=generate_video,
|
| 19 |
+
inputs=gr.Image(label="Upload an image"),
|
| 20 |
+
outputs=gr.Video(label="Generated Video"),
|
| 21 |
+
title="AI Video Generator",
|
| 22 |
+
description="Upload an image to generate an AI video."
|
| 23 |
)
|
| 24 |
|
| 25 |
+
iface.launch()
|
|
|