Spaces:
Runtime error

File size: 929 Bytes
d492be9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import torch
import gradio as gr
from diffusers import DiffusionPipeline
from diffusers.utils import export_to_video

# Load model
pipe = DiffusionPipeline.from_pretrained(
    "damo-vilab/text-to-video-ms-1.7b",
    torch_dtype=torch.float16,
    variant="fp16"
)

pipe.enable_model_cpu_offload()

# Video generation function

def generate_video(prompt):
    video_frames = pipe(
        prompt,
        num_inference_steps=25,
        num_frames=24
    ).frames

    output_path = "generated_video.mp4"

    export_to_video(video_frames, output_path)

    return output_path

# Gradio UI
app = gr.Interface(
    fn=generate_video,
    inputs=gr.Textbox(
        label="Video Prompt",
        placeholder="A futuristic city at night with neon lights"
    ),
    outputs=gr.Video(label="Generated Video"),
    title="AI Video Generator",
    description="Generate AI videos using Hugging Face Diffusers"
)

app.launch()