Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import torch | |
| from diffusers import WanVideoPipeline | |
| from huggingface_hub import login | |
| # لو الموديل خاص أو محتاج صلاحية | |
| # login("YOUR_HF_TOKEN") | |
| # تحميل الموديل (تأكد إن المساحة المخصصة في الـ Space فيها GPU) | |
| pipe = WanVideoPipeline.from_pretrained( | |
| "Wan-Video/Wan2.1-T2V-14B", | |
| torch_dtype=torch.float16, | |
| device_map="auto" | |
| ) | |
| def generate_video(prompt): | |
| video = pipe( | |
| prompt, | |
| num_frames=81, | |
| guidance_scale=5.0, | |
| num_inference_steps=50 | |
| ).frames[0] | |
| return video | |
| # تصميم الواجهة باستخدام Gradio Blocks | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# 🎥 Wan 2.1 Video Generator") | |
| with gr.Row(): | |
| with gr.Column(): | |
| prompt = gr.Textbox(label="اكتب وصف الفيديو هنا", placeholder="مثال: A cat dancing in space...") | |
| btn = gr.Button("بدء التوليد", variant="primary") | |
| with gr.Column(): | |
| output = gr.Video(label="الفيديو الناتج") | |
| btn.click(fn=generate_video, inputs=prompt, outputs=output) | |
| demo.launch() |