Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -522,9 +522,27 @@ with gr.Blocks(title="Self-Forcing Streaming Demo") as demo:
|
|
| 522 |
download_btn = gr.Button("💾 Download Video", variant="secondary")
|
| 523 |
download_output = gr.File(label="Download")
|
| 524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
# Connect the generator to the streaming video
|
| 526 |
start_btn.click(
|
| 527 |
-
fn=
|
| 528 |
inputs=[prompt, seed, fps],
|
| 529 |
outputs=[streaming_video, status_display]
|
| 530 |
)
|
|
|
|
| 522 |
download_btn = gr.Button("💾 Download Video", variant="secondary")
|
| 523 |
download_output = gr.File(label="Download")
|
| 524 |
|
| 525 |
+
# Define a wrapper function to ensure we always return the expected outputs
|
| 526 |
+
def safe_video_generator(p, s, f):
|
| 527 |
+
# Clear frames from previous generation
|
| 528 |
+
APP_STATE["current_frames"] = []
|
| 529 |
+
|
| 530 |
+
# Call the generator function and ensure it returns both video and status
|
| 531 |
+
try:
|
| 532 |
+
for video_path, status_html in video_generation_handler_streaming(p, s, f):
|
| 533 |
+
if video_path is not None:
|
| 534 |
+
yield video_path, status_html
|
| 535 |
+
else:
|
| 536 |
+
yield None, status_html
|
| 537 |
+
except Exception as e:
|
| 538 |
+
import traceback
|
| 539 |
+
print(f"Error in generator: {e}")
|
| 540 |
+
traceback.print_exc()
|
| 541 |
+
yield None, f"<div style='color: red; padding: 10px; border: 1px solid #ffcccc; border-radius: 5px;'>Error: {e}</div>"
|
| 542 |
+
|
| 543 |
# Connect the generator to the streaming video
|
| 544 |
start_btn.click(
|
| 545 |
+
fn=safe_video_generator,
|
| 546 |
inputs=[prompt, seed, fps],
|
| 547 |
outputs=[streaming_video, status_display]
|
| 548 |
)
|