tags: [gradio-custom-component, gradio-5, laban-movement-analysis, pose-visualisation, pose-estimation, movement-visualisation, visualisation, video] title: gradio_overlay_video emoji: 🏃 short_description: pose data overlayed video controller colorFrom: purple colorTo: green sdk: gradio sdk_version: 5.33.0 pinned: false app_file: space.py
gradio_overlay_video
overlayed video controller
Installation
pip install gradio_overlay_video
Usage
import gradio as gr
from gradio_overlay_video import OverlayVideo
from pathlib import Path
DEMO_DIR = Path(__file__).parent.parent
sample_video_path = DEMO_DIR / "files/balette.mp4"
sample_json_path = DEMO_DIR / "files/mediapipe_full_kp_balette.json"
mediapipe_json_path = DEMO_DIR / "files/mediapipe_heavy_kp_parkour.json"
movenet_json_path = DEMO_DIR / "files/movenet_thunder_kp_skate.json"
yolo8_json_path = DEMO_DIR / "files/yolov8_kp_dance.json"
yolo11_json_path = DEMO_DIR / "files/yolov11.json"
def prepare_visualization_data(json_path, video_path):
"""
This function simply validates the inputs and passes them to the
custom OverlayVideo component for frontend processing.
"""
if not json_path:
raise gr.Error("A JSON file is required to generate a visualization.")
print(f"✅ Preparing visualization with JSON: {json_path}")
if video_path:
print(f"✅ Video background provided: {video_path}")
else:
print("ℹ️ No video background provided. Visualization will be on a black background.")
# The backend's job is just to pass the filepaths to the frontend.
# The return format (video_path, json_path) must match what postprocess expects.
return (video_path, json_path)
with gr.Blocks(theme=gr.themes.Default(primary_hue="rose", secondary_hue="pink")) as demo:
gr.Markdown(
"# 🩰 Interactive Pose Visualization\n"
"1. **Upload a JSON file** with pose data.\n"
"2. **(Optional) Upload a video** to use as the background.\n"
"3. Click 'Display Visualization' to see the interactive result."
)
with gr.Row():
with gr.Column(scale=1):
# Use standard gr.File for robust input handling
json_upload = gr.File(
label="Upload Required JSON File",
file_types=[".json"],
type="filepath"
)
video_upload = gr.File(
label="Upload Optional Video File",
file_types=["video"],
type="filepath",
value=None
)
btn = gr.Button("Display Visualization", variant="primary")
with gr.Column(scale=1):
output_ov = OverlayVideo(label="Output", interactive=False, autoplay=True)
btn.click(
fn=prepare_visualization_data,
inputs=[json_upload, video_upload],
outputs=[output_ov]
)
gr.Examples(
examples=[
[str(mediapipe_json_path), None],
[str(movenet_json_path), None],
[str(yolo8_json_path), None],
[str(sample_json_path), str(sample_video_path)],
[str(yolo11_json_path), None]
],
inputs=[json_upload, video_upload],
outputs=output_ov,
fn=prepare_visualization_data,
cache_examples=True
)
if __name__ == "__main__":
demo.launch(allowed_paths=["/Users/csabi/Develop/overlay_video/files"])
OverlayVideo
Initialization
| name | type | default | description |
|---|---|---|---|
value |
typing.Any
|
None |
None |
label |
str | None
|
None |
None |
interactive |
bool | None
|
None |
None |
autoplay |
bool
|
False |
None |
loop |
bool
|
False |
None |
mode |
str
|
"overlay" |
None |
Events
| name | description |
|---|---|
change |
Triggered when the value of the OverlayVideo changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input. |
clear |
This listener is triggered when the user clears the OverlayVideo using the clear button for the component. |
play |
This listener is triggered when the user plays the media in the OverlayVideo. |
pause |
This listener is triggered when the media in the OverlayVideo stops for any reason. |
end |
This listener is triggered when the user reaches the end of the media playing in the OverlayVideo. |
User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
def predict(
value: str | None
) -> typing.Optional[typing.Tuple[str | None, str | None]][
typing.Tuple[str | None, str | None][
str | None, str | None
],
None,
]:
return value
Metadata
Release files for gradio-overlay-video 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gradio_overlay_video-0.0.9.tar.gz | 6.1 MB | Without provenance | Details for gradio_overlay_video-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gradio_overlay_video-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for gradio_overlay_video-0.0.9-py3-none-any.whl |
Total release size: 7.6 MB
Release files / gradio_overlay_video-0.0.9.tar.gz
| Download URL | gradio_overlay_video-0.0.9.tar.gz |
|---|---|
| Size | 6.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1173284c1ed4c3dbf9f1c02f63a5dc441f36c6a1357d06d2dbd44d24ebfd8037
|
|
BLAKE2b-256 checksum How to use checksums |
0054fe1f1292fb01215f0dfdd0d04bc6b0f7ee1b905203eaaea035fa8a0fce20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / gradio_overlay_video-0.0.9-py3-none-any.whl
| Download URL | gradio_overlay_video-0.0.9-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5dd55f4f23378c3f83226717f50eeb724c3e24468cba204cdc75446a9790db8f
|
|
BLAKE2b-256 checksum How to use checksums |
14006e68f08c78f06abc44036beb334978e2718e6d0670b341dbb4f19357d1e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for gradio-overlay-video 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.