












Roboflow 的 Supervision 项目已于近期突破 30,000 个 GitHub Stars,是视觉工程师常用的辅助库,让你告别重复造轮子。 Supervision 是 Roboflow 出品、基于 MIT 协议的开源库,用于解决视觉项目中常见的可视化、跟踪、计数、格式转换等需求。可与 YOLO、Detectron2、Transformers 等模型无缝对接,适用于视频分析、物体追踪、区域计数、数据集处理等场景。
Supervision 正是为此而生,让你专注模型和应用,不再纠结基础设施。
Detections 类统一封装检测框、分割 mask、类别、跟踪 ID 等信息,支持从 Ultralytics、Transformers、inference 输出中加载 。
提供超过 20 种 annotator,例如 BoxAnnotator、LabelAnnotator、MaskAnnotator、TraceAnnotator、VertexAnnotator … 支持灵活组合搭配 。
支持定义直线或多边形区域统计目标穿越次数、筛选区域内对象等,适合行为分析、出入口统计 。
集成 ByteTrack 跟踪器、检测平滑器(DetectionsSmoother),可将视频目标轨迹可视化为 trace 抽象路径与轨迹图 。
可处理姿态估计模型输出(KeyPoints),通过 .as_detections() 转换为 Detections,并与跟踪结合统计人体行为 。
提供 Precision、Recall、Mean Average Recall、F1 Score 等 CV 评估指标,支持普通与 Oriented Bounding Boxes 评估 。
提供 xyxy_to_xywh/xcycarh 坐标转换函数,支持 IoU 与 IOS(Intersection over Smallest)重叠度评估 。
|
Detections 标准化 |
支持多种模型输入,处理统一一致,代码简洁清晰 |
|
Annotator 可定制性 |
支持样式、颜色、标签、字体等灵活配置 |
|
Zone 工具(Line/Polygon) |
快速实现区域计数与过滤功能,适用于安防、物流、零售等场景 |
|
跟踪集成 |
自动跟踪目标,获得 tracker_id,后续统计更精准 |
|
数据集工具支持 |
自动转换数据格式,支持 YOLO/COCO/VOC 等格式兼容 |
import cv2 import supervision as sv from ultralytics import YOLO from supervision.tools.line_counter import LineCounter from supervision.geometry.dataclasses import Point model = YOLO("yolov8s.pt") line = LineCounter(start=Point(100,400), end=Point(100,100)) box_annotator = sv.BoxAnnotator() cap = cv2.VideoCapture("input.mp4") while cap.isOpened(): ret, frame = cap.read() if not ret: break result = model(frame)[0] detections = sv.Detections.from_ultralytics(result) line.update(detections=detections) annotated = box_annotator.annotate(scene=frame, detections=detections) line.annotator.annotate(scene=annotated, line_counter=line) cv2.imshow("output", annotated) if cv2.waitKey(1)==27: break print(f"In: {line.in_count}, Out: {line.out_count}")
结果界面可展示视频中方框、轨迹线、计数标签,非常直观(参考上方截图第3张、第4张)。
from roboflow import Roboflow import supervision as sv rf = Roboflow(api_key="YOUR_KEY") proj = rf.workspace("...").project("...") version = proj.version(1) dataset = version.download("coco") ds = sv.DetectionDataset.from_coco( images_directory_path=f"{dataset.location}/train", annotations_path=f"{dataset.location}/train/_annotations.coco.json" )
可方便地进行训练与验证集格式管理。

|
多模型兼容 |
YOLO、Detectron2、Transformers、Inference |
每种模型格式需手写适配 |
|
区域计数工具 |
内置 LineZoneCounter、PolygonZoneCounter |
手写几何判断复杂冗余 |
|
可视化注释工具 |
丰富及定制化 Annotator 支持多样样式 |
平均只有简单画框,难定制 |
|
跟踪组件支持 |
自动整合 ByteTrack/SORT 等,输出 tracker_id |
跟踪逻辑需手动植入 |
|
数据集工具支持 |
支持 coco、yolo、voc 等格式转换与加载 |
通常需自己写解析器 |
|
快速上手与文档完善 |
pip 安装 + 示例丰富 + 官方博客指导 |
学习成本高 |
Roboflow Supervision 已获 GitHub ⭐30.9 k,成为 CV 项目可视化与分析的标配工具库。 它弥合模型输出与业务可视化之间的鸿沟,适配多模型、输出统一、注释灵活、区域统计精准、目标跟踪平滑,可显著降低开发成本。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。