Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -234,22 +234,24 @@ def generate_video_with_audio(
|
|
234 |
print(f"Error in video generation: {e}")
|
235 |
return None, current_seed
|
236 |
|
237 |
-
# Example generation function
|
238 |
-
def
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
)
|
249 |
-
return video_path, \
|
250 |
-
DEFAULT_H_SLIDER_VALUE, DEFAULT_W_SLIDER_VALUE, \
|
251 |
-
DEFAULT_DURATION_SECONDS, DEFAULT_STEPS, seed, \
|
252 |
-
True, DEFAULT_AUDIO_NEGATIVE_PROMPT, 25, 4.5
|
253 |
|
254 |
# Examples with audio descriptions
|
255 |
examples = [
|
@@ -258,13 +260,22 @@ examples = [
|
|
258 |
["Golden-hour countryside road winding through rolling wheat fields. A man and woman ride a vintage café-racer motorcycle, hair and scarf fluttering in the warm breeze. Drone chase shot reveals endless patchwork farmland; low slider along rear wheel captures dust trail. Sun-flare back-lights the riders, lens blooms on highlights. Soft acoustic rock underscore; engine rumble mixed at –8 dB. Warm pastel color grade, gentle film-grain for nostalgic vibe.", DEFAULT_NAG_NEGATIVE_PROMPT, 11],
|
259 |
]
|
260 |
|
261 |
-
# CSS styling - Fixed
|
262 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
.container {
|
264 |
-
max-width:
|
265 |
-
margin: auto;
|
266 |
padding: 20px;
|
267 |
}
|
|
|
|
|
268 |
.main-title {
|
269 |
text-align: center;
|
270 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
@@ -274,11 +285,14 @@ css = """
|
|
274 |
font-weight: bold;
|
275 |
margin-bottom: 10px;
|
276 |
}
|
|
|
277 |
.subtitle {
|
278 |
text-align: center;
|
279 |
color: #6b7280;
|
280 |
margin-bottom: 30px;
|
281 |
}
|
|
|
|
|
282 |
.prompt-container {
|
283 |
background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
|
284 |
border-radius: 15px;
|
@@ -286,6 +300,7 @@ css = """
|
|
286 |
margin-bottom: 20px;
|
287 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
288 |
}
|
|
|
289 |
.generate-btn {
|
290 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
291 |
color: white;
|
@@ -299,23 +314,40 @@ css = """
|
|
299 |
width: 100%;
|
300 |
margin-top: 20px;
|
301 |
}
|
|
|
302 |
.generate-btn:hover {
|
303 |
transform: translateY(-2px);
|
304 |
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
|
305 |
}
|
|
|
|
|
306 |
.video-output {
|
307 |
border-radius: 15px;
|
308 |
overflow: hidden;
|
309 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
310 |
background: #1a1a1a;
|
311 |
padding: 10px;
|
|
|
|
|
|
|
312 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
.settings-panel {
|
314 |
background: #f9fafb;
|
315 |
border-radius: 15px;
|
316 |
padding: 20px;
|
317 |
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
318 |
}
|
|
|
319 |
.slider-container {
|
320 |
background: white;
|
321 |
padding: 15px;
|
@@ -323,13 +355,7 @@ css = """
|
|
323 |
margin-bottom: 15px;
|
324 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
325 |
}
|
326 |
-
|
327 |
-
background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
|
328 |
-
border-radius: 10px;
|
329 |
-
padding: 15px;
|
330 |
-
margin: 10px 0;
|
331 |
-
border-left: 4px solid #667eea;
|
332 |
-
}
|
333 |
.audio-settings {
|
334 |
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
335 |
border-radius: 10px;
|
@@ -337,6 +363,17 @@ css = """
|
|
337 |
margin-top: 10px;
|
338 |
border-left: 4px solid #f59e0b;
|
339 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
"""
|
341 |
|
342 |
# Gradio interface - Fixed structure
|
@@ -349,7 +386,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
349 |
""")
|
350 |
|
351 |
gr.HTML("""
|
352 |
-
<div class='container' style='display:flex; justify-content:center; gap:12px;'>
|
353 |
<a href="https://huggingface.co/spaces/openfree/Best-AI" target="_blank">
|
354 |
<img src="https://img.shields.io/static/v1?label=OpenFree&message=BEST%20AI%20Services&color=%230000ff&labelColor=%23000080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="OpenFree badge">
|
355 |
</a>
|
@@ -360,8 +397,8 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
360 |
</div>
|
361 |
""")
|
362 |
|
363 |
-
with gr.Row():
|
364 |
-
with gr.Column(scale=
|
365 |
with gr.Group(elem_classes="prompt-container"):
|
366 |
prompt = gr.Textbox(
|
367 |
label="✨ Video Prompt (also used for audio generation)",
|
@@ -486,12 +523,13 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
486 |
elem_classes="generate-btn"
|
487 |
)
|
488 |
|
489 |
-
with gr.Column(scale=
|
490 |
video_output = gr.Video(
|
491 |
label="Generated Video with Audio",
|
492 |
autoplay=True,
|
493 |
interactive=False,
|
494 |
-
elem_classes="video-output"
|
|
|
495 |
)
|
496 |
|
497 |
gr.HTML("""
|
@@ -501,18 +539,15 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
501 |
</div>
|
502 |
""")
|
503 |
|
504 |
-
|
|
|
|
|
|
|
505 |
gr.Examples(
|
506 |
examples=examples,
|
507 |
-
fn=generate_with_example,
|
508 |
inputs=[prompt, nag_negative_prompt, nag_scale],
|
509 |
-
outputs=
|
510 |
-
|
511 |
-
height_input, width_input, duration_seconds_input,
|
512 |
-
steps_slider, seed_input,
|
513 |
-
enable_audio, audio_negative_prompt, audio_steps, audio_cfg_strength
|
514 |
-
],
|
515 |
-
cache_examples=False # Changed from "lazy" to False
|
516 |
)
|
517 |
|
518 |
# Connect UI elements
|
|
|
234 |
print(f"Error in video generation: {e}")
|
235 |
return None, current_seed
|
236 |
|
237 |
+
# Example generation function - simplified
|
238 |
+
def set_example(prompt, nag_negative_prompt, nag_scale):
|
239 |
+
"""Set example values in the UI without triggering generation"""
|
240 |
+
return (
|
241 |
+
prompt,
|
242 |
+
nag_negative_prompt,
|
243 |
+
nag_scale,
|
244 |
+
DEFAULT_H_SLIDER_VALUE,
|
245 |
+
DEFAULT_W_SLIDER_VALUE,
|
246 |
+
DEFAULT_DURATION_SECONDS,
|
247 |
+
DEFAULT_STEPS,
|
248 |
+
DEFAULT_SEED,
|
249 |
+
True, # randomize_seed
|
250 |
+
True, # enable_audio
|
251 |
+
DEFAULT_AUDIO_NEGATIVE_PROMPT,
|
252 |
+
25, # audio_steps
|
253 |
+
4.5 # audio_cfg_strength
|
254 |
)
|
|
|
|
|
|
|
|
|
255 |
|
256 |
# Examples with audio descriptions
|
257 |
examples = [
|
|
|
260 |
["Golden-hour countryside road winding through rolling wheat fields. A man and woman ride a vintage café-racer motorcycle, hair and scarf fluttering in the warm breeze. Drone chase shot reveals endless patchwork farmland; low slider along rear wheel captures dust trail. Sun-flare back-lights the riders, lens blooms on highlights. Soft acoustic rock underscore; engine rumble mixed at –8 dB. Warm pastel color grade, gentle film-grain for nostalgic vibe.", DEFAULT_NAG_NEGATIVE_PROMPT, 11],
|
261 |
]
|
262 |
|
263 |
+
# CSS styling - Fixed for better layout
|
264 |
css = """
|
265 |
+
/* Global container settings */
|
266 |
+
.gradio-container {
|
267 |
+
max-width: 100% !important;
|
268 |
+
padding: 20px !important;
|
269 |
+
}
|
270 |
+
|
271 |
+
/* Main container */
|
272 |
.container {
|
273 |
+
max-width: 1600px;
|
274 |
+
margin: 0 auto;
|
275 |
padding: 20px;
|
276 |
}
|
277 |
+
|
278 |
+
/* Title styling */
|
279 |
.main-title {
|
280 |
text-align: center;
|
281 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
285 |
font-weight: bold;
|
286 |
margin-bottom: 10px;
|
287 |
}
|
288 |
+
|
289 |
.subtitle {
|
290 |
text-align: center;
|
291 |
color: #6b7280;
|
292 |
margin-bottom: 30px;
|
293 |
}
|
294 |
+
|
295 |
+
/* Left column styling */
|
296 |
.prompt-container {
|
297 |
background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
|
298 |
border-radius: 15px;
|
|
|
300 |
margin-bottom: 20px;
|
301 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
302 |
}
|
303 |
+
|
304 |
.generate-btn {
|
305 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
306 |
color: white;
|
|
|
314 |
width: 100%;
|
315 |
margin-top: 20px;
|
316 |
}
|
317 |
+
|
318 |
.generate-btn:hover {
|
319 |
transform: translateY(-2px);
|
320 |
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
|
321 |
}
|
322 |
+
|
323 |
+
/* Right column - video output */
|
324 |
.video-output {
|
325 |
border-radius: 15px;
|
326 |
overflow: hidden;
|
327 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
328 |
background: #1a1a1a;
|
329 |
padding: 10px;
|
330 |
+
width: 100% !important;
|
331 |
+
height: auto !important;
|
332 |
+
min-height: 400px;
|
333 |
}
|
334 |
+
|
335 |
+
/* Ensure video container is responsive */
|
336 |
+
.video-output video {
|
337 |
+
width: 100% !important;
|
338 |
+
height: auto !important;
|
339 |
+
max-height: 600px;
|
340 |
+
object-fit: contain;
|
341 |
+
}
|
342 |
+
|
343 |
+
/* Settings panels */
|
344 |
.settings-panel {
|
345 |
background: #f9fafb;
|
346 |
border-radius: 15px;
|
347 |
padding: 20px;
|
348 |
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
349 |
}
|
350 |
+
|
351 |
.slider-container {
|
352 |
background: white;
|
353 |
padding: 15px;
|
|
|
355 |
margin-bottom: 15px;
|
356 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
357 |
}
|
358 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
.audio-settings {
|
360 |
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
361 |
border-radius: 10px;
|
|
|
363 |
margin-top: 10px;
|
364 |
border-left: 4px solid #f59e0b;
|
365 |
}
|
366 |
+
|
367 |
+
/* Responsive grid layout */
|
368 |
+
@media (max-width: 768px) {
|
369 |
+
.gradio-container {
|
370 |
+
padding: 10px !important;
|
371 |
+
}
|
372 |
+
|
373 |
+
.main-title {
|
374 |
+
font-size: 1.8em;
|
375 |
+
}
|
376 |
+
}
|
377 |
"""
|
378 |
|
379 |
# Gradio interface - Fixed structure
|
|
|
386 |
""")
|
387 |
|
388 |
gr.HTML("""
|
389 |
+
<div class='container' style='display:flex; justify-content:center; gap:12px; margin-bottom: 20px;'>
|
390 |
<a href="https://huggingface.co/spaces/openfree/Best-AI" target="_blank">
|
391 |
<img src="https://img.shields.io/static/v1?label=OpenFree&message=BEST%20AI%20Services&color=%230000ff&labelColor=%23000080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="OpenFree badge">
|
392 |
</a>
|
|
|
397 |
</div>
|
398 |
""")
|
399 |
|
400 |
+
with gr.Row(equal_height=True):
|
401 |
+
with gr.Column(scale=5):
|
402 |
with gr.Group(elem_classes="prompt-container"):
|
403 |
prompt = gr.Textbox(
|
404 |
label="✨ Video Prompt (also used for audio generation)",
|
|
|
523 |
elem_classes="generate-btn"
|
524 |
)
|
525 |
|
526 |
+
with gr.Column(scale=5):
|
527 |
video_output = gr.Video(
|
528 |
label="Generated Video with Audio",
|
529 |
autoplay=True,
|
530 |
interactive=False,
|
531 |
+
elem_classes="video-output",
|
532 |
+
height=600
|
533 |
)
|
534 |
|
535 |
gr.HTML("""
|
|
|
539 |
</div>
|
540 |
""")
|
541 |
|
542 |
+
# Examples section moved outside of columns
|
543 |
+
with gr.Row():
|
544 |
+
gr.Markdown("### 🎯 Example Prompts")
|
545 |
+
|
546 |
gr.Examples(
|
547 |
examples=examples,
|
|
|
548 |
inputs=[prompt, nag_negative_prompt, nag_scale],
|
549 |
+
outputs=None, # Don't connect outputs to avoid index issues
|
550 |
+
cache_examples=False
|
|
|
|
|
|
|
|
|
|
|
551 |
)
|
552 |
|
553 |
# Connect UI elements
|