detect
A modular video detection toolkit that produces a stable det-v1 JSON output schema, with a pluggable backend (currently Ultralytics) and optional model export.
- Backend: Ultralytics (YOLO families, RT-DETR, YOLO-World/YOLOE, SAM/FastSAM — depending on your installed
ultralyticsversion) - Default behavior: no files are written unless you opt-in (JSON / frames / annotated video)
Output schema (det-v1)
Every run returns a det-v1 payload in memory (and the CLI prints it to stdout).
Top-level keys:
schema_version: always"det-v1"video:{path, fps, frame_count, width, height}detector: configuration used for the run (name/weights/conf/imgsz/device/half + task + optional prompts/topk)frames: list of per-frame records
Per-frame record:
frame: 0-based frame indexfile: standard frame filename (e.g.000000.jpg) (even if frames aren’t saved)detections: list of detections
Detection fields:
- boxes:
bbox = [x1, y1, x2, y2] - pose:
keypoints = [[x, y, score], ...] - segmentation:
segments = [[[x, y], ...], ...](polygons) - oriented boxes (best-effort):
obb = [cx, cy, w, h, angle_degrees]plus an axis-alignedbbox
Minimal example
{
"schema_version": "det-v1",
"video": {"path": "in.mp4", "fps": 30.0, "frame_count": 120, "width": 1920, "height": 1080},
"detector": {"name": "ultralytics", "weights": "yolo26n", "conf_thresh": 0.25, "imgsz": 640, "device": "cpu", "half": false, "task": "detect"},
"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"}
]
}
]
}
Install
Requires Python 3.11+.
From PyPI
pip install detect-lib
Optional extras (only if you need them):
pip install "detect-lib[export]" # ONNX / export helpers
pip install "detect-lib[coreml]" # CoreML export (macOS)
pip install "detect-lib[openvino]" # OpenVINO export
pip install "detect-lib[tf]" # TensorFlow export paths (heavy)
From GitHub (uv)
git clone https://github.com/Surya-Rayala/VisionPipeline-detection.git
cd VisionPipeline-detection
uv sync
Extras:
uv sync --extra export
uv sync --extra coreml
uv sync --extra openvino
uv sync --extra tf
CLI
All CLI commands are:
python -m ...(pip)uv run python -m ...(uv)
Detection
Help:
python -m detect.cli.detect_video -h
List models (registry + installed):
python -m detect.cli.detect_video --list-models
Common patterns
1) Bounding boxes (typical YOLO / RT-DETR)
python -m detect.cli.detect_video \
--video in.mp4 \
--detector ultralytics \
--weights yolo26n \
--task detect \
--json \
--save-video annotated.mp4 \
--out-dir out --run-name yolo26n_detect
2) Instance segmentation (polygons)
python -m detect.cli.detect_video \
--video in.mp4 \
--detector ultralytics \
--weights yolo26n-seg \
--task segment \
--json \
--save-video annotated.mp4 \
--out-dir out --run-name yolo26n_seg
3) Pose (keypoints)
python -m detect.cli.detect_video \
--video in.mp4 \
--detector ultralytics \
--weights yolo26n-pose \
--task pose \
--json \
--save-video annotated.mp4 \
--out-dir out --run-name yolo26n_pose
4) Open-vocabulary (YOLO-World / YOLOE)
python -m detect.cli.detect_video \
--video in.mp4 \
--detector ultralytics \
--weights yolov8s-worldv2 \
--task openvocab \
--text "person,car,dog" \
--json \
--save-video annotated.mp4 \
--out-dir out --run-name worldv2_openvocab
*Open-vocabulary + polygons (YOLOE -seg)
Use a YOLOE segmentation weight and segment when you want polygons.
python -m detect.cli.detect_video \
--video in.mp4 \
--detector ultralytics \
--weights yoloe-11s-seg \
--task segment \
--text "person,car,dog" \
--json \
--save-video annotated.mp4 \
--out-dir out --run-name yoloe_seg_openvocab
Task semantics (important)
detect | segment | pose | obb | classify | sam | sam2 | sam3 | fastsamdescribe the output type you want.openvocabis a prompt mode for YOLO-World/YOLOE. Output type follows the model (boxes vs masks). If you want polygons, use a*-segmodel andsegment.
Prompts
You can supply prompts via:
--text "a,b,c"(open-vocabulary label list)--box "x1,y1,x2,y2"(repeatable)--point "x,y"or--point "x,y,label"(repeatable; label 1=fg, 0=bg)--prompts prompts.json(combined)
Example prompts.json:
{
"text": ["person", "car", "dog"],
"boxes": [[100, 100, 500, 500]],
"points": [[320, 240, 1], [100, 120, 0]],
"topk": 5
}
Export note (open-vocab): exported formats (ONNX/CoreML/etc.) may not support changing the vocabulary at runtime. If prompts don’t take effect, run the .pt weights for true open-vocabulary prompting or post-filter detections.
Artifacts (all opt-in)
--jsonwritesout/<run-name>/detections.json--frameswritesout/<run-name>/frames/*.jpg--save-video NAME.mp4writesout/<run-name>/NAME.mp4
If you don’t enable any artifacts, no output directory is created.
Python API
Parameter mapping (Python vs CLI)
Python uses snake_case keyword arguments. The CLI uses kebab-case flags. The values are the same, but the names differ.
Common mapping:
- CLI
--video→ Pythonvideo - CLI
--detector→ Pythondetector - CLI
--weights→ Pythonweights - CLI
--classes "0,2"→ Pythonclasses=[0, 2] - CLI
--conf-thresh→ Pythonconf_thresh - CLI
--imgsz→ Pythonimgsz - CLI
--device→ Pythondevice - CLI
--half→ Pythonhalf=True - CLI
--task→ Pythontask
Prompts:
- CLI
--text "a,b"→ Pythonprompts={"text": ["a", "b"]} - CLI
--box "x1,y1,x2,y2"(repeatable) → Pythonprompts={"boxes": [[x1, y1, x2, y2], ...]} - CLI
--point "x,y,label"(repeatable) → Pythonprompts={"points": [[x, y, label], ...]} - CLI
--topk N→ Pythontopk=N(orprompts={"topk": N})
Artifacts (all opt-in):
- CLI
--json→ Pythonsave_json=True - CLI
--frames→ Pythonsave_frames=True - CLI
--save-video NAME.mp4→ Pythonsave_video="NAME.mp4" - CLI
--out-dir DIR→ Pythonout_dir="DIR" - CLI
--run-name NAME→ Pythonrun_name="NAME" - CLI
--no-progress→ Pythonprogress=False - CLI
--display→ Pythondisplay=True
Note: the Python API also accepts an advanced artifacts=ArtifactOptions(...) object, but the convenience args above are easiest for most usage.
Detect a video
from detect import detect_video
res = detect_video(
video="in.mp4",
detector="ultralytics",
weights="yolo26n",
task="detect",
classes=None, # e.g. [0, 2] to filter class ids
conf_thresh=0.25,
imgsz=640,
device="auto",
half=False,
# prompts={"text": ["person", "car", "dog"]}, # for open-vocabulary models
save_json=True,
save_video="annotated.mp4",
out_dir="out",
run_name="py_detect",
)
print(res.payload["schema_version"], len(res.payload["frames"]))
print(res.paths)
Note: legacy detector aliases (yolo_bbox, yolo_seg, yolo_pose) are still accepted for backward compatibility, but the docs use ultralytics everywhere.
Export
Export is currently implemented for the Ultralytics backend.
CLI export
python -m detect.cli.export_model -h
python -m detect.cli.export_model \
--weights yolo26n \
--formats onnx \
--out-dir models/exports --run-name y26_onnx
Export from Python
Python export also uses snake_case args (e.g., out_dir, run_name) and accepts formats as a list or comma-separated string.
from detect.backends.ultralytics.export import export_model_ultralytics
res = export_model_ultralytics(
weights="yolo26n",
formats=["onnx"],
imgsz=640,
out_dir="models/exports",
run_name="y26_onnx_py",
)
print("run_dir:", res["run_dir"])
for p in res["artifacts"]:
print("-", p)
Compatibility notes:
- Some model families do not support export (e.g., MobileSAM and SAM/SAM2/SAM3 per Ultralytics docs). The export CLI will warn and exit.
- YOLO-World v1 weights (
*-world.pt) do not support export; use YOLO-World v2 (*-worldv2.pt) for export. - YOLOv10 supports export but only to a restricted set of formats; unsupported formats will warn and exit.
License
MIT License. See LICENSE.
Metadata
Release files for detect-lib 0.1.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 |
|---|---|---|---|---|
| detect_lib-0.1.9.tar.gz | 31.7 kB | Without provenance | Details for detect_lib-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| detect_lib-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for detect_lib-0.1.9-py3-none-any.whl |
Total release size: 70.8 kB
Release files / detect_lib-0.1.9.tar.gz
| Download URL | detect_lib-0.1.9.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3faf651781460eabb92f5d4265051b38f0642c4bab9f0c1e6cd6b081ff8a49ec
|
|
BLAKE2b-256 checksum How to use checksums |
a0c91fb76d118512cdd15583a1e25d76fa24b9b6f8c198eb784bb9093c905e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / detect_lib-0.1.9-py3-none-any.whl
| Download URL | detect_lib-0.1.9-py3-none-any.whl |
|---|---|
| Size | 39.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
682e68511779dd6975ecaec95c0fe8ddedb7df8d302d2f21bed5d4be329db6fb
|
|
BLAKE2b-256 checksum How to use checksums |
8ef636113c816f998d0f34c7c4fa56149c84530f3f1158f0badde13921be4e6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for detect-lib 0.1.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.