Spaces:
Sleeping
Sleeping
Use HTML video player output
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import tempfile
|
|
| 5 |
import time
|
| 6 |
from functools import lru_cache
|
| 7 |
from pathlib import Path
|
|
|
|
| 8 |
|
| 9 |
import cv2
|
| 10 |
import gradio as gr
|
|
@@ -212,6 +213,13 @@ def build_stickman_video(
|
|
| 212 |
if written_count == 0:
|
| 213 |
raise gr.Error("No frames were processed. Try lowering frame stride or uploading a different video.")
|
| 214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
summary = (
|
| 216 |
f"Done.\n"
|
| 217 |
f"- Source: {source.name}\n"
|
|
@@ -223,7 +231,7 @@ def build_stickman_video(
|
|
| 223 |
f"- Model: {MODEL_PATH.name}"
|
| 224 |
)
|
| 225 |
progress(1, desc="Finished.")
|
| 226 |
-
return
|
| 227 |
|
| 228 |
|
| 229 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate"), title="Rowing Stickman Demo") as demo:
|
|
@@ -256,7 +264,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate"), ti
|
|
| 256 |
line_width_input = gr.Slider(1, 8, value=3, step=1, label="Stickman line width")
|
| 257 |
run_button = gr.Button("Process video", variant="primary")
|
| 258 |
with gr.Column(scale=1):
|
| 259 |
-
video_output = gr.
|
| 260 |
file_output = gr.File(label="Download MP4")
|
| 261 |
summary_output = gr.Textbox(label="Processing summary", lines=10)
|
| 262 |
|
|
|
|
| 5 |
import time
|
| 6 |
from functools import lru_cache
|
| 7 |
from pathlib import Path
|
| 8 |
+
from urllib.parse import quote
|
| 9 |
|
| 10 |
import cv2
|
| 11 |
import gradio as gr
|
|
|
|
| 213 |
if written_count == 0:
|
| 214 |
raise gr.Error("No frames were processed. Try lowering frame stride or uploading a different video.")
|
| 215 |
|
| 216 |
+
video_url = f"/file={quote(str(output_path))}"
|
| 217 |
+
player_html = f"""
|
| 218 |
+
<video controls style="width: 100%; max-height: 520px; background: #0f172a; border-radius: 8px;">
|
| 219 |
+
<source src="{video_url}" type="video/mp4">
|
| 220 |
+
Your browser does not support the video tag.
|
| 221 |
+
</video>
|
| 222 |
+
"""
|
| 223 |
summary = (
|
| 224 |
f"Done.\n"
|
| 225 |
f"- Source: {source.name}\n"
|
|
|
|
| 231 |
f"- Model: {MODEL_PATH.name}"
|
| 232 |
)
|
| 233 |
progress(1, desc="Finished.")
|
| 234 |
+
return player_html, str(output_path), summary
|
| 235 |
|
| 236 |
|
| 237 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate"), title="Rowing Stickman Demo") as demo:
|
|
|
|
| 264 |
line_width_input = gr.Slider(1, 8, value=3, step=1, label="Stickman line width")
|
| 265 |
run_button = gr.Button("Process video", variant="primary")
|
| 266 |
with gr.Column(scale=1):
|
| 267 |
+
video_output = gr.HTML(label="Stickman playback")
|
| 268 |
file_output = gr.File(label="Download MP4")
|
| 269 |
summary_output = gr.Textbox(label="Processing summary", lines=10)
|
| 270 |
|