Spaces:
Running
Running
File size: 8,174 Bytes
db8251f 7bd9a2d db8251f 3498257 db8251f 3498257 db8251f 3498257 db8251f 7bd9a2d db8251f 3498257 db8251f 3498257 db8251f 3498257 db8251f 3498257 db8251f 7bd9a2d db8251f 2b35920 db8251f 2b35920 db8251f 3498257 7bd9a2d 3498257 db8251f 2b35920 db8251f 2b35920 db8251f 2b35920 db8251f 2b35920 db8251f 2b35920 db8251f 6a1cccc db8251f 3498257 db8251f 7bd9a2d db8251f 7bd9a2d db8251f |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
import gradio as gr
import logging
import tempfile
import os
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def create_interface():
"""Create the Gradio interface"""
def generate_video_interface(prompt, model_id, num_frames, fps, num_inference_steps, guidance_scale, seed):
"""Interface function for video generation"""
if not prompt.strip():
return None, "Please enter a video description"
# For demo purposes, return a message instead of actual video generation
# This will work on Hugging Face Spaces without NumPy issues
return None, f"Demo mode: Would generate video for '{prompt}' using {model_id} with {num_frames} frames at {fps} FPS"
# Custom CSS for better styling
custom_css = """
.gradio-container {
max-width: 1200px !important;
margin: 0 auto !important;
}
.generate-btn {
background: linear-gradient(45deg, #667eea 0%, #764ba2 100%) !important;
border: none !important;
color: white !important;
font-weight: bold !important;
}
.status-box {
background-color: #f8f9fa !important;
border: 1px solid #dee2e6 !important;
}
"""
# Available models for demo
models = {
"damo-vilab/text-to-video-ms-1.7b": {
"name": "DAMO Text-to-Video MS-1.7B",
"description": "Fast and efficient text-to-video model",
"max_frames": 16,
"fps": 8,
"quality": "Good",
"speed": "Fast"
},
"cerspense/zeroscope_v2_XL": {
"name": "Zeroscope v2 XL",
"description": "High-quality text-to-video model",
"max_frames": 24,
"fps": 6,
"quality": "Excellent",
"speed": "Medium"
}
}
# Create interface
with gr.Blocks(title="AI Video Creator Pro", theme=gr.themes.Soft(), css=custom_css) as interface:
# Professional Header
with gr.Group():
gr.Markdown("""
# π¬ AI Video Creator Pro
### Transform Your Ideas Into Stunning Videos with AI-Powered Generation
""")
with gr.Row():
with gr.Column(scale=2):
# Main Input Section
with gr.Group():
gr.Markdown("## π― Video Generation")
prompt = gr.Textbox(
label="π Video Description",
placeholder="Describe the video you want to create... (e.g., 'A majestic dragon soaring through a mystical forest with glowing mushrooms')",
lines=3,
max_lines=5,
container=True
)
model_id = gr.Dropdown(
choices=list(models.keys()),
value=list(models.keys())[0],
label="π€ AI Model",
info="Choose the AI model for video generation",
container=True
)
with gr.Row():
num_frames = gr.Slider(
minimum=8,
maximum=32,
value=16,
step=1,
label="ποΈ Video Length (Frames)",
info="More frames = longer video"
)
fps = gr.Slider(
minimum=4,
maximum=12,
value=8,
step=1,
label="β‘ FPS",
info="Frames per second"
)
with gr.Row():
num_inference_steps = gr.Slider(
minimum=10,
maximum=50,
value=25,
step=1,
label="π¨ Quality Steps",
info="More steps = better quality but slower"
)
guidance_scale = gr.Slider(
minimum=1.0,
maximum=20.0,
value=7.5,
step=0.5,
label="π― Guidance Scale",
info="Higher values = more prompt adherence"
)
seed = gr.Number(
label="π² Seed (Optional)",
value=None,
info="Set for reproducible results",
container=True
)
# Generate Button
generate_btn = gr.Button("π Generate Professional Video", variant="primary", size="lg")
# Output Section
with gr.Group():
gr.Markdown("## πΊ Generated Video")
status_text = gr.Textbox(label="π Status", interactive=False)
video_output = gr.Video(label="π¬ Your Video")
with gr.Column(scale=1):
# Model Information
with gr.Group():
gr.Markdown("## π€ AI Model Details")
model_info = gr.JSON(label="Current Model Specifications")
# Examples
with gr.Group():
gr.Markdown("## π‘ Inspiration Examples")
gr.Markdown("""
**Try these example prompts:**
β’ A beautiful sunset over the ocean with waves crashing on the shore
β’ A cat playing with a ball of yarn in a cozy living room
β’ A futuristic city with flying cars and neon lights
β’ A butterfly emerging from a cocoon in a garden
β’ A rocket launching into space with fire and smoke
β’ A majestic dragon soaring through a mystical forest with glowing mushrooms
""")
# Features
with gr.Group():
gr.Markdown("## β¨ Features")
gr.Markdown("""
π¬ **Multiple AI Models**
- State-of-the-art video generation
- Quality vs speed options
π¨ **Advanced Controls**
- Quality settings
- Reproducible results
β‘ **Fast Processing**
- GPU acceleration
- Optimized pipelines
""")
# Event handlers
generate_btn.click(
fn=generate_video_interface,
inputs=[prompt, model_id, num_frames, fps, num_inference_steps, guidance_scale, seed],
outputs=[video_output, status_text]
)
# Update model info when model changes
def update_model_info(model_id):
info = models.get(model_id, {"error": "Model not found"})
if not isinstance(info, dict):
info = {"error": "Invalid model info"}
return info
model_id.change(
fn=update_model_info,
inputs=model_id,
outputs=model_info
)
# Load initial model info
interface.load(lambda: models[list(models.keys())[0]], outputs=model_info)
return interface
# Create and launch the interface
interface = create_interface()
interface.launch(
server_name="0.0.0.0",
server_port=7860,
share=True,
show_error=True
) |