Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,26 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
iface = gr.Interface(
|
7 |
fn=generate_video,
|
8 |
-
inputs="
|
9 |
-
outputs=
|
10 |
-
title="AI Video Generator",
|
11 |
-
description="Enter a prompt to generate AI video (Coming Soon)."
|
12 |
)
|
13 |
|
14 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from diffusers import StableVideoDiffusionPipeline
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
# मॉडल लोड करें
|
7 |
+
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
8 |
+
"stabilityai/stable-video-diffusion-img2vid",
|
9 |
+
torch_dtype=torch.float16
|
10 |
+
).to("cpu") # Hugging Face Space में CPU ही चलेगा
|
11 |
|
12 |
+
def generate_video(image):
|
13 |
+
image = Image.open(image).convert("RGB") # इमेज लोड करें
|
14 |
+
video = pipe(image, num_inference_steps=25).frames
|
15 |
+
video_path = "generated_video.mp4"
|
16 |
+
video[0].save(video_path) # वीडियो सेव करें
|
17 |
+
return video_path
|
18 |
+
|
19 |
+
# Gradio Interface बनाएं
|
20 |
iface = gr.Interface(
|
21 |
fn=generate_video,
|
22 |
+
inputs=gr.Image(type="pil"),
|
23 |
+
outputs=gr.Video()
|
|
|
|
|
24 |
)
|
25 |
|
26 |
iface.launch()
|