roboflow/supervision

GitHub: roboflow/supervision

一款模型无关的计算机视觉工具库,旨在简化目标检测结果的绘制、分析以及数据集的管理与转换。

Stars: 37543 | Forks: 3282


[notebooks](https://github.com/roboflow/notebooks) | [inference](https://github.com/roboflow/inference) | [autodistill](https://github.com/autodistill/autodistill) | [maestro](https://github.com/roboflow/multimodal-maestro)
[![version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision) [![downloads](https://img.shields.io/pypi/dm/supervision)](https://pypistats.org/packages/supervision) [![license](https://img.shields.io/pypi/l/supervision)](LICENSE.md) [![python-version](https://img.shields.io/pypi/pyversions/supervision)](https://badge.fury.io/py/supervision) [![codecov](https://codecov.io/gh/roboflow/supervision/graph/badge.svg?token=HMNJ5FVZ36)](https://codecov.io/gh/roboflow/supervision) [![snyk](https://snyk.io/advisor/python/supervision/badge.svg)](https://snyk.io/advisor/python/supervision) [![colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/supervision/blob/main/demo.ipynb) [![gradio](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Roboflow/Annotators) [![discord](https://img.shields.io/discord/1159501506232451173?logo=discord&label=discord&labelColor=fff&color=5865f2&link=https%3A%2F%2Fdiscord.gg%2FGbfgXGJ8Bk)](https://discord.gg/GbfgXGJ8Bk)
roboflow%2Fsupervision | Trendshift
## 👋 你好 **我们为您编写可复用的计算机视觉工具。** 无论您是需要从硬盘加载数据集,在图像或视频上绘制检测结果,还是计算区域内的检测数量。您都可以信赖我们!🤝 ## 💻 安装 在 [**Python>=3.9**](https://www.python.org/) 环境中使用 Pip 安装 supervision 包。 ``` pip install supervision ``` 在我们的 [指南](https://roboflow.github.io/supervision/) 中阅读更多关于 conda、mamba 以及从源码安装的内容。 ## 🔥 快速入门 ### 模型 Supervision 旨在与模型无关。只需接入任何分类、检测或分割模型即可。为了您的方便,我们为 Ultralytics、Transformers、MMDetection 或 Inference 等最流行的库创建了 [连接器](https://supervision.roboflow.com/latest/detection/core/#detections)。其他集成(如 `rfdetr`)已经直接返回 `sv.Detections`。 使用 `pip install pillow rfdetr` 安装此示例的可选依赖项。 ``` import supervision as sv from PIL import Image from rfdetr import RFDETRSmall image = Image.open(...) model = RFDETRSmall() detections = model.predict(image, threshold=0.5) len(detections) # 5 ```
👉 更多模型连接器 - inference 使用 [Inference](https://github.com/roboflow/inference) 运行需要 [Roboflow API KEY](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key)。 import supervision as sv from PIL import Image from inference import get_model image = Image.open(...) model = get_model(model_id="rfdetr-small", api_key="ROBOFLOW_API_KEY") result = model.infer(image)[0] detections = sv.Detections.from_inference(result) len(detections) # 5
### 标注器 Supervision 提供了各种高度可定制的 [标注器](https://supervision.roboflow.com/latest/detection/annotators/),让您能够针对具体用例组合出完美的可视化效果。 ``` import cv2 import supervision as sv image = cv2.imread(...) detections = sv.Detections(...) box_annotator = sv.BoxAnnotator() annotated_frame = box_annotator.annotate(scene=image.copy(), detections=detections) ``` https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-ab5644f39bce ### 数据集 Supervision 提供了一组 [工具](https://supervision.roboflow.com/latest/datasets/core/),允许您以支持的格式之一加载、拆分、合并和保存数据集。 ``` import supervision as sv from roboflow import Roboflow project = Roboflow().workspace("WORKSPACE_ID").project("PROJECT_ID") dataset = project.version("PROJECT_VERSION").download("coco") ds = sv.DetectionDataset.from_coco( images_directory_path=f"{dataset.location}/train", annotations_path=f"{dataset.location}/train/_annotations.coco.json", ) path, image, annotation = ds[0] # 按需加载图像 for path, image, annotation in ds: # loads image on demand pass ```
👉 更多数据集工具 - load dataset = sv.DetectionDataset.from_yolo( images_directory_path=..., annotations_directory_path=..., data_yaml_path=..., ) dataset = sv.DetectionDataset.from_pascal_voc( images_directory_path=..., annotations_directory_path=..., ) dataset = sv.DetectionDataset.from_coco( images_directory_path=..., annotations_path=..., ) - split train_dataset, test_dataset = dataset.split(split_ratio=0.7) test_dataset, valid_dataset = test_dataset.split(split_ratio=0.5) len(train_dataset), len(test_dataset), len(valid_dataset) # (700, 150, 150) - merge ds_1 = sv.DetectionDataset(...) len(ds_1) # 100 ds_1.classes # ['dog', 'person'] ds_2 = sv.DetectionDataset(...) len(ds_2) # 200 ds_2.classes # ['cat'] ds_merged = sv.DetectionDataset.merge([ds_1, ds_2]) len(ds_merged) # 300 ds_merged.classes # ['cat', 'dog', 'person'] - save dataset.as_yolo( images_directory_path=..., annotations_directory_path=..., data_yaml_path=..., ) dataset.as_pascal_voc( images_directory_path=..., annotations_directory_path=..., ) dataset.as_coco( images_directory_path=..., annotations_path=..., ) - convert sv.DetectionDataset.from_yolo( images_directory_path=..., annotations_directory_path=..., data_yaml_path=..., ).as_pascal_voc( images_directory_path=..., annotations_directory_path=..., )
## 🎬 教程 想要学习如何使用 Supervision?探索我们的 [操作指南](https://supervision.roboflow.com/develop/how_to/detect_and_annotate/)、[端到端示例](./examples)、[速查表](https://roboflow.github.io/cheatsheet-supervision/) 和 [Cookbooks](https://supervision.roboflow.com/develop/cookbooks/)!

Dwell Time Analysis with Computer Vision | Real-Time Stream Processing Dwell Time Analysis with Computer Vision | Real-Time Stream Processing

Created: 5 Apr 2024

Learn how to use computer vision to analyze wait times and optimize processes. This tutorial covers object detection, tracking, and calculating time spent in designated zones. Use these techniques to improve customer experience in retail, traffic management, or other scenarios.


Speed Estimation & Vehicle Tracking | Computer Vision | Open Source Speed Estimation & Vehicle Tracking | Computer Vision | Open Source

Created: 11 Jan 2024

Learn how to track and estimate the speed of vehicles using YOLO, ByteTrack, and Roboflow Inference. This comprehensive tutorial covers object detection, multi-object tracking, filtering detections, perspective transformation, speed estimation, visualization improvements, and more.

## 💜 使用 supervision 构建 您用 supervision 构建了什么很酷的东西吗?[告诉我们!](https://github.com/roboflow/supervision/discussions/categories/built-with-supervision) https://user-images.githubusercontent.com/26109316/207858600-ee862b22-0353-440b-ad85-caa0c4777904.mp4 https://github.com/roboflow/supervision/assets/26109316/c9436828-9fbf-4c25-ae8c-60e9c81b3900 https://github.com/roboflow/supervision/assets/26109316/3ac6982f-4943-4108-9b7f-51787ef1a69f ## 📚 文档 访问我们的 [文档](https://roboflow.github.io/supervision) 页面,了解 supervision 如何帮助您更快、更可靠地构建计算机视觉应用程序。
标签:Apex, CV, CV工具, Python, Roboflow, Supervision, YOLO, 人工智能, 代码库, 关键点检测, 图像处理, 图像标注, 多模态, 威胁情报, 工具包, 开发者工具, 开源库, 掩码, 搜索引擎爬虫, 无后门, 机器学习, 深度学习, 用户模式Hook绕过, 目标检测, 目标跟踪, 网络调试, 自动化, 视频分析, 计算机视觉, 边界框, 逆向工具