Skip to content

Commit e50c761

Browse files
authored
Merge pull request #1258 from roboflow/develop
`supervision-0.21.0` release
2 parents f7f40f0 + 0200fd3 commit e50c761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4640
-1029
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ repos:
4545

4646

4747
- repo: https://github.com/astral-sh/ruff-pre-commit
48-
rev: v0.4.1
48+
rev: v0.4.7
4949
hooks:
5050
- id: ruff
5151
args: [--fix, --exit-non-zero-on-fix]

docs/changelog.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,83 @@
1+
### 0.21.0 <small>Jun 5, 2024</small>
2+
3+
- Added [#500](https://github.com/roboflow/supervision/pull/500): [`sv.Detections.with_nmm`](https://supervision.roboflow.com/develop/detection/core/#supervision.detection.core.Detections.with_nmm) to perform non-maximum merging on the current set of object detections.
4+
5+
- Added [#1221](https://github.com/roboflow/supervision/pull/1221): [`sv.Detections.from_lmm`](https://supervision.roboflow.com/develop/detection/core/#supervision.detection.core.Detections.from_lmm) allowing to parse Large Multimodal Model (LMM) text result into [`sv.Detections`](https://supervision.roboflow.com/develop/detection/core/) object. For now `from_lmm` supports only [PaliGemma](https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/how-to-finetune-paligemma-on-detection-dataset.ipynb) result parsing.
6+
7+
```python
8+
import supervision as sv
9+
10+
paligemma_result = "<loc0256><loc0256><loc0768><loc0768> cat"
11+
detections = sv.Detections.from_lmm(
12+
sv.LMM.PALIGEMMA,
13+
paligemma_result,
14+
resolution_wh=(1000, 1000),
15+
classes=['cat', 'dog']
16+
)
17+
detections.xyxy
18+
# array([[250., 250., 750., 750.]])
19+
20+
detections.class_id
21+
# array([0])
22+
```
23+
24+
- Added [#1236](https://github.com/roboflow/supervision/pull/1236): [`sv.VertexLabelAnnotator`](https://supervision.roboflow.com/develop/keypoint/annotators/#supervision.keypoint.annotators.EdgeAnnotator.annotate) allowing to annotate every vertex of a keypoint skeleton with custom text and color.
25+
26+
```python
27+
import supervision as sv
28+
29+
image = ...
30+
key_points = sv.KeyPoints(...)
31+
32+
edge_annotator = sv.EdgeAnnotator(
33+
color=sv.Color.GREEN,
34+
thickness=5
35+
)
36+
annotated_frame = edge_annotator.annotate(
37+
scene=image.copy(),
38+
key_points=key_points
39+
)
40+
```
41+
42+
- Added [#1147](https://github.com/roboflow/supervision/pull/1147): [`sv.KeyPoints.from_inference`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints.from_inference) allowing to create [`sv.KeyPoints`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints) from [Inference](https://github.com/roboflow/inference) result.
43+
44+
- Added [#1138](https://github.com/roboflow/supervision/pull/1138): [`sv.KeyPoints.from_yolo_nas`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints.from_yolo_nas) allowing to create [`sv.KeyPoints`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints) from [YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) result.
45+
46+
- Added [#1163](https://github.com/roboflow/supervision/pull/1163): [`sv.mask_to_rle`](https://supervision.roboflow.com/develop/datasets/utils/#supervision.dataset.utils.rle_to_mask) and [`sv.rle_to_mask`](https://supervision.roboflow.com/develop/datasets/utils/#supervision.dataset.utils.rle_to_mask) allowing for easy conversion between mask and rle formats.
47+
48+
- Changed [#1236](https://github.com/roboflow/supervision/pull/1236): [`sv.InferenceSlicer`](https://supervision.roboflow.com/develop/detection/tools/inference_slicer/) allowing to select overlap filtering strategy (`NONE`, `NON_MAX_SUPPRESSION` and `NON_MAX_MERGE`).
49+
50+
- Changed [#1178](https://github.com/roboflow/supervision/pull/1178): [`sv.InferenceSlicer`](https://supervision.roboflow.com/develop/detection/tools/inference_slicer/) adding instance segmentation model support.
51+
52+
```python
53+
import cv2
54+
import numpy as np
55+
import supervision as sv
56+
from inference import get_model
57+
58+
model = get_model(model_id="yolov8x-seg-640")
59+
image = cv2.imread(<SOURCE_IMAGE_PATH>)
60+
61+
def callback(image_slice: np.ndarray) -> sv.Detections:
62+
results = model.infer(image_slice)[0]
63+
return sv.Detections.from_inference(results)
64+
65+
slicer = sv.InferenceSlicer(callback = callback)
66+
detections = slicer(image)
67+
68+
mask_annotator = sv.MaskAnnotator()
69+
label_annotator = sv.LabelAnnotator()
70+
71+
annotated_image = mask_annotator.annotate(
72+
scene=image, detections=detections)
73+
annotated_image = label_annotator.annotate(
74+
scene=annotated_image, detections=detections)
75+
```
76+
77+
- Changed [#1228](https://github.com/roboflow/supervision/pull/1228): [`sv.LineZone`](https://supervision.roboflow.com/develop/detection/tools/line_zone/) making it 10-20 times faster, depending on the use case.
78+
79+
- Changed [#1163](https://github.com/roboflow/supervision/pull/1163): [`sv.DetectionDataset.from_coco`](https://supervision.roboflow.com/develop/datasets/core/#supervision.dataset.core.DetectionDataset.from_coco) and [`sv.DetectionDataset.as_coco`](https://supervision.roboflow.com/develop/datasets/core/#supervision.dataset.core.DetectionDataset.as_coco) adding support for run-length encoding (RLE) mask format.
80+
181
### 0.20.0 <small>April 24, 2024</small>
282

383
- Added [#1128](https://github.com/roboflow/supervision/pull/1128): [`sv.KeyPoints`](/0.20.0/keypoint/core/#supervision.keypoint.core.KeyPoints) to provide initial support for pose estimation and broader keypoint detection models.

docs/cookbooks.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
template: cookbooks.html
33
comments: true
4-
status: new
54
hide:
65
- navigation
76
- toc

docs/datasets.md renamed to docs/datasets/core.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
comments: true
3+
status: new
34
---
45

56
# Datasets

docs/datasets/utils.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
comments: true
3+
status: new
4+
---
5+
6+
# Datasets Utils
7+
8+
<div class="md-typeset">
9+
<h2><a href="#supervision.dataset.utils.rle_to_mask">rle_to_mask</a></h2>
10+
</div>
11+
12+
:::supervision.dataset.utils.rle_to_mask
13+
14+
<div class="md-typeset">
15+
<h2><a href="#supervision.dataset.utils.mask_to_rle">mask_to_rle</a></h2>
16+
</div>
17+
18+
:::supervision.dataset.utils.mask_to_rle

docs/detection/annotators.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
comments: true
3-
status: new
43
---
54

65
# Annotators
@@ -285,6 +284,37 @@ status: new
285284

286285
</div>
287286

287+
=== "RichLabel"
288+
289+
```python
290+
import supervision as sv
291+
292+
image = ...
293+
detections = sv.Detections(...)
294+
295+
labels = [
296+
f"{class_name} {confidence:.2f}"
297+
for class_name, confidence
298+
in zip(detections['class_name'], detections.confidence)
299+
]
300+
301+
rich_label_annotator = sv.RichLabelAnnotator(
302+
font_path=".../font.ttf",
303+
text_position=sv.Position.CENTER
304+
)
305+
annotated_frame = label_annotator.annotate(
306+
scene=image.copy(),
307+
detections=detections,
308+
labels=labels
309+
)
310+
```
311+
312+
<div class="result" markdown>
313+
314+
![label-annotator-example](https://media.roboflow.com/supervision-annotator-examples/label-annotator-example-purple.png){ align=center width="800" }
315+
316+
</div>
317+
288318
=== "Crop"
289319

290320
```python
@@ -492,6 +522,12 @@ status: new
492522

493523
:::supervision.annotators.core.LabelAnnotator
494524

525+
<div class="md-typeset">
526+
<h2><a href="#supervision.annotators.core.RichLabelAnnotator">RichLabelAnnotator</a></h2>
527+
</div>
528+
529+
:::supervision.annotators.core.RichLabelAnnotator
530+
495531
<div class="md-typeset">
496532
<h2><a href="#supervision.annotators.core.BlurAnnotator">BlurAnnotator</a></h2>
497533
</div>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
comments: true
3+
status: new
4+
---
5+
6+
# Double Detection Filter
7+
8+
<div class="md-typeset">
9+
<h2><a href="#supervision.detection.overlap_filter.OverlapFilter">OverlapFilter</a></h2>
10+
</div>
11+
12+
:::supervision.detection.overlap_filter.OverlapFilter
13+
14+
<div class="md-typeset">
15+
<h2><a href="#supervision.detection.overlap_filter.box_non_max_suppression">box_non_max_suppression</a></h2>
16+
</div>
17+
18+
:::supervision.detection.overlap_filter.box_non_max_suppression
19+
20+
<div class="md-typeset">
21+
<h2><a href="#supervision.detection.overlap_filter.mask_non_max_suppression">mask_non_max_suppression</a></h2>
22+
</div>
23+
24+
:::supervision.detection.overlap_filter.mask_non_max_suppression
25+
26+
<div class="md-typeset">
27+
<h2><a href="#supervision.detection.overlap_filter.box_non_max_merge">box_non_max_merge</a></h2>
28+
</div>
29+
30+
:::supervision.detection.overlap_filter.box_non_max_merge

docs/detection/tools/inference_slicer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
comments: true
3+
status: new
34
---
45

56
# InferenceSlicer

docs/detection/tools/line_zone.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
comments: true
3+
status: new
34
---
45

56
<div class="md-typeset">

docs/detection/tools/save_detections.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
comments: true
3-
status: new
43
---
54

65
# Save Detections

0 commit comments

Comments
 (0)