Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -492,12 +492,17 @@ def video_generation_handler_streaming(prompt, seed=42, fps=15):
|
|
| 492 |
f"</div>"
|
| 493 |
)
|
| 494 |
|
| 495 |
-
# Show download button
|
| 496 |
-
|
| 497 |
-
yield None, final_status_html, gr.update(visible=download_visible), final_mp4_path
|
| 498 |
|
| 499 |
print(f"✅ PyAV streaming complete! {total_frames_yielded} frames across {num_blocks} blocks")
|
| 500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
# --- Gradio UI Layout ---
|
| 502 |
with gr.Blocks(title="Self-Forcing Streaming Demo") as demo:
|
| 503 |
gr.Markdown("# 🚀 Self-Forcing Video Generation")
|
|
@@ -556,9 +561,19 @@ with gr.Blocks(title="Self-Forcing Streaming Demo") as demo:
|
|
| 556 |
show_label=False
|
| 557 |
)
|
| 558 |
|
| 559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
with gr.Row():
|
| 561 |
-
download_button = gr.
|
| 562 |
"📥 Download Video",
|
| 563 |
visible=False,
|
| 564 |
variant="primary"
|
|
@@ -578,16 +593,26 @@ with gr.Blocks(title="Self-Forcing Streaming Demo") as demo:
|
|
| 578 |
download_file = gr.File(visible=False)
|
| 579 |
|
| 580 |
# Connect the generator to the streaming video
|
| 581 |
-
start_btn.click(
|
| 582 |
fn=video_generation_handler_streaming,
|
| 583 |
inputs=[prompt, seed, fps],
|
| 584 |
-
outputs=[streaming_video, status_display,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
)
|
| 586 |
|
| 587 |
-
#
|
| 588 |
download_button.click(
|
| 589 |
-
|
| 590 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
| 591 |
outputs=[download_file]
|
| 592 |
)
|
| 593 |
|
|
|
|
| 492 |
f"</div>"
|
| 493 |
)
|
| 494 |
|
| 495 |
+
# Show download button and complete video
|
| 496 |
+
yield None, final_status_html, final_mp4_path, gr.update(value=final_mp4_path)
|
|
|
|
| 497 |
|
| 498 |
print(f"✅ PyAV streaming complete! {total_frames_yielded} frames across {num_blocks} blocks")
|
| 499 |
|
| 500 |
+
def download_video(video_path):
|
| 501 |
+
"""Handle video download."""
|
| 502 |
+
if video_path and os.path.exists(video_path):
|
| 503 |
+
return video_path
|
| 504 |
+
return None
|
| 505 |
+
|
| 506 |
# --- Gradio UI Layout ---
|
| 507 |
with gr.Blocks(title="Self-Forcing Streaming Demo") as demo:
|
| 508 |
gr.Markdown("# 🚀 Self-Forcing Video Generation")
|
|
|
|
| 561 |
show_label=False
|
| 562 |
)
|
| 563 |
|
| 564 |
+
gr.Markdown("### 🎬 Complete Video")
|
| 565 |
+
|
| 566 |
+
# Complete video display
|
| 567 |
+
complete_video = gr.Video(
|
| 568 |
+
label="Complete Video",
|
| 569 |
+
height=400,
|
| 570 |
+
show_label=False,
|
| 571 |
+
visible=False
|
| 572 |
+
)
|
| 573 |
+
|
| 574 |
+
# Download button
|
| 575 |
with gr.Row():
|
| 576 |
+
download_button = gr.Button(
|
| 577 |
"📥 Download Video",
|
| 578 |
visible=False,
|
| 579 |
variant="primary"
|
|
|
|
| 593 |
download_file = gr.File(visible=False)
|
| 594 |
|
| 595 |
# Connect the generator to the streaming video
|
| 596 |
+
generation_event = start_btn.click(
|
| 597 |
fn=video_generation_handler_streaming,
|
| 598 |
inputs=[prompt, seed, fps],
|
| 599 |
+
outputs=[streaming_video, status_display, complete_video, download_button]
|
| 600 |
+
)
|
| 601 |
+
|
| 602 |
+
# When generation completes, show the complete video and download button
|
| 603 |
+
generation_event.then(
|
| 604 |
+
fn=lambda x: (gr.update(visible=True), gr.update(visible=True)),
|
| 605 |
+
inputs=[complete_video],
|
| 606 |
+
outputs=[complete_video, download_button]
|
| 607 |
)
|
| 608 |
|
| 609 |
+
# Handle download button click
|
| 610 |
download_button.click(
|
| 611 |
+
fn=download_video,
|
| 612 |
+
inputs=[complete_video],
|
| 613 |
+
outputs=[download_file]
|
| 614 |
+
).then(
|
| 615 |
+
fn=lambda: gr.update(visible=True),
|
| 616 |
outputs=[download_file]
|
| 617 |
)
|
| 618 |
|