python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- python-api
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/api-reference.md8.1 KB
- 参考文档references/metric-behavior.md4.8 KB
- 参考文档references/troubleshooting.md3.9 KB
03 SKILL.md 正文
Python API sub-skill
Use this sub-skill when the task needs direct, in-memory use of the legacy Object-Detection-Metrics classes instead of a text-folder CLI workflow.
Best-fit triggers
- Construct
BoundingBox/BoundingBoxesobjects directly from Python data. - Compute AP or mAP from in-memory detections and ground truths with
Evaluator.GetPascalVOCMetrics. - Select
EveryPointInterpolationversusElevenPointInterpolation. - Convert relative YOLO-style center coordinates into the repository's absolute box representation.
- Diagnose source-style imports, OpenCV import failures, or headless plotting/drawing caveats.
Route away
- For end-to-end evaluation from ground-truth and detection text folders, use
../file-evaluation/SKILL.md; that path owns safe folder parsing and the self-contained CLI helper. - For COCO metrics, the newer successor toolkit, model training, inference, or benchmark-paper analysis, do not use this legacy PASCAL VOC API skill.
Operating checklist
- Prepare a Python process that can import from a user-provided checkout or copied
lib/directory. The repo is source-style, so add thelibdirectory itself tosys.path; do not expect a pip package import. - Read
references/api-reference.mdfor verified signatures, enums, class responsibilities, and in-memory usage patterns. - Read
references/metric-behavior.mdbefore interpreting AP, TP/FP, duplicate detections, relative coordinates, or IoU edge cases. - Use
scripts/api_metric_smoke.py --repo-root PATHor--lib-dir PATHto verify a user-provided checkout/copy before relying on it. - If import, plotting, drawing, or coordinate errors occur, use
references/troubleshooting.md.
Minimal in-memory pattern
import sys
from pathlib import Path
lib_dir = Path("/path/to/copied-or-checked-out/lib")
sys.path.insert(0, str(lib_dir))
from BoundingBox import BoundingBox
from BoundingBoxes import BoundingBoxes
from Evaluator import Evaluator
from utils import BBFormat, BBType, CoordinatesType, MethodAveragePrecision
boxes = BoundingBoxes()
boxes.addBoundingBox(BoundingBox("img-1", "person", 10, 10, 50, 50,
CoordinatesType.Absolute, bbType=BBType.GroundTruth,
format=BBFormat.XYX2Y2))
boxes.addBoundingBox(BoundingBox("img-1", "person", 10, 10, 50, 50,
CoordinatesType.Absolute, bbType=BBType.Detected,
classConfidence=0.99, format=BBFormat.XYX2Y2))
metrics = Evaluator().GetPascalVOCMetrics(
boxes,
IOUThreshold=0.5,
method=MethodAveragePrecision.EveryPointInterpolation,
)
This should produce one person result with AP 1.0, total positives 1, total TP 1, and total FP 0.
Distilled evidence
This sub-skill distills the repository's lib/BoundingBox.py, lib/BoundingBoxes.py, lib/Evaluator.py, lib/utils.py, and the programmatic examples under samples/sample_1/ and samples/sample_2/. Those paths are evidence for the guidance here; runtime use should rely on the bundled references and script above.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.