Spaces:
Runtime error
Runtime error
Download app.py from RustyPan90/vidmakerai: direct link, hf CLI and curl.
- Browser
- Download file 929 Bytes
-
https://huggingface.co/spaces/RustyPan90/vidmakerai/resolve/main/app.py
- Command line
-
hf download hf://spaces/RustyPan90/vidmakerai/app.py
-
curl -L -o app.py https://huggingface.co/spaces/RustyPan90/vidmakerai/resolve/main/app.py
929 Bytes
| 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() |