Downloads · 30 days
0
Hulaluoooo/TEXTTOLIVEVIDEO
TEXTTOLIVEVIDEO is a machine learning model from Hulaluoooo. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import gradio as gr from diffusers import DiffusionPipeline import torch from moviepy.editor import ImageSequenceClip import os
Downloads · 30 days
0
Access
Public
Updated Feb 24, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 53%
From the Hugging Face model README
import gradio as gr from diffusers import DiffusionPipeline import torch from moviepy.editor import ImageSequenceClip import os
print("Loading the text-to-video model...") model_id = "damo-vilab/text-to-video-ms-1.7b" pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) if torch.cuda.is_available(): pipe = pipe.to("cuda") print("Model loaded successfully!")
def generate_video(prompt): print(f"Generating video for prompt: {prompt}") try: video_output = pipe(prompt, num_inference_steps=50, height=256, width=256, num_frames=16) video_frames = video_output.frames[0] video_path = "output.mp4" clip = ImageSequenceClip(video_frames, fps=24) clip.write_videofile(video_path, codec="libx264", audio=False) return video_path except Exception as e: return f"Error: {str(e)}"
interface = gr.Interface( fn=generate_video, inputs=gr.Textbox(label="Enter your text prompt", placeholder="e.g., A bird flying over a lake"), outputs=gr.Video(label="Generated Video"), title="Text-to-Video Generator", description="Enter a text prompt to generate a short video using a free Hugging Face model." )
interface.launch()