Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -416,18 +416,8 @@ def create_demo():
|
|
| 416 |
with gr.Row():
|
| 417 |
with gr.Column(scale=1):
|
| 418 |
preview_image = gr.Image(label="Preview Image", type="filepath", elem_classes="preview_media", visible=False)
|
| 419 |
-
preview_video = gr.Video(label="Preview Video", elem_classes="preview_media", visible=False, format="mp4")
|
| 420 |
-
|
| 421 |
-
def _play_pause(video_path):
|
| 422 |
-
return f'''
|
| 423 |
-
<script>
|
| 424 |
-
const vid = document.querySelector('video[src="{video_path}"]');
|
| 425 |
-
if (vid) vid.paused ? vid.play() : vid.pause();
|
| 426 |
-
</script>
|
| 427 |
-
'''
|
| 428 |
-
|
| 429 |
-
preview_status = gr.Textbox(label="Preview status", interactive=False, lines=2, value="", visible=True)
|
| 430 |
-
|
| 431 |
with gr.Column(scale=2):
|
| 432 |
url_input = gr.Textbox(label="Image / Video URL", placeholder="https://...", lines=1)
|
| 433 |
with gr.Accordion("Prompt (optional)", open=False):
|
|
@@ -437,11 +427,11 @@ def create_demo():
|
|
| 437 |
with gr.Row():
|
| 438 |
submit_btn = gr.Button("Submit")
|
| 439 |
clear_btn = gr.Button("Clear")
|
| 440 |
-
|
| 441 |
progress_md = gr.Markdown("Idle")
|
| 442 |
output_md = gr.Markdown("")
|
| 443 |
status_state = gr.State("idle")
|
| 444 |
-
|
|
|
|
| 445 |
|
| 446 |
# small helper: fetch URL into bytes with retries and respect Retry-After
|
| 447 |
def _fetch_with_retries_bytes(src: str, timeout: int = 15, max_retries: int = 3):
|
|
|
|
| 416 |
with gr.Row():
|
| 417 |
with gr.Column(scale=1):
|
| 418 |
preview_image = gr.Image(label="Preview Image", type="filepath", elem_classes="preview_media", visible=False)
|
| 419 |
+
preview_video = gr.Video(label="Preview Video", elem_classes="preview_media", visible=False, format="mp4")
|
| 420 |
+
preview_status = gr.Textbox(label="Preview status", interactive=False, lines=1, value="", visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
with gr.Column(scale=2):
|
| 422 |
url_input = gr.Textbox(label="Image / Video URL", placeholder="https://...", lines=1)
|
| 423 |
with gr.Accordion("Prompt (optional)", open=False):
|
|
|
|
| 427 |
with gr.Row():
|
| 428 |
submit_btn = gr.Button("Submit")
|
| 429 |
clear_btn = gr.Button("Clear")
|
|
|
|
| 430 |
progress_md = gr.Markdown("Idle")
|
| 431 |
output_md = gr.Markdown("")
|
| 432 |
status_state = gr.State("idle")
|
| 433 |
+
# hidden state to pass preview path from worker to frontend
|
| 434 |
+
preview_path_state = gr.State("")
|
| 435 |
|
| 436 |
# small helper: fetch URL into bytes with retries and respect Retry-After
|
| 437 |
def _fetch_with_retries_bytes(src: str, timeout: int = 15, max_retries: int = 3):
|