Peeble commited on
Commit
d7da1d6
·
verified ·
1 Parent(s): ed02090

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -54
app.py DELETED
@@ -1,54 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- from diffusers import StableVideoDiffusionPipeline
4
- from PIL import Image
5
- import imageio
6
- import os
7
- import uuid
8
-
9
- # Load model (automatically uses GPU if available)
10
- device = "cuda" if torch.cuda.is_available() else "cpu"
11
-
12
- pipe = StableVideoDiffusionPipeline.from_pretrained(
13
- "stabilityai/stable-video-diffusion-img2vid-xt",
14
- torch_dtype=torch.float16 if device == "cuda" else torch.float32
15
- )
16
-
17
- pipe = pipe.to(device)
18
-
19
- def generate_video(image, fps):
20
- if image is None:
21
- return None
22
-
23
- image = image.convert("RGB")
24
-
25
- # Generate frames
26
- frames = pipe(image, num_frames=25).frames[0]
27
-
28
- # Save video
29
- filename = f"output_{uuid.uuid4().hex}.mp4"
30
- imageio.mimsave(filename, frames, fps=fps)
31
-
32
- return filename
33
-
34
- # UI
35
- with gr.Blocks() as demo:
36
- gr.Markdown("# 🎬 StuffMotion AI (Image → Video)")
37
- gr.Markdown("Upload an image and generate AI motion video")
38
-
39
- with gr.Row():
40
- image_input = gr.Image(type="pil", label="Input Image")
41
-
42
- fps = gr.Slider(5, 30, value=12, step=1, label="FPS")
43
-
44
- generate_btn = gr.Button("Generate Video")
45
-
46
- video_output = gr.Video()
47
-
48
- generate_btn.click(
49
- fn=generate_video,
50
- inputs=[image_input, fps],
51
- outputs=video_output
52
- )
53
-
54
- demo.launch()