Skip to content

Commit c5f92a5

Browse files
authored
Merge pull request #1132 from roboflow/docs/supervision-0.20.0-changelog
docs/supervision 0.20.0 change log
2 parents b084091 + d6a59cb commit c5f92a5

File tree

6 files changed

+82
-15
lines changed

6 files changed

+82
-15
lines changed

docs/changelog.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
### 0.20.0 <small>April 24, 2024</small>
2+
3+
- 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.
4+
5+
- Added [#1128](https://github.com/roboflow/supervision/pull/1128): [`sv.EdgeAnnotator`](/0.20.0/keypoint/annotators/#supervision.keypoint.annotators.EdgeAnnotator) and [`sv.VertexAnnotator`](/0.20.0/keypoint/annotators/#supervision.keypoint.annotators.VertexAnnotator) to enable rendering of results from keypoint detection models.
6+
7+
```python
8+
import cv2
9+
import supervision as sv
10+
from ultralytics import YOLO
11+
12+
image = cv2.imread(<SOURCE_IMAGE_PATH>)
13+
model = YOLO('yolov8l-pose')
14+
15+
result = model(image, verbose=False)[0]
16+
keypoints = sv.KeyPoints.from_ultralytics(result)
17+
18+
edge_annotators = sv.EdgeAnnotator(color=sv.Color.GREEN, thickness=5)
19+
annotated_image = edge_annotators.annotate(image.copy(), keypoints)
20+
```
21+
22+
- Changed [#1037](https://github.com/roboflow/supervision/pull/1037): [`sv.LabelAnnotator`](/0.20.0/annotators/#supervision.annotators.core.LabelAnnotator) by adding an additional `corner_radius` argument that allows for rounding the corners of the bounding box.
23+
24+
- Changed [#1109](https://github.com/roboflow/supervision/pull/1109): [`sv.PolygonZone`](/0.20.0/detection/tools/polygon_zone/#supervision.detection.tools.polygon_zone.PolygonZone) such that the `frame_resolution_wh` argument is no longer required to initialize `sv.PolygonZone`.
25+
26+
!!! failure "Deprecated"
27+
28+
The `frame_resolution_wh` parameter in `sv.PolygonZone` is deprecated and will be removed in `supervision-0.24.0`.
29+
30+
- Changed [#1084](https://github.com/roboflow/supervision/pull/1084): [`sv.get_polygon_center`](/0.20.0/utils/geometry/#supervision.geometry.core.utils.get_polygon_center) to calculate a more accurate polygon centroid.
31+
32+
- Changed [#1069](https://github.com/roboflow/supervision/pull/1069): [`sv.Detections.from_transformers`](/0.20.0/detection/core/#supervision.detection.core.Detections.from_transformers) by adding support for Transformers segmentation models and extract class names values.
33+
34+
```python
35+
import torch
36+
import supervision as sv
37+
from PIL import Image
38+
from transformers import DetrImageProcessor, DetrForSegmentation
39+
40+
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50-panoptic")
41+
model = DetrForSegmentation.from_pretrained("facebook/detr-resnet-50-panoptic")
42+
43+
image = Image.open(<SOURCE_IMAGE_PATH>)
44+
inputs = processor(images=image, return_tensors="pt")
45+
46+
with torch.no_grad():
47+
outputs = model(**inputs)
48+
49+
width, height = image.size
50+
target_size = torch.tensor([[height, width]])
51+
results = processor.post_process_segmentation(
52+
outputs=outputs, target_sizes=target_size)[0]
53+
detections = sv.Detections.from_transformers(results, id2label=model.config.id2label)
54+
55+
mask_annotator = sv.MaskAnnotator()
56+
label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER)
57+
58+
annotated_image = mask_annotator.annotate(
59+
scene=image, detections=detections)
60+
annotated_image = label_annotator.annotate(
61+
scene=annotated_image, detections=detections)
62+
```
63+
64+
- Fixed [#787](https://github.com/roboflow/supervision/pull/787): [`sv.ByteTrack.update_with_detections`](/0.20.0/trackers/#supervision.tracker.byte_tracker.core.ByteTrack.update_with_detections) which was removing segmentation masks while tracking. Now, `ByteTrack` can be used alongside segmentation models.
65+
166
### 0.19.0 <small>March 15, 2024</small>
267

368
- Added [#818](https://github.com/roboflow/supervision/pull/818): [`sv.CSVSink`](/0.19.0/detection/tools/save_detections/#supervision.detection.tools.csv_sink.CSVSink) allowing for the straightforward saving of image, video, or stream inference results in a `.csv` file.

docs/deprecated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ These features are phased out due to better alternatives or potential issues in
1616
- The method [`FPSMonitor.__call__`](utils/video.md/#supervision.utils.video.FPSMonitor.__call__) is deprecated and will be removed in `supervision-0.22.0`. Use the attribute [`FPSMonitor.fps`](utils/video.md/#supervision.utils.video.FPSMonitor.fps) instead.
1717
- The `track_buffer`, `track_thresh`, and `match_thresh` parameters in [`ByterTrack`](trackers.md/#supervision.tracker.byte_tracker.core.ByteTrack) are deprecated and will be removed in `supervision-0.23.0`. Use `lost_track_buffer,` `track_activation_threshold`, and `minimum_matching_threshold` instead.
1818
- The `triggering_position ` parameter in [`sv.PolygonZone`](detection/tools/polygon_zone.md/#supervision.detection.tools.polygon_zone.PolygonZone) is deprecated and will be removed in `supervision-0.23.0`. Use `triggering_anchors ` instead.
19+
- The `frame_resolution_wh ` parameter in [`sv.PolygonZone`](detection/tools/polygon_zone.md/#supervision.detection.tools.polygon_zone.PolygonZone) is deprecated and will be removed in `supervision-0.24.0`.

docs/utils/geometry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
comments: true
33
---
44

5+
<div class="md-typeset">
6+
<h2><a href="#supervision.geometry.core.utils.get_polygon_center">get_polygon_center</a></h2>
7+
</div>
8+
9+
:::supervision.geometry.utils.get_polygon_center
10+
511
<div class="md-typeset">
612
<h2><a href="#supervision.geometry.core.Position">Position</a></h2>
713
</div>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "supervision"
3-
version = "0.20.0rc2"
3+
version = "0.20.0"
44
description = "A set of easy-to-use utils that will come in handy in any Computer Vision project"
55
authors = ["Piotr Skalski <piotr.skalski92@gmail.com>"]
66
maintainers = ["Piotr Skalski <piotr.skalski92@gmail.com>"]

supervision/detection/annotate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from supervision.utils.internal import deprecated
1010

1111

12-
@deprecated(
13-
"`BoxAnnotator` is deprecated and will be removed in "
14-
"`supervision-0.22.0`. Use `BoundingBoxAnnotator` and `LabelAnnotator` instead"
15-
)
1612
class BoxAnnotator:
1713
"""
1814
A class for drawing bounding boxes on an image using detections provided.
@@ -46,6 +42,10 @@ def __init__(
4642
self.text_thickness: int = text_thickness
4743
self.text_padding: int = text_padding
4844

45+
@deprecated(
46+
"`BoxAnnotator` is deprecated and will be removed in "
47+
"`supervision-0.22.0`. Use `BoundingBoxAnnotator` and `LabelAnnotator` instead"
48+
)
4949
@convert_for_annotation_method
5050
def annotate(
5151
self,

supervision/geometry/utils.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66
def get_polygon_center(polygon: np.ndarray) -> Point:
77
"""
8-
Calculate the center of a polygon.
9-
10-
This function takes in a polygon as a 2-dimensional numpy ndarray and
11-
returns the center of the polygon as a Point object.
12-
13-
The center is calculated as the center
8+
Calculate the center of a polygon. The center is calculated as the center
149
of the solid figure formed by the points of the polygon
1510
1611
Parameters:
@@ -23,12 +18,12 @@ def get_polygon_center(polygon: np.ndarray) -> Point:
2318
2419
Examples:
2520
```python
26-
from supervision.geometry.utils import get_polygon_center
2721
import numpy as np
22+
import supervision as sv
2823
29-
vertices = np.array([[0, 0], [0, 2], [2, 2], [2, 0]])
30-
get_polygon_center(vertices)
31-
Point(x=1, y=1)
24+
polygon = np.array([[0, 0], [0, 2], [2, 2], [2, 0]])
25+
sv.get_polygon_center(polygon=polygon)
26+
# Point(x=1, y=1)
3227
```
3328
"""
3429

0 commit comments

Comments
 (0)