superiorvision 0.30.0.dev0__tar.gz → 0.30.0.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {superiorvision-0.30.0.dev0/src/superiorvision.egg-info → superiorvision-0.30.0.dev2}/PKG-INFO +34 -26
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/README.md +31 -23
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/pyproject.toml +3 -3
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2/src/superiorvision.egg-info}/PKG-INFO +34 -26
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/core.py +7 -16
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/overlap_filter.py +46 -11
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/transformers.py +101 -27
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/key_points/core.py +7 -9
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/core.py +2 -2
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/LICENSE.md +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/setup.cfg +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/superiorvision/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/superiorvision.egg-info/SOURCES.txt +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/superiorvision.egg-info/dependency_links.txt +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/superiorvision.egg-info/requires.txt +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/superiorvision.egg-info/top_level.txt +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/annotators/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/annotators/base.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/annotators/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/annotators/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/assets/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/assets/downloader.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/assets/list.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/classification/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/classification/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/config.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/coco.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/createml.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/labelme.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/pascal_voc.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/formats/yolo.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/dataset/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/compact_mask.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/line_zone.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tensor_utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tensor_views.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/csv_sink.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/inference_slicer.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/json_sink.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/polygon_zone.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/tools/smoother.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/_typing.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/boxes.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/converters.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/internal.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/iou_and_nms.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/masks.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/polygons.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/utils/vlms.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/detection/vlm.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/draw/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/draw/base.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/draw/color.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/draw/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/geometry/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/geometry/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/geometry/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/key_points/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/key_points/annotators.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/key_points/skeletons.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/keypoint/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/keypoint/annotators.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/keypoint/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/core.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/detection.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/f1_score.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/mean_average_precision.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/mean_average_recall.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/precision.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/recall.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/utils/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/utils/matching.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/utils/object_size.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/metrics/utils/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/py.typed +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/kalman_filter.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/matching.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/single_object_track.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/tracker/byte_tracker/utils.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/conversion.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/deprecate.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/file.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/image.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/internal.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/iterables.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/logger.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/notebook.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/tensor.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/utils/video.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/src/supervision/validators/__init__.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/tests/test_public_api.py +0 -0
- {superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2}/tests/test_validate_deprecations.py +0 -0
{superiorvision-0.30.0.dev0/src/superiorvision.egg-info → superiorvision-0.30.0.dev2}/PKG-INFO
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: superiorvision
|
|
3
|
-
Version: 0.30.0.
|
|
3
|
+
Version: 0.30.0.dev2
|
|
4
4
|
Summary: A tensor-native, inference-focused fork of Supervision
|
|
5
5
|
Author-email: "Roboflow et al." <develop@roboflow.com>
|
|
6
6
|
Maintainer-email: Piotr Skalski <piotr@roboflow.com>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
Project-URL: Documentation, https://supervision.roboflow.com/latest/
|
|
9
|
-
Project-URL: Homepage, https://github.com/roboflow/
|
|
10
|
-
Project-URL: Repository, https://github.com/roboflow/
|
|
9
|
+
Project-URL: Homepage, https://github.com/roboflow/superiorvision
|
|
10
|
+
Project-URL: Repository, https://github.com/roboflow/superiorvision
|
|
11
11
|
Keywords: AI,deep-learning,DL,machine-learning,ML,Roboflow,vision
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -72,18 +72,14 @@ If detections begin as tensors, converting them to NumPy so the next operation
|
|
|
72
72
|
can turn them back into tensors is not "compatibility." It is cardio.
|
|
73
73
|
SuperiorVision declines the workout.
|
|
74
74
|
|
|
75
|
-
[](https://pypi.org/project/superiorvision/) [](https://pypistats.org/packages/superiorvision) [](LICENSE.md) [](https://pypi.org/project/superiorvision/)
|
|
76
76
|
|
|
77
|
-
[](https://huggingface.co/spaces/Roboflow/Annotators) [](https://discord.gg/GbfgXGJ8Bk)
|
|
82
78
|
|
|
83
79
|
Same API. Fewer NumPy vacations.
|
|
84
80
|
|
|
85
81
|
For the external multi-object trackers used by Inference, pair SuperiorVision
|
|
86
|
-
with the
|
|
82
|
+
with the [Tracktors](https://pypi.org/project/tracktors/) package. The
|
|
87
83
|
dependency points one way—Tracktors consumes tensor-native `sv.Detections`—so
|
|
88
84
|
SuperiorVision keeps its existing `sv.ByteTrack` compatibility API without a
|
|
89
85
|
circular package dependency.
|
|
@@ -98,7 +94,7 @@ circular package dependency.
|
|
|
98
94
|
- [Annotators](#annotators)
|
|
99
95
|
- [Datasets](#datasets)
|
|
100
96
|
- [🎬 Tutorials](#-tutorials)
|
|
101
|
-
- [💜 Built with
|
|
97
|
+
- [💜 Built with the API](#-built-with-the-api)
|
|
102
98
|
- [📚 Documentation](#-documentation)
|
|
103
99
|
- [🏆 Contribution](#-contribution)
|
|
104
100
|
|
|
@@ -106,11 +102,22 @@ circular package dependency.
|
|
|
106
102
|
|
|
107
103
|
## 👋 Hello
|
|
108
104
|
|
|
109
|
-
**
|
|
105
|
+
**The familiar computer-vision toolkit, now with fewer surprise trips to the
|
|
106
|
+
CPU.** From tensor-native detections to real-time zone counting, SuperiorVision
|
|
107
|
+
keeps the compatible building blocks used by Inference while letting GPUs do
|
|
108
|
+
the job they were purchased to do. 🤝
|
|
110
109
|
|
|
111
110
|
## 💻 Install
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
Install the SuperiorVision distribution in a
|
|
113
|
+
[**Python>=3.10**](https://www.python.org/) environment. The published version
|
|
114
|
+
is currently a development release, so pin it explicitly:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install superiorvision==0.30.0.dev2
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For an editable checkout:
|
|
114
121
|
|
|
115
122
|
```bash
|
|
116
123
|
git clone git@github.com:roboflow/superiorvision.git
|
|
@@ -125,9 +132,10 @@ import supervision as sv # existing Inference code
|
|
|
125
132
|
import superiorvision as sv # cheekier spelling, same API
|
|
126
133
|
```
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
The PyPI distribution is named `superiorvision`, but it intentionally provides
|
|
136
|
+
the `supervision` import namespace for drop-in compatibility. Install it as a
|
|
137
|
+
replacement for upstream Supervision, not beside it. Two distributions cannot
|
|
138
|
+
both own the same trench coat and pretend everything is fine.
|
|
131
139
|
|
|
132
140
|
The upstream documentation below remains useful for the compatible API surface.
|
|
133
141
|
|
|
@@ -135,7 +143,7 @@ The upstream documentation below remains useful for the compatible API surface.
|
|
|
135
143
|
|
|
136
144
|
### Models
|
|
137
145
|
|
|
138
|
-
|
|
146
|
+
SuperiorVision preserves Supervision's model-agnostic API. Just plug in any classification, detection, or segmentation model. The compatible [connectors](https://supervision.roboflow.com/latest/detection/core/#detections) cover popular libraries such as Ultralytics, Transformers, MMDetection, and Inference. Other integrations, including `rfdetr`, already return `sv.Detections` directly.
|
|
139
147
|
|
|
140
148
|
Install the optional dependencies for this example with `pip install pillow rfdetr`.
|
|
141
149
|
|
|
@@ -177,7 +185,7 @@ len(detections)
|
|
|
177
185
|
|
|
178
186
|
### Annotators
|
|
179
187
|
|
|
180
|
-
|
|
188
|
+
SuperiorVision retains the wide range of customizable [annotators](https://supervision.roboflow.com/latest/detection/annotators/) from its upstream API, allowing you to compose the visualization your use case needs.
|
|
181
189
|
|
|
182
190
|
```python
|
|
183
191
|
import cv2
|
|
@@ -195,7 +203,7 @@ https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-
|
|
|
195
203
|
|
|
196
204
|
### Datasets
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
SuperiorVision retains the compatible [dataset utilities](https://supervision.roboflow.com/latest/datasets/core/) for loading, splitting, merging, and saving supported formats. Dataset and image I/O remain deliberate CPU boundaries; tensor-native runtime paths do not need to cosplay as JPEG encoders.
|
|
199
207
|
|
|
200
208
|
```python
|
|
201
209
|
import supervision as sv
|
|
@@ -309,7 +317,7 @@ for path, image, annotation in ds:
|
|
|
309
317
|
|
|
310
318
|
## 🎬 Tutorials
|
|
311
319
|
|
|
312
|
-
Want to learn
|
|
320
|
+
Want to learn the compatible API? Explore the upstream [how-to guides](https://supervision.roboflow.com/develop/how_to/detect_and_annotate/), [end-to-end examples](./examples), [cheatsheet](https://roboflow.github.io/cheatsheet-supervision/), and [cookbooks](https://supervision.roboflow.com/develop/cookbooks/)!
|
|
313
321
|
|
|
314
322
|
<br/>
|
|
315
323
|
|
|
@@ -327,9 +335,9 @@ Want to learn how to use Supervision? Explore our [how-to guides](https://superv
|
|
|
327
335
|
<div><strong>Created: 11 Jan 2024</strong></div>
|
|
328
336
|
<br/>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.</p>
|
|
329
337
|
|
|
330
|
-
## 💜 Built with
|
|
338
|
+
## 💜 Built with the API
|
|
331
339
|
|
|
332
|
-
Did you build something cool using supervision? [
|
|
340
|
+
Did you build something cool using the compatible `supervision` API? [Tell us in the SuperiorVision repository.](https://github.com/roboflow/superiorvision)
|
|
333
341
|
|
|
334
342
|
https://user-images.githubusercontent.com/26109316/207858600-ee862b22-0353-440b-ad85-caa0c4777904.mp4
|
|
335
343
|
|
|
@@ -339,15 +347,15 @@ https://github.com/roboflow/supervision/assets/26109316/3ac6982f-4943-4108-9b7f-
|
|
|
339
347
|
|
|
340
348
|
## 📚 Documentation
|
|
341
349
|
|
|
342
|
-
|
|
350
|
+
The [upstream Supervision documentation](https://supervision.roboflow.com/latest/) describes the compatible API. Fork-specific tensor coverage and Inference compatibility are tracked in [this repository](https://github.com/roboflow/superiorvision) and [the Inference API surface audit](INFERENCE_API_SURFACE.md).
|
|
343
351
|
|
|
344
352
|
## 🏆 Contribution
|
|
345
353
|
|
|
346
|
-
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!
|
|
354
|
+
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. The fork lives at [`roboflow/superiorvision`](https://github.com/roboflow/superiorvision); upstream-compatible changes may still belong in Supervision. Thank you 🙏 to all our contributors!
|
|
347
355
|
|
|
348
356
|
<p align="center">
|
|
349
|
-
<a href="https://github.com/roboflow/
|
|
350
|
-
<img src="https://contrib.rocks/image?repo=roboflow/
|
|
357
|
+
<a href="https://github.com/roboflow/superiorvision/graphs/contributors">
|
|
358
|
+
<img src="https://contrib.rocks/image?repo=roboflow/superiorvision" />
|
|
351
359
|
</a>
|
|
352
360
|
</p>
|
|
353
361
|
|
|
@@ -21,18 +21,14 @@ If detections begin as tensors, converting them to NumPy so the next operation
|
|
|
21
21
|
can turn them back into tensors is not "compatibility." It is cardio.
|
|
22
22
|
SuperiorVision declines the workout.
|
|
23
23
|
|
|
24
|
-
[](https://pypi.org/project/superiorvision/) [](https://pypistats.org/packages/superiorvision) [](LICENSE.md) [](https://pypi.org/project/superiorvision/)
|
|
25
25
|
|
|
26
|
-
[](https://huggingface.co/spaces/Roboflow/Annotators) [](https://discord.gg/GbfgXGJ8Bk)
|
|
31
27
|
|
|
32
28
|
Same API. Fewer NumPy vacations.
|
|
33
29
|
|
|
34
30
|
For the external multi-object trackers used by Inference, pair SuperiorVision
|
|
35
|
-
with the
|
|
31
|
+
with the [Tracktors](https://pypi.org/project/tracktors/) package. The
|
|
36
32
|
dependency points one way—Tracktors consumes tensor-native `sv.Detections`—so
|
|
37
33
|
SuperiorVision keeps its existing `sv.ByteTrack` compatibility API without a
|
|
38
34
|
circular package dependency.
|
|
@@ -47,7 +43,7 @@ circular package dependency.
|
|
|
47
43
|
- [Annotators](#annotators)
|
|
48
44
|
- [Datasets](#datasets)
|
|
49
45
|
- [🎬 Tutorials](#-tutorials)
|
|
50
|
-
- [💜 Built with
|
|
46
|
+
- [💜 Built with the API](#-built-with-the-api)
|
|
51
47
|
- [📚 Documentation](#-documentation)
|
|
52
48
|
- [🏆 Contribution](#-contribution)
|
|
53
49
|
|
|
@@ -55,11 +51,22 @@ circular package dependency.
|
|
|
55
51
|
|
|
56
52
|
## 👋 Hello
|
|
57
53
|
|
|
58
|
-
**
|
|
54
|
+
**The familiar computer-vision toolkit, now with fewer surprise trips to the
|
|
55
|
+
CPU.** From tensor-native detections to real-time zone counting, SuperiorVision
|
|
56
|
+
keeps the compatible building blocks used by Inference while letting GPUs do
|
|
57
|
+
the job they were purchased to do. 🤝
|
|
59
58
|
|
|
60
59
|
## 💻 Install
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
Install the SuperiorVision distribution in a
|
|
62
|
+
[**Python>=3.10**](https://www.python.org/) environment. The published version
|
|
63
|
+
is currently a development release, so pin it explicitly:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install superiorvision==0.30.0.dev2
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For an editable checkout:
|
|
63
70
|
|
|
64
71
|
```bash
|
|
65
72
|
git clone git@github.com:roboflow/superiorvision.git
|
|
@@ -74,9 +81,10 @@ import supervision as sv # existing Inference code
|
|
|
74
81
|
import superiorvision as sv # cheekier spelling, same API
|
|
75
82
|
```
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
The PyPI distribution is named `superiorvision`, but it intentionally provides
|
|
85
|
+
the `supervision` import namespace for drop-in compatibility. Install it as a
|
|
86
|
+
replacement for upstream Supervision, not beside it. Two distributions cannot
|
|
87
|
+
both own the same trench coat and pretend everything is fine.
|
|
80
88
|
|
|
81
89
|
The upstream documentation below remains useful for the compatible API surface.
|
|
82
90
|
|
|
@@ -84,7 +92,7 @@ The upstream documentation below remains useful for the compatible API surface.
|
|
|
84
92
|
|
|
85
93
|
### Models
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
SuperiorVision preserves Supervision's model-agnostic API. Just plug in any classification, detection, or segmentation model. The compatible [connectors](https://supervision.roboflow.com/latest/detection/core/#detections) cover popular libraries such as Ultralytics, Transformers, MMDetection, and Inference. Other integrations, including `rfdetr`, already return `sv.Detections` directly.
|
|
88
96
|
|
|
89
97
|
Install the optional dependencies for this example with `pip install pillow rfdetr`.
|
|
90
98
|
|
|
@@ -126,7 +134,7 @@ len(detections)
|
|
|
126
134
|
|
|
127
135
|
### Annotators
|
|
128
136
|
|
|
129
|
-
|
|
137
|
+
SuperiorVision retains the wide range of customizable [annotators](https://supervision.roboflow.com/latest/detection/annotators/) from its upstream API, allowing you to compose the visualization your use case needs.
|
|
130
138
|
|
|
131
139
|
```python
|
|
132
140
|
import cv2
|
|
@@ -144,7 +152,7 @@ https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-
|
|
|
144
152
|
|
|
145
153
|
### Datasets
|
|
146
154
|
|
|
147
|
-
|
|
155
|
+
SuperiorVision retains the compatible [dataset utilities](https://supervision.roboflow.com/latest/datasets/core/) for loading, splitting, merging, and saving supported formats. Dataset and image I/O remain deliberate CPU boundaries; tensor-native runtime paths do not need to cosplay as JPEG encoders.
|
|
148
156
|
|
|
149
157
|
```python
|
|
150
158
|
import supervision as sv
|
|
@@ -258,7 +266,7 @@ for path, image, annotation in ds:
|
|
|
258
266
|
|
|
259
267
|
## 🎬 Tutorials
|
|
260
268
|
|
|
261
|
-
Want to learn
|
|
269
|
+
Want to learn the compatible API? Explore the upstream [how-to guides](https://supervision.roboflow.com/develop/how_to/detect_and_annotate/), [end-to-end examples](./examples), [cheatsheet](https://roboflow.github.io/cheatsheet-supervision/), and [cookbooks](https://supervision.roboflow.com/develop/cookbooks/)!
|
|
262
270
|
|
|
263
271
|
<br/>
|
|
264
272
|
|
|
@@ -276,9 +284,9 @@ Want to learn how to use Supervision? Explore our [how-to guides](https://superv
|
|
|
276
284
|
<div><strong>Created: 11 Jan 2024</strong></div>
|
|
277
285
|
<br/>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.</p>
|
|
278
286
|
|
|
279
|
-
## 💜 Built with
|
|
287
|
+
## 💜 Built with the API
|
|
280
288
|
|
|
281
|
-
Did you build something cool using supervision? [
|
|
289
|
+
Did you build something cool using the compatible `supervision` API? [Tell us in the SuperiorVision repository.](https://github.com/roboflow/superiorvision)
|
|
282
290
|
|
|
283
291
|
https://user-images.githubusercontent.com/26109316/207858600-ee862b22-0353-440b-ad85-caa0c4777904.mp4
|
|
284
292
|
|
|
@@ -288,15 +296,15 @@ https://github.com/roboflow/supervision/assets/26109316/3ac6982f-4943-4108-9b7f-
|
|
|
288
296
|
|
|
289
297
|
## 📚 Documentation
|
|
290
298
|
|
|
291
|
-
|
|
299
|
+
The [upstream Supervision documentation](https://supervision.roboflow.com/latest/) describes the compatible API. Fork-specific tensor coverage and Inference compatibility are tracked in [this repository](https://github.com/roboflow/superiorvision) and [the Inference API surface audit](INFERENCE_API_SURFACE.md).
|
|
292
300
|
|
|
293
301
|
## 🏆 Contribution
|
|
294
302
|
|
|
295
|
-
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!
|
|
303
|
+
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. The fork lives at [`roboflow/superiorvision`](https://github.com/roboflow/superiorvision); upstream-compatible changes may still belong in Supervision. Thank you 🙏 to all our contributors!
|
|
296
304
|
|
|
297
305
|
<p align="center">
|
|
298
|
-
<a href="https://github.com/roboflow/
|
|
299
|
-
<img src="https://contrib.rocks/image?repo=roboflow/
|
|
306
|
+
<a href="https://github.com/roboflow/superiorvision/graphs/contributors">
|
|
307
|
+
<img src="https://contrib.rocks/image?repo=roboflow/superiorvision" />
|
|
300
308
|
</a>
|
|
301
309
|
</p>
|
|
302
310
|
|
|
@@ -4,7 +4,7 @@ requires = [ "setuptools>=61" ]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "superiorvision"
|
|
7
|
-
version = "0.30.0.
|
|
7
|
+
version = "0.30.0.dev2"
|
|
8
8
|
description = "A tensor-native, inference-focused fork of Supervision"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
keywords = [
|
|
@@ -66,8 +66,8 @@ optional-dependencies.metrics = [
|
|
|
66
66
|
"pandas>=2",
|
|
67
67
|
]
|
|
68
68
|
urls.Documentation = "https://supervision.roboflow.com/latest/"
|
|
69
|
-
urls.Homepage = "https://github.com/roboflow/
|
|
70
|
-
urls.Repository = "https://github.com/roboflow/
|
|
69
|
+
urls.Homepage = "https://github.com/roboflow/superiorvision"
|
|
70
|
+
urls.Repository = "https://github.com/roboflow/superiorvision"
|
|
71
71
|
|
|
72
72
|
[dependency-groups]
|
|
73
73
|
dev = [
|
{superiorvision-0.30.0.dev0 → superiorvision-0.30.0.dev2/src/superiorvision.egg-info}/PKG-INFO
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: superiorvision
|
|
3
|
-
Version: 0.30.0.
|
|
3
|
+
Version: 0.30.0.dev2
|
|
4
4
|
Summary: A tensor-native, inference-focused fork of Supervision
|
|
5
5
|
Author-email: "Roboflow et al." <develop@roboflow.com>
|
|
6
6
|
Maintainer-email: Piotr Skalski <piotr@roboflow.com>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
Project-URL: Documentation, https://supervision.roboflow.com/latest/
|
|
9
|
-
Project-URL: Homepage, https://github.com/roboflow/
|
|
10
|
-
Project-URL: Repository, https://github.com/roboflow/
|
|
9
|
+
Project-URL: Homepage, https://github.com/roboflow/superiorvision
|
|
10
|
+
Project-URL: Repository, https://github.com/roboflow/superiorvision
|
|
11
11
|
Keywords: AI,deep-learning,DL,machine-learning,ML,Roboflow,vision
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -72,18 +72,14 @@ If detections begin as tensors, converting them to NumPy so the next operation
|
|
|
72
72
|
can turn them back into tensors is not "compatibility." It is cardio.
|
|
73
73
|
SuperiorVision declines the workout.
|
|
74
74
|
|
|
75
|
-
[](https://pypi.org/project/superiorvision/) [](https://pypistats.org/packages/superiorvision) [](LICENSE.md) [](https://pypi.org/project/superiorvision/)
|
|
76
76
|
|
|
77
|
-
[](https://huggingface.co/spaces/Roboflow/Annotators) [](https://discord.gg/GbfgXGJ8Bk)
|
|
82
78
|
|
|
83
79
|
Same API. Fewer NumPy vacations.
|
|
84
80
|
|
|
85
81
|
For the external multi-object trackers used by Inference, pair SuperiorVision
|
|
86
|
-
with the
|
|
82
|
+
with the [Tracktors](https://pypi.org/project/tracktors/) package. The
|
|
87
83
|
dependency points one way—Tracktors consumes tensor-native `sv.Detections`—so
|
|
88
84
|
SuperiorVision keeps its existing `sv.ByteTrack` compatibility API without a
|
|
89
85
|
circular package dependency.
|
|
@@ -98,7 +94,7 @@ circular package dependency.
|
|
|
98
94
|
- [Annotators](#annotators)
|
|
99
95
|
- [Datasets](#datasets)
|
|
100
96
|
- [🎬 Tutorials](#-tutorials)
|
|
101
|
-
- [💜 Built with
|
|
97
|
+
- [💜 Built with the API](#-built-with-the-api)
|
|
102
98
|
- [📚 Documentation](#-documentation)
|
|
103
99
|
- [🏆 Contribution](#-contribution)
|
|
104
100
|
|
|
@@ -106,11 +102,22 @@ circular package dependency.
|
|
|
106
102
|
|
|
107
103
|
## 👋 Hello
|
|
108
104
|
|
|
109
|
-
**
|
|
105
|
+
**The familiar computer-vision toolkit, now with fewer surprise trips to the
|
|
106
|
+
CPU.** From tensor-native detections to real-time zone counting, SuperiorVision
|
|
107
|
+
keeps the compatible building blocks used by Inference while letting GPUs do
|
|
108
|
+
the job they were purchased to do. 🤝
|
|
110
109
|
|
|
111
110
|
## 💻 Install
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
Install the SuperiorVision distribution in a
|
|
113
|
+
[**Python>=3.10**](https://www.python.org/) environment. The published version
|
|
114
|
+
is currently a development release, so pin it explicitly:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install superiorvision==0.30.0.dev2
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For an editable checkout:
|
|
114
121
|
|
|
115
122
|
```bash
|
|
116
123
|
git clone git@github.com:roboflow/superiorvision.git
|
|
@@ -125,9 +132,10 @@ import supervision as sv # existing Inference code
|
|
|
125
132
|
import superiorvision as sv # cheekier spelling, same API
|
|
126
133
|
```
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
The PyPI distribution is named `superiorvision`, but it intentionally provides
|
|
136
|
+
the `supervision` import namespace for drop-in compatibility. Install it as a
|
|
137
|
+
replacement for upstream Supervision, not beside it. Two distributions cannot
|
|
138
|
+
both own the same trench coat and pretend everything is fine.
|
|
131
139
|
|
|
132
140
|
The upstream documentation below remains useful for the compatible API surface.
|
|
133
141
|
|
|
@@ -135,7 +143,7 @@ The upstream documentation below remains useful for the compatible API surface.
|
|
|
135
143
|
|
|
136
144
|
### Models
|
|
137
145
|
|
|
138
|
-
|
|
146
|
+
SuperiorVision preserves Supervision's model-agnostic API. Just plug in any classification, detection, or segmentation model. The compatible [connectors](https://supervision.roboflow.com/latest/detection/core/#detections) cover popular libraries such as Ultralytics, Transformers, MMDetection, and Inference. Other integrations, including `rfdetr`, already return `sv.Detections` directly.
|
|
139
147
|
|
|
140
148
|
Install the optional dependencies for this example with `pip install pillow rfdetr`.
|
|
141
149
|
|
|
@@ -177,7 +185,7 @@ len(detections)
|
|
|
177
185
|
|
|
178
186
|
### Annotators
|
|
179
187
|
|
|
180
|
-
|
|
188
|
+
SuperiorVision retains the wide range of customizable [annotators](https://supervision.roboflow.com/latest/detection/annotators/) from its upstream API, allowing you to compose the visualization your use case needs.
|
|
181
189
|
|
|
182
190
|
```python
|
|
183
191
|
import cv2
|
|
@@ -195,7 +203,7 @@ https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-
|
|
|
195
203
|
|
|
196
204
|
### Datasets
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
SuperiorVision retains the compatible [dataset utilities](https://supervision.roboflow.com/latest/datasets/core/) for loading, splitting, merging, and saving supported formats. Dataset and image I/O remain deliberate CPU boundaries; tensor-native runtime paths do not need to cosplay as JPEG encoders.
|
|
199
207
|
|
|
200
208
|
```python
|
|
201
209
|
import supervision as sv
|
|
@@ -309,7 +317,7 @@ for path, image, annotation in ds:
|
|
|
309
317
|
|
|
310
318
|
## 🎬 Tutorials
|
|
311
319
|
|
|
312
|
-
Want to learn
|
|
320
|
+
Want to learn the compatible API? Explore the upstream [how-to guides](https://supervision.roboflow.com/develop/how_to/detect_and_annotate/), [end-to-end examples](./examples), [cheatsheet](https://roboflow.github.io/cheatsheet-supervision/), and [cookbooks](https://supervision.roboflow.com/develop/cookbooks/)!
|
|
313
321
|
|
|
314
322
|
<br/>
|
|
315
323
|
|
|
@@ -327,9 +335,9 @@ Want to learn how to use Supervision? Explore our [how-to guides](https://superv
|
|
|
327
335
|
<div><strong>Created: 11 Jan 2024</strong></div>
|
|
328
336
|
<br/>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.</p>
|
|
329
337
|
|
|
330
|
-
## 💜 Built with
|
|
338
|
+
## 💜 Built with the API
|
|
331
339
|
|
|
332
|
-
Did you build something cool using supervision? [
|
|
340
|
+
Did you build something cool using the compatible `supervision` API? [Tell us in the SuperiorVision repository.](https://github.com/roboflow/superiorvision)
|
|
333
341
|
|
|
334
342
|
https://user-images.githubusercontent.com/26109316/207858600-ee862b22-0353-440b-ad85-caa0c4777904.mp4
|
|
335
343
|
|
|
@@ -339,15 +347,15 @@ https://github.com/roboflow/supervision/assets/26109316/3ac6982f-4943-4108-9b7f-
|
|
|
339
347
|
|
|
340
348
|
## 📚 Documentation
|
|
341
349
|
|
|
342
|
-
|
|
350
|
+
The [upstream Supervision documentation](https://supervision.roboflow.com/latest/) describes the compatible API. Fork-specific tensor coverage and Inference compatibility are tracked in [this repository](https://github.com/roboflow/superiorvision) and [the Inference API surface audit](INFERENCE_API_SURFACE.md).
|
|
343
351
|
|
|
344
352
|
## 🏆 Contribution
|
|
345
353
|
|
|
346
|
-
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!
|
|
354
|
+
We love your input! Please see our [contributing guide](.github/CONTRIBUTING.md) to get started. The fork lives at [`roboflow/superiorvision`](https://github.com/roboflow/superiorvision); upstream-compatible changes may still belong in Supervision. Thank you 🙏 to all our contributors!
|
|
347
355
|
|
|
348
356
|
<p align="center">
|
|
349
|
-
<a href="https://github.com/roboflow/
|
|
350
|
-
<img src="https://contrib.rocks/image?repo=roboflow/
|
|
357
|
+
<a href="https://github.com/roboflow/superiorvision/graphs/contributors">
|
|
358
|
+
<img src="https://contrib.rocks/image?repo=roboflow/superiorvision" />
|
|
351
359
|
</a>
|
|
352
360
|
</p>
|
|
353
361
|
|
|
@@ -63,9 +63,6 @@ from supervision.detection.utils.iou_and_nms import (
|
|
|
63
63
|
from supervision.detection.utils.iou_and_nms import (
|
|
64
64
|
box_non_max_merge as numpy_box_non_max_merge,
|
|
65
65
|
)
|
|
66
|
-
from supervision.detection.utils.iou_and_nms import (
|
|
67
|
-
box_non_max_suppression as numpy_box_non_max_suppression,
|
|
68
|
-
)
|
|
69
66
|
from supervision.detection.utils.iou_and_nms import (
|
|
70
67
|
mask_non_max_merge as numpy_mask_non_max_merge,
|
|
71
68
|
)
|
|
@@ -784,7 +781,7 @@ class Detections:
|
|
|
784
781
|
@classmethod
|
|
785
782
|
def from_transformers(
|
|
786
783
|
cls,
|
|
787
|
-
transformers_results:
|
|
784
|
+
transformers_results: Any,
|
|
788
785
|
id2label: dict[int, str] | None = None,
|
|
789
786
|
) -> Detections:
|
|
790
787
|
"""
|
|
@@ -2961,7 +2958,10 @@ class Detections:
|
|
|
2961
2958
|
):
|
|
2962
2959
|
index = [int(index)]
|
|
2963
2960
|
tensor_index = _index_for_device(index, self.xyxy.device)
|
|
2964
|
-
|
|
2961
|
+
needs_host_index = isinstance(self.mask, CompactMask) or any(
|
|
2962
|
+
not isinstance(value, torch.Tensor) for value in self.data.values()
|
|
2963
|
+
)
|
|
2964
|
+
host_index = _index_for_host(index) if needs_host_index else index
|
|
2965
2965
|
data: _DetectionDataType = {}
|
|
2966
2966
|
for key, value in self.data.items():
|
|
2967
2967
|
if isinstance(value, torch.Tensor):
|
|
@@ -3329,10 +3329,7 @@ class Detections:
|
|
|
3329
3329
|
)
|
|
3330
3330
|
|
|
3331
3331
|
if self.mask is not None:
|
|
3332
|
-
if (
|
|
3333
|
-
isinstance(self.mask, torch.Tensor)
|
|
3334
|
-
and overlap_metric == OverlapMetric.IOU
|
|
3335
|
-
):
|
|
3332
|
+
if isinstance(self.mask, torch.Tensor):
|
|
3336
3333
|
indices = tensor_mask_non_max_suppression(
|
|
3337
3334
|
predictions=predictions,
|
|
3338
3335
|
masks=self.mask,
|
|
@@ -3359,18 +3356,12 @@ class Detections:
|
|
|
3359
3356
|
iou_threshold=threshold,
|
|
3360
3357
|
overlap_metric=overlap_metric,
|
|
3361
3358
|
)
|
|
3362
|
-
|
|
3359
|
+
else:
|
|
3363
3360
|
indices = tensor_box_non_max_suppression(
|
|
3364
3361
|
predictions=predictions,
|
|
3365
3362
|
iou_threshold=threshold,
|
|
3366
3363
|
overlap_metric=overlap_metric,
|
|
3367
3364
|
)
|
|
3368
|
-
else:
|
|
3369
|
-
indices = numpy_box_non_max_suppression(
|
|
3370
|
-
predictions=to_numpy(predictions),
|
|
3371
|
-
iou_threshold=threshold,
|
|
3372
|
-
overlap_metric=overlap_metric,
|
|
3373
|
-
)
|
|
3374
3365
|
|
|
3375
3366
|
return self.select(indices)
|
|
3376
3367
|
|
|
@@ -10,6 +10,40 @@ import torch
|
|
|
10
10
|
from supervision.detection.utils import box_iou_batch, mask_iou_batch
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
def _uses_intersection_over_smaller(overlap_metric: object | None) -> bool:
|
|
14
|
+
"""Return whether an overlap metric requests intersection over smaller area."""
|
|
15
|
+
value = getattr(overlap_metric, "value", overlap_metric)
|
|
16
|
+
return isinstance(value, str) and value.lower() == "ios"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _tensor_mask_overlap_batch(
|
|
20
|
+
masks: torch.Tensor, overlap_metric: object | None
|
|
21
|
+
) -> torch.Tensor:
|
|
22
|
+
"""Compute pairwise tensor mask overlap without leaving the source device."""
|
|
23
|
+
flat_masks = masks.bool().flatten(1)
|
|
24
|
+
intersection = (flat_masks[:, None] & flat_masks[None, :]).sum(dim=2)
|
|
25
|
+
areas = flat_masks.sum(dim=1)
|
|
26
|
+
if _uses_intersection_over_smaller(overlap_metric):
|
|
27
|
+
denominator = torch.minimum(areas[:, None], areas[None, :])
|
|
28
|
+
else:
|
|
29
|
+
denominator = areas[:, None] + areas[None, :] - intersection
|
|
30
|
+
return intersection / denominator.clamp(min=1)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _tensor_box_overlap_batch(
|
|
34
|
+
boxes: torch.Tensor, overlap_metric: object | None
|
|
35
|
+
) -> torch.Tensor:
|
|
36
|
+
"""Compute pairwise tensor box overlap without leaving the source device."""
|
|
37
|
+
if not _uses_intersection_over_smaller(overlap_metric):
|
|
38
|
+
return box_iou_batch(boxes, boxes)
|
|
39
|
+
areas = (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1])
|
|
40
|
+
top_left = torch.maximum(boxes[:, None, :2], boxes[:, :2])
|
|
41
|
+
bottom_right = torch.minimum(boxes[:, None, 2:], boxes[:, 2:])
|
|
42
|
+
intersection = (bottom_right - top_left).clamp(min=0).prod(dim=2)
|
|
43
|
+
denominator = torch.minimum(areas[:, None], areas[None, :])
|
|
44
|
+
return torch.nan_to_num(intersection / denominator)
|
|
45
|
+
|
|
46
|
+
|
|
13
47
|
def resize_masks(masks: np.ndarray, max_dimension: int = 640) -> np.ndarray:
|
|
14
48
|
"""
|
|
15
49
|
Resize all masks in the array to have a maximum dimension of max_dimension,
|
|
@@ -86,16 +120,15 @@ def mask_non_max_suppression(
|
|
|
86
120
|
# Pairwise mask IoU without leaving the source device. This is intentionally
|
|
87
121
|
# exact; callers wanting a reduced-resolution approximation can downsample
|
|
88
122
|
# the masks before constructing Detections.
|
|
89
|
-
|
|
90
|
-
intersection = (flat_masks[:, None] & flat_masks[None, :]).sum(dim=2)
|
|
91
|
-
areas = flat_masks.sum(dim=1)
|
|
92
|
-
ious = intersection / (areas[:, None] + areas[None, :] - intersection).clamp(min=1)
|
|
123
|
+
ious = _tensor_mask_overlap_batch(sorted_masks, overlap_metric)
|
|
93
124
|
categories = sorted_predictions[:, 5]
|
|
94
125
|
keep = torch.ones(rows, dtype=torch.bool, device=predictions.device)
|
|
95
126
|
for index in range(rows):
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
127
|
+
suppress = (
|
|
128
|
+
(ious[index] > iou_threshold)
|
|
129
|
+
& (categories == categories[index])
|
|
130
|
+
& keep[index]
|
|
131
|
+
)
|
|
99
132
|
suppress[index] = False
|
|
100
133
|
keep &= ~suppress
|
|
101
134
|
output = torch.zeros(rows, dtype=torch.bool, device=predictions.device)
|
|
@@ -159,12 +192,14 @@ def box_non_max_suppression(
|
|
|
159
192
|
sort_index = torch.argsort(predictions[:, 4], descending=True)
|
|
160
193
|
sorted_predictions = predictions[sort_index]
|
|
161
194
|
boxes, categories = sorted_predictions[:, :4], sorted_predictions[:, 5]
|
|
162
|
-
ious =
|
|
195
|
+
ious = _tensor_box_overlap_batch(boxes, overlap_metric)
|
|
163
196
|
keep = torch.ones(rows, dtype=torch.bool, device=predictions.device)
|
|
164
197
|
for index in range(rows):
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
198
|
+
suppress = (
|
|
199
|
+
(ious[index] > iou_threshold)
|
|
200
|
+
& (categories == categories[index])
|
|
201
|
+
& keep[index]
|
|
202
|
+
)
|
|
168
203
|
suppress[index] = False
|
|
169
204
|
keep &= ~suppress
|
|
170
205
|
output = torch.zeros(rows, dtype=torch.bool, device=predictions.device)
|