Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
+
from diffusers.utils import export_to_video
|
5 |
+
|
6 |
+
# Charger le modèle de diffusion
|
7 |
+
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
|
8 |
+
pipe = pipe.to("cuda")
|
9 |
+
|
10 |
+
# Fonction pour générer la vidéo
|
11 |
+
def generate_video(prompt):
|
12 |
+
video_frames = pipe(prompt).frames[0]
|
13 |
+
video_path = export_to_video(video_frames)
|
14 |
+
return video_path
|
15 |
+
|
16 |
+
# Interface Gradio
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=generate_video,
|
19 |
+
inputs=gr.Textbox(label="Enter Prompt", placeholder="e.g., Spiderman is surfing"),
|
20 |
+
outputs=gr.Video(label="Generated Video"),
|
21 |
+
title="Text-to-Video Generation",
|
22 |
+
description="Generate a video based on a textual prompt."
|
23 |
+
)
|
24 |
+
|
25 |
+
# Lancer l'interface
|
26 |
+
iface.launch()
|