Skip to content

Commit

Permalink
Merge pull request #1258 from roboflow/develop
Browse files Browse the repository at this point in the history
`supervision-0.21.0` release
  • Loading branch information
SkalskiP authored Jun 6, 2024
2 parents f7f40f0 + 0200fd3 commit e50c761
Show file tree
Hide file tree
Showing 70 changed files with 4,640 additions and 1,029 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
rev: v0.4.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
80 changes: 80 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,83 @@
### 0.21.0 <small>Jun 5, 2024</small>

- 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.

- 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.

```python
import supervision as sv

paligemma_result = "<loc0256><loc0256><loc0768><loc0768> cat"
detections = sv.Detections.from_lmm(
sv.LMM.PALIGEMMA,
paligemma_result,
resolution_wh=(1000, 1000),
classes=['cat', 'dog']
)
detections.xyxy
# array([[250., 250., 750., 750.]])

detections.class_id
# array([0])
```

- 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.

```python
import supervision as sv

image = ...
key_points = sv.KeyPoints(...)

edge_annotator = sv.EdgeAnnotator(
color=sv.Color.GREEN,
thickness=5
)
annotated_frame = edge_annotator.annotate(
scene=image.copy(),
key_points=key_points
)
```

- 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.

- 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.

- 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.

- 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`).

- 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.

```python
import cv2
import numpy as np
import supervision as sv
from inference import get_model

model = get_model(model_id="yolov8x-seg-640")
image = cv2.imread(<SOURCE_IMAGE_PATH>)

def callback(image_slice: np.ndarray) -> sv.Detections:
results = model.infer(image_slice)[0]
return sv.Detections.from_inference(results)

slicer = sv.InferenceSlicer(callback = callback)
detections = slicer(image)

mask_annotator = sv.MaskAnnotator()
label_annotator = sv.LabelAnnotator()

annotated_image = mask_annotator.annotate(
scene=image, detections=detections)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections)
```

- 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.

- 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.

### 0.20.0 <small>April 24, 2024</small>

- 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.
Expand Down
1 change: 0 additions & 1 deletion docs/cookbooks.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
template: cookbooks.html
comments: true
status: new
hide:
- navigation
- toc
Expand Down
1 change: 1 addition & 0 deletions docs/datasets.md → docs/datasets/core.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
comments: true
status: new
---

# Datasets
Expand Down
18 changes: 18 additions & 0 deletions docs/datasets/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
comments: true
status: new
---

# Datasets Utils

<div class="md-typeset">
<h2><a href="#supervision.dataset.utils.rle_to_mask">rle_to_mask</a></h2>
</div>

:::supervision.dataset.utils.rle_to_mask

<div class="md-typeset">
<h2><a href="#supervision.dataset.utils.mask_to_rle">mask_to_rle</a></h2>
</div>

:::supervision.dataset.utils.mask_to_rle
38 changes: 37 additions & 1 deletion docs/detection/annotators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
comments: true
status: new
---

# Annotators
Expand Down Expand Up @@ -285,6 +284,37 @@ status: new

</div>

=== "RichLabel"

```python
import supervision as sv

image = ...
detections = sv.Detections(...)

labels = [
f"{class_name} {confidence:.2f}"
for class_name, confidence
in zip(detections['class_name'], detections.confidence)
]

rich_label_annotator = sv.RichLabelAnnotator(
font_path=".../font.ttf",
text_position=sv.Position.CENTER
)
annotated_frame = label_annotator.annotate(
scene=image.copy(),
detections=detections,
labels=labels
)
```

<div class="result" markdown>

![label-annotator-example](https://media.roboflow.com/supervision-annotator-examples/label-annotator-example-purple.png){ align=center width="800" }

</div>

=== "Crop"

```python
Expand Down Expand Up @@ -492,6 +522,12 @@ status: new

:::supervision.annotators.core.LabelAnnotator

<div class="md-typeset">
<h2><a href="#supervision.annotators.core.RichLabelAnnotator">RichLabelAnnotator</a></h2>
</div>

:::supervision.annotators.core.RichLabelAnnotator

<div class="md-typeset">
<h2><a href="#supervision.annotators.core.BlurAnnotator">BlurAnnotator</a></h2>
</div>
Expand Down
30 changes: 30 additions & 0 deletions docs/detection/double_detection_filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
comments: true
status: new
---

# Double Detection Filter

<div class="md-typeset">
<h2><a href="#supervision.detection.overlap_filter.OverlapFilter">OverlapFilter</a></h2>
</div>

:::supervision.detection.overlap_filter.OverlapFilter

<div class="md-typeset">
<h2><a href="#supervision.detection.overlap_filter.box_non_max_suppression">box_non_max_suppression</a></h2>
</div>

:::supervision.detection.overlap_filter.box_non_max_suppression

<div class="md-typeset">
<h2><a href="#supervision.detection.overlap_filter.mask_non_max_suppression">mask_non_max_suppression</a></h2>
</div>

:::supervision.detection.overlap_filter.mask_non_max_suppression

<div class="md-typeset">
<h2><a href="#supervision.detection.overlap_filter.box_non_max_merge">box_non_max_merge</a></h2>
</div>

:::supervision.detection.overlap_filter.box_non_max_merge
1 change: 1 addition & 0 deletions docs/detection/tools/inference_slicer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
comments: true
status: new
---

# InferenceSlicer
Expand Down
1 change: 1 addition & 0 deletions docs/detection/tools/line_zone.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
comments: true
status: new
---

<div class="md-typeset">
Expand Down
1 change: 0 additions & 1 deletion docs/detection/tools/save_detections.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
comments: true
status: new
---

# Save Detections
Expand Down
43 changes: 30 additions & 13 deletions docs/detection/utils.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
comments: true
status: new
---

# Detection Utils
Expand All @@ -17,18 +16,6 @@ status: new

:::supervision.detection.utils.mask_iou_batch

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.box_non_max_suppression">box_non_max_suppression</a></h2>
</div>

:::supervision.detection.utils.box_non_max_suppression

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.mask_non_max_suppression">mask_non_max_suppression</a></h2>
</div>

:::supervision.detection.utils.mask_non_max_suppression

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.polygon_to_mask">polygon_to_mask</a></h2>
</div>
Expand Down Expand Up @@ -65,8 +52,38 @@ status: new

:::supervision.detection.utils.move_boxes

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.move_masks">move_masks</a></h2>
</div>

:::supervision.detection.utils.move_masks

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.scale_boxes">scale_boxes</a></h2>
</div>

:::supervision.detection.utils.scale_boxes

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.clip_boxes">clip_boxes</a></h2>
</div>

:::supervision.detection.utils.clip_boxes

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.pad_boxes">pad_boxes</a></h2>
</div>

:::supervision.detection.utils.pad_boxes

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.contains_holes">contains_holes</a></h2>
</div>

:::supervision.detection.utils.contains_holes

<div class="md-typeset">
<h2><a href="#supervision.detection.utils.contains_multiple_segments">contains_multiple_segments</a></h2>
</div>

:::supervision.detection.utils.contains_multiple_segments
1 change: 0 additions & 1 deletion docs/how_to/detect_and_annotate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
comments: true
status: new
---

# Detect and Annotate
Expand Down
Loading

0 comments on commit e50c761

Please sign in to comment.