Files
wehub-resource-sync c6d676eb47
Docs/Test Workflow / Test docs build (push) Waiting to run
Check links & references / links-check (push) Waiting to run
Pytest/Test Workflow / testing-guardian (push) Blocked by required conditions
PR Conflict Labeler / main (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (macos-latest, 3.10) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (macos-latest, 3.11) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (macos-latest, 3.12) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (macos-latest, 3.13) (push) Waiting to run
Pytest/Test Workflow / Build this Package (push) Failing after 13m39s
Pytest/Test Workflow / Import Test and Pytest Run (ubuntu-latest, 3.10) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (ubuntu-latest, 3.11) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (ubuntu-latest, 3.12) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (ubuntu-latest, 3.13) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (windows-latest, 3.10) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (windows-latest, 3.11) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (windows-latest, 3.12) (push) Waiting to run
Pytest/Test Workflow / Import Test and Pytest Run (windows-latest, 3.13) (push) Waiting to run
docs: make Chinese README the default
2026-07-13 09:52:40 +00:00

328 lines
12 KiB
Markdown

<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/roboflow/supervision) · [上游 README](https://github.com/roboflow/supervision/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<div align="center">
<p>
<a align="center" href="https://supervision.roboflow.com" target="_blank">
<img
width="100%"
src="https://media.roboflow.com/open-source/supervision/rf-supervision-banner.png?updatedAt=1678995927529"
>
</a>
</p>
<br>
[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)
<br>
[![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)
<div align="center">
<a href="https://trendshift.io/repositories/124" target="_blank"><img src="https://trendshift.io/api/badge/repositories/124" alt="roboflow%2Fsupervision | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</div>
</div>
<details>
<summary><strong>📑 目录</strong></summary>
- [👋 你好](#-hello)
- [💻 安装](#-install)
- [🔥 快速入门](#-quickstart)
- [模型](#models)
- [标注器](#annotators)
- [数据集](#datasets)
- [🎬 教程](#-tutorials)
- [💜 使用 Supervision 构建](#-built-with-supervision)
- [📚 文档](#-documentation)
- [🏆 贡献](#-contribution)
</details>
## 👋 你好
**我们是你在计算机视觉(computer vision)领域的必备工具包。** 从数据加载到实时区域计数,我们提供各类基础模块,让你可以专注于围绕模型构建应用。🤝
## 💻 安装
在 [**Python>=3.10**](https://www.python.org/) 环境中,使用 pip 安装 supervision 包。
```bash
pip install supervision
```
如需了解 conda、mamba 及从源码安装的更多内容,请参阅我们的[指南](https://roboflow.github.io/supervision/).
## 🔥 快速入门
### 模型
Supervision 在设计上是模型无关(model agnostic)的。你可以直接接入任意分类、检测或分割模型。为方便使用,我们为 Ultralytics、Transformers、MMDetection、Inference 等最流行的库创建了[连接器](https://supervision.roboflow.com/latest/detection/core/#detections)。其他集成方式(如 `rfdetr`)已能直接返回 `sv.Detections`
使用 `pip install pillow rfdetr` 安装本示例所需的可选依赖。
```python
import supervision as sv
from PIL import Image
from rfdetr import RFDETRSmall
image = Image.open("path/to/image.jpg")
model = RFDETRSmall()
detections = model.predict(image, threshold=0.5)
len(detections)
# 5
```
<details>
<summary>👉 更多模型连接器</summary>
- inference
使用 [Inference](https://github.com/roboflow/inference) 运行需要 [Roboflow API KEY](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key).
```python
import supervision as sv
from PIL import Image
from inference import get_model
image = Image.open("path/to/image.jpg")
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
```
</details>
### 标注器
Supervision 提供大量高度可自定义的[标注器](https://supervision.roboflow.com/latest/detection/annotators/),,可让你为具体场景组合出完美的可视化效果。
```python
import cv2
import supervision as sv
image = cv2.imread("path/to/image.jpg")
# Assuming detections are obtained from a model
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/),支持以支持的格式之一加载、拆分、合并和保存数据集。
```python
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]
# loads image on demand
for path, image, annotation in ds:
# loads image on demand
pass
```
<details>
<summary>👉 更多数据集工具</summary>
- load
```python
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
```python
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
```python
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
```python
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
```python
sv.DetectionDataset.from_yolo(
images_directory_path=...,
annotations_directory_path=...,
data_yaml_path=...,
).as_pascal_voc(
images_directory_path=...,
annotations_directory_path=...,
)
```
</details>
## 🎬 教程
想了解如何使用 Supervision?可浏览我们的[操作指南](https://supervision.roboflow.com/develop/how_to/detect_and_annotate/),、[端到端示例](./examples)、[速查表](https://roboflow.github.io/cheatsheet-supervision/), 和 [cookbook](https://supervision.roboflow.com/develop/cookbooks/)!
<br/>
<p align="left">
<a href="https://youtu.be/hAWpsIuem10" title="Dwell Time Analysis with Computer Vision | Real-Time Stream Processing"><img src="https://github.com/user-attachments/assets/014cffc7-72b3-4c0a-bb89-6de265b2c06b" alt="Dwell Time Analysis with Computer Vision | Real-Time Stream Processing" width="300px" align="left" /></a>
<a href="https://youtu.be/hAWpsIuem10" title="Dwell Time Analysis with Computer Vision | Real-Time Stream Processing"><strong>Dwell Time Analysis with Computer Vision | Real-Time Stream Processing</strong></a>
<div><strong>创建时间:2024 年 4 月 5 日</strong></div>
<br/>了解如何使用计算机视觉分析等待时间并优化流程。本教程涵盖目标检测、跟踪,以及计算在指定区域内的停留时间。可将这些技术用于提升零售、交通管理等场景下的客户体验。</p>
<br/>
<p align="left">
<a href="https://youtu.be/uWP6UjDeZvY" title="速度估算与车辆跟踪 | 计算机视觉 | 开源"><img src="https://github.com/user-attachments/assets/b16b8e21-dc6c-4a73-a678-2f7d5d374793" alt="速度估算与车辆跟踪 | 计算机视觉 | 开源" width="300px" align="left" /></a>
<a href="https://youtu.be/uWP6UjDeZvY" title="速度估算与车辆跟踪 | 计算机视觉 | 开源"><strong>速度估算与车辆跟踪 | 计算机视觉 | 开源</strong></a>
<div><strong>创建日期:2024 年 1 月 11 日</strong></div>
<br/>学习如何使用 YOLO、ByteTrack 和 Roboflow Inference 跟踪并估算车辆速度。本综合教程涵盖目标检测(object detection)、多目标跟踪(multi-object tracking)、检测结果过滤、透视变换(perspective transformation)、速度估算、可视化改进等内容。</p>
## 💜 使用 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 如何帮助你更快、更可靠地构建计算机视觉应用。
## 🏆 贡献
我们欢迎你的反馈!请查阅我们的[贡献指南](.github/CONTRIBUTING.md)开始参与。感谢 🙏 所有贡献者!
<p align="center">
<a href="https://github.com/roboflow/supervision/graphs/contributors">
<img src="https://contrib.rocks/image?repo=roboflow/supervision" />
</a>
</p>
<br>
<div align="center">
<a href="https://youtube.com/roboflow">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/youtube.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949634652"
width="3%"
/>
</a>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
<a href="https://roboflow.com">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/roboflow-app.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949746649"
width="3%"
/>
</a>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
<a href="https://www.linkedin.com/company/roboflow-ai/">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/linkedin.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949633691"
width="3%"
/>
</a>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
<a href="https://docs.roboflow.com">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/knowledge.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949634511"
width="3%"
/>
</a>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
<a href="https://discuss.roboflow.com">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/forum.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949633584"
width="3%"
/>
</a>
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
<a href="https://blog.roboflow.com">
<img
src="https://media.roboflow.com/notebooks/template/icons/purple/blog.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949633605"
width="3%"
/>
</a>
</div>