A modular video object detection toolkit with a clean det-v1 JSON schema, pluggable backends, and optional model export.
Project description
detect
A modular video object detection toolkit with a clean det-v1 JSON schema, pluggable backends, and optional model export.
Current backend:
- Ultralytics YOLO (bbox / pose / segmentation)
By default,
detectdoes not write any files. You opt-in to saving JSON, frames, or annotated video via flags.
det-v1 output (returned + optionally saved)
detect always produces a canonical JSON payload in-memory with:
schema_version: always"det-v1"video: input metadata (path, fps, frame_count, width, height)detector: detector settings used for the run (name, weights, classes, conf/imgsz/device/half)frames: per-frame detections- bbox detection:
bbox = [x1, y1, x2, y2] - pose detection:
keypoints = [[x, y, score], ...] - segmentation:
segments = [[[x, y], ...], ...](polygons)
- bbox detection:
Minimal schema example
{
"schema_version": "det-v1",
"video": {
"path": "in.mp4",
"fps": 30.0,
"frame_count": 120,
"width": 1920,
"height": 1080
},
"detector": {
"name": "yolo_bbox",
"weights": "yolo26n",
"classes": null,
"conf_thresh": 0.25,
"imgsz": 640,
"device": "cpu",
"half": false
},
"frames": [
{
"frame": 0,
"file": "000000.jpg",
"detections": [
{
"det_ind": 0,
"bbox": [100.0, 50.0, 320.0, 240.0],
"score": 0.91,
"class_id": 0,
"class_name": "person"
}
]
}
]
}
Returned vs saved
- Returned (always): the full det-v1 payload is available as
DetectResult.payload(Python) or printed to stdout (CLI). - Saved (opt-in): nothing is written unless you enable artifacts:
--jsonsavesdetections.json--framessaves frames underframes/--save-videosaves an annotated video
When no artifacts are enabled, no output directory/run folder is created.
Install with pip (PyPI)
Use this if you want to install and use the tool without cloning the repo.
Install
pip install detect-lib
Optional dependencies (pip extras)
Export helpers (ONNX + ONNXRuntime):
pip install "detect-lib[export]"
TensorFlow export paths (heavy):
pip install "detect-lib[tf]"
OpenVINO export:
pip install "detect-lib[openvino]"
CoreML export (macOS):
pip install "detect-lib[coreml]"
CLI usage (pip)
Global help:
python -m detect.cli.detect_video -h
python -m detect.cli.export_model -h
List detectors:
python -c "import detect; print(detect.available_detectors())"
List models (registry + installed):
python -m detect.cli.detect_video --list-models
python -m detect.cli.export_model --list-models
Basic command (detection):
python -m detect.cli.detect_video \
--video <in.mp4> \
--detector yolo_bbox \
--weights yolo26n
Basic command (export):
python -m detect.cli.export_model \
--weights yolo26n \
--formats onnx \
--out-dir models/exports --run-name y26_onnx
Python usage (import)
You can use detect as a library after installing detect-lib with pip.
Quick sanity check
python -c "import detect; print(detect.available_detectors())"
Run detection from a Python file
Create run_detect.py:
from detect import detect_video
res = detect_video(
video="in.mp4",
detector="yolo_bbox",
weights="yolo26n",
)
payload = res.payload
print(payload["schema_version"], len(payload["frames"]))
print(res.paths) # populated only if you enable saving artifacts
Run:
python run_detect.py
Run model export from a Python file
Requires export extras based on the type of export needed (e.g.,
pip install "detect-lib[export]").
Create run_export.py:
from detect import export_model
res = export_model(
weights="yolo26n",
formats=["onnx"],
imgsz=640,
out_dir="models/exports",
run_name="y26_onnx_py",
)
print("run_dir:", res["run_dir"])
print("artifacts:")
for p in res["artifacts"]:
print(" -", p)
Run it:
python run_export.py
Install from GitHub (uv)
Use this if you are developing locally or want reproducible project environments.
Install uv:
https://docs.astral.sh/uv/getting-started/installation/#standalone-installer
Verify:
uv --version
Install dependencies
git clone https://github.com/Surya-Rayala/VideoPipeline-detection.git
cd VideoPipeline-detection
uv sync
Optional dependencies (uv extras)
uv sync --extra export
uv sync --extra tf
uv sync --extra openvino
uv sync --extra coreml
CLI usage (uv)
Global help:
uv run python -m detect.cli.detect_video -h
uv run python -m detect.cli.export_model -h
List detectors:
uv run python -c "import detect; print(detect.available_detectors())"
List models (registry + installed):
uv run python -m detect.cli.detect_video --list-models
uv run python -m detect.cli.export_model --list-models
Basic command (detection):
uv run python -m detect.cli.detect_video \
--video <in.mp4> \
--detector yolo_bbox \
--weights yolo26n
Basic command (export):
uv run python -m detect.cli.export_model \
--weights yolo26n \
--formats onnx \
--out-dir models/exports --run-name y26_onnx
TensorRT / engine export and run notes (important)
Exporting engine (TensorRT) typically requires an NVIDIA GPU + CUDA + TensorRT installed and version-compatible.
Export TensorRT engine:
uv run python -m detect.cli.export_model \
--weights yolo26n \
--formats engine \
--device 0 \
--out-dir models/exports --run-name y26_trt
Run / sanity-check the exported engine using this package (produces det-v1 output):
uv run python -m detect.cli.detect_video \
--video in.mp4 \
--detector yolo_bbox \
--weights models/exports/y26_trt/yolo26n.engine \
--device 0
Optionally save artifacts (JSON + annotated video):
uv run python -m detect.cli.detect_video \
--video in.mp4 \
--detector yolo_bbox \
--weights models/exports/y26_trt/yolo26n.engine \
--device 0 \
--json \
--save-video annotated_engine.mp4 \
--out-dir out --run-name y26_trt_check
CLI arguments
Detection: detect.cli.detect_video
Required
--video <path>: Path to the input video file.--detector <name>: Detector type (yolo_bbox, yolo_pose, or yolo_seg).--weights <id|path|url>: Registry key, local weights path, or URL to weights.
Detection options
--classes <ids>: Filter to specific class IDs (comma/semicolon-separated), or omit for all classes.--conf-thresh <float>: Confidence threshold for detections (default 0.25).--imgsz <int>: Inference image size used by the backend (default 640).--device <str>: Device selector (e.g.,auto,cpu,mps,0).--half: Enable FP16 inference where supported.
Artifact saving (opt-in)
--json: Save detections.json under the run directory.--frames: Save extracted frames as images under the run directory.--save-video <name.mp4>: Save an annotated video under the run directory.--display: Show live visualization window while running (press q to quit).
Output control
--out-dir <dir>: Output root directory used only if saving artifacts (default out).--run-name <name>: Run folder name inside out-dir (auto-derived if omitted).
Model registry / downloads
--models-dir <dir>: Directory where models are stored/downloaded (default models).--no-download: Disable automatic download for registry keys/URLs.
Misc
--no-progress: Disable progress bar output.--list-models: Print registry + installed models then exit.
Export: detect.cli.export_model
Required
--weights <id|path|url>: Registry key, local weights path, or URL to weights.
Export options
--formats <list>: Comma/semicolon-separated export formats (default onnx).--imgsz <int|H,W>: Export image size as an int orH,Wpair (default 640).--device <str>: Export device selector (e.g.,cpu,mps,0).--half: Enable FP16 export where supported.--int8: Enable INT8 quantization (format/toolchain-dependent).--data <yaml>: Dataset YAML for INT8 calibration (when required).--fraction <float>: Fraction of dataset used for calibration (default 1.0).--dynamic: Enable dynamic shapes where supported.--batch <int>: Export batch size (default 1).--opset <int>: ONNX opset version (ONNX only).--simplify: Simplify the ONNX graph (ONNX only).--workspace <int>: TensorRT workspace size in GB (TensorRT only).--nms: Add NMS to exported model when supported by format/backend.
Output control
--out-dir <dir>: Output root directory for exports (default models/exports).--run-name <name>: Export run folder name inside out-dir.
Model registry / downloads
--models-dir <dir>: Directory where models are stored/downloaded (default models).--no-download: Disable automatic download for registry keys/URLs.
Misc
--list-models: Print registry + installed models then exit.
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file detect_lib-0.1.2.tar.gz.
File metadata
- Download URL: detect_lib-0.1.2.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab4dd2e13d7f7417f2d008ebc544b665fd90d0513016a1556240ef727988da57
|
|
| MD5 |
c1e8a062d13ea88f28be5e52a95c31f7
|
|
| BLAKE2b-256 |
0523005d21e576a67486a7330f2deb8e03e47642b0be453df21ad77a9e208d60
|
File details
Details for the file detect_lib-0.1.2-py3-none-any.whl.
File metadata
- Download URL: detect_lib-0.1.2-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a79524aabd6643d697b21160ac688bc51f697de7340ccdea9372901fffe1f597
|
|
| MD5 |
a44e325a8cb5f2f2bd416c449a6d8cea
|
|
| BLAKE2b-256 |
290943f0b7a797260ceed4975b2b8e85c11922db22f7ec7c677222186bb1890f
|