Spaces:
Running
Running
File size: 836 Bytes
39e9646 fb18f06 39e9646 3771b0e fb18f06 8ae300f fb18f06 8ae300f 39e9646 fb18f06 39e9646 |
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 |
import os
import gradio as gr
from diffusers import StableVideoDiffusionPipeline
import torch
# Ensure dependencies are installed
os.system("pip install -r requirements.txt")
# Model Load (CPU Compatible)
model_id = "stabilityai/stable-video-diffusion-img2vid"
pipe = StableVideoDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32) # Float32 use karo
pipe.to("cpu") # Ensure model runs on CPU
# Function to Generate Video
def generate_video(prompt):
video = pipe(prompt, num_inference_steps=30).videos
video_path = "generated_video.mp4"
video[0].save(video_path)
return video_path
# Gradio Interface
iface = gr.Interface(fn=generate_video, inputs="text", outputs="video")
# Launch Gradio Server on Hugging Face Space
iface.launch(server_name="0.0.0.0", server_port=int(os.getenv("PORT", 7860)))
|