Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -419,8 +419,10 @@ def create_demo():
|
|
| 419 |
preview_video = gr.Video(label="Preview Video", elem_classes="preview_media", visible=False)
|
| 420 |
with gr.Column(scale=2):
|
| 421 |
url_input = gr.Textbox(label="Image / Video URL", placeholder="https://...", lines=1)
|
| 422 |
-
|
| 423 |
-
|
|
|
|
|
|
|
| 424 |
with gr.Row():
|
| 425 |
submit_btn = gr.Button("Submit")
|
| 426 |
clear_btn = gr.Button("Clear")
|
|
@@ -457,11 +459,12 @@ def create_demo():
|
|
| 457 |
try:
|
| 458 |
if not url:
|
| 459 |
return ("error", "**Error:** No URL provided.")
|
| 460 |
-
progress(0, desc="Starting processing...")
|
| 461 |
fut = run_blocking_in_thread(process_media, url, prompt or "", key or "", progress)
|
| 462 |
res = fut.result()
|
| 463 |
-
|
| 464 |
-
|
|
|
|
| 465 |
except Exception as e:
|
| 466 |
return ("error", f"Unexpected worker error: {e}")
|
| 467 |
|
|
|
|
| 419 |
preview_video = gr.Video(label="Preview Video", elem_classes="preview_media", visible=False)
|
| 420 |
with gr.Column(scale=2):
|
| 421 |
url_input = gr.Textbox(label="Image / Video URL", placeholder="https://...", lines=1)
|
| 422 |
+
with gr.Accordion("Prompt (optional)", open=False):
|
| 423 |
+
custom_prompt = gr.Textbox(label="Prompt", lines=4, value="")
|
| 424 |
+
with gr.Accordion("Mistral API Key (optional)", open=False):
|
| 425 |
+
api_key = gr.Textbox(label="Mistral API Key", type="password", max_lines=1)
|
| 426 |
with gr.Row():
|
| 427 |
submit_btn = gr.Button("Submit")
|
| 428 |
clear_btn = gr.Button("Clear")
|
|
|
|
| 459 |
try:
|
| 460 |
if not url:
|
| 461 |
return ("error", "**Error:** No URL provided.")
|
| 462 |
+
progress(0.01, desc="Starting processing...")
|
| 463 |
fut = run_blocking_in_thread(process_media, url, prompt or "", key or "", progress)
|
| 464 |
res = fut.result()
|
| 465 |
+
if isinstance(res, str) and res.lower().startswith("error"):
|
| 466 |
+
return ("error", f"**Error:** {res}")
|
| 467 |
+
return ("done", res if isinstance(res, str) else str(res))
|
| 468 |
except Exception as e:
|
| 469 |
return ("error", f"Unexpected worker error: {e}")
|
| 470 |
|