From 0f56a405c6910ba0c54d7f34126aa8c968464a6d Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 16 Jul 2025 01:04:51 +0200 Subject: [PATCH] updates before `supervision-0.26.0` release --- docs/changelog.md | 129 ++++++++++++++++++++++------------- docs/deprecated.md | 32 +++------ docs/detection/annotators.md | 30 ++++---- docs/keypoint/core.md | 1 + 4 files changed, 106 insertions(+), 86 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 6399df0b..2f380095 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -8,67 +8,65 @@ !!! info "Tip" Supervision’s documentation theme now has a fresh look that is consistent with the documentations of all Roboflow open-source projects. ([#1858](https://github.com/roboflow/supervision/pull/1858)) -- Added [#1774](https://github.com/roboflow/supervision/pull/1774): Support for IOS overlap metric (a region-overlap score between two shapes that indicates how much of the smaller object is covered by the bigger one) for `sv.Detections.with_nms` and `sv.Detections.with_nmm`, `sv.box_iou_batch`, and `sv.mask_iou_batch`. - - ```python - import cv2 - import supervision as sv - from inference import get_model - - model = get_model(model_id="yolov11m-seg-640") - image = cv2.imread("") - results = model.infer(image)[0] - detections = sv.Detections.from_inference(results) - detections = detections.with_nmm(overlap_metric=sv.OverlapMetric.IOU) - ``` - -- Added [#1874](https://github.com/roboflow/supervision/pull/1874): `sv.box_iou` that efficiently computes the Intersection over Union (IoU) between two individual bounding boxes. - -- Added [#1816](https://github.com/roboflow/supervision/pull/1816): Support for frame limitations and progress bar in `sv.process_video`. +- Added [#1774](https://github.com/roboflow/supervision/pull/1774): Support for the IOS (Intersection over Smallest) overlap metric that measures how much of the smaller object is covered by the larger one in [`sv.Detections.with_nms`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.with_nms), [`sv.Detections.with_nmm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.with_nmm), [`sv.box_iou_batch`](https://supervision.roboflow.com/0.26.0/detection/utils/iou_and_nms/#supervision.detection.utils.iou_and_nms.box_iou_batch), and [`sv.mask_iou_batch`](https://supervision.roboflow.com/0.26.0/detection/utils/iou_and_nms/#supervision.detection.utils.iou_and_nms.mask_iou_batch). ```python import numpy as np import supervision as sv - from inference import get_model - - model = get_model("yolov11m-640") - box_annotator = sv.BoxAnnotator() - - def callback(frame: np.ndarray, _: int) -> np.ndarray: - results = model.infer(frame,verbose=False)[0] - detections = sv.Detections.from_inference(results) - return box_annotator.annotate(frame.copy(), detections=detections) - - sv.process_video( - source_path="", - target_path="", - callback=callback, - max_frames=100, - show_progress=True, + + boxes_true = np.array([ + [100, 100, 200, 200], + [300, 300, 400, 400] + ]) + boxes_detection = np.array([ + [150, 150, 250, 250], + [320, 320, 420, 420] + ]) + + sv.box_iou_batch( + boxes_true=boxes_true, + boxes_detection=boxes_detection, + overlap_metric=sv.OverlapMetric.IOU ) + + # array([[0.14285714, 0. ], + # [0. , 0.47058824]]) + + sv.box_iou_batch( + boxes_true=boxes_true, + boxes_detection=boxes_detection, + overlap_metric=sv.OverlapMetric.IOS + ) + + # array([[0.25, 0. ], + # [0. , 0.64]]) ``` -- Added [#1788](https://github.com/roboflow/supervision/pull/1788): Support for creating `sv.KeyPoints` objects using [ViTPose](https://huggingface.co/docs/transformers/en/model_doc/vitpose) and [ViTPose++](https://huggingface.co/docs/transformers/en/model_doc/vitpose#vitpose-models) inference results from [Transformers](https://huggingface.co/docs/transformers/index). +- Added [#1874](https://github.com/roboflow/supervision/pull/1874): [`sv.box_iou`](https://supervision.roboflow.com/0.26.0/detection/utils/iou_and_nms/#supervision.detection.utils.iou_and_nms.box_iou) that efficiently computes the Intersection over Union (IoU) between two individual bounding boxes. -- Added [#1823](https://github.com/roboflow/supervision/pull/1823): `sv.xyxy_to_xcycarh` function to convert bounding box coordinates from `(x_min, y_min, x_max, y_max)` into measurement space to format `(center x, center y, aspect ratio, height)`, where the aspect ratio is `width / height`. +- Added [#1816](https://github.com/roboflow/supervision/pull/1816): Support for frame limitations and progress bar in [`sv.process_video`](https://supervision.roboflow.com/0.26.0/utils/video/#supervision.utils.video.process_video). -- Added [#1788](https://github.com/roboflow/supervision/pull/1788): `sv.xyxy_to_xywh` function to convert bounding box coordinates from `(x_min, y_min, x_max, y_max)` format to `(x, y, width, height)` format. +- Added [#1788](https://github.com/roboflow/supervision/pull/1788): Support for creating [`sv.KeyPoints`](https://supervision.roboflow.com/0.26.0/keypoint/core/#supervision.keypoint.core.KeyPoints) objects from [ViTPose](https://huggingface.co/docs/transformers/en/model_doc/vitpose) and [ViTPose++](https://huggingface.co/docs/transformers/en/model_doc/vitpose#vitpose-models) inference results via [`sv.KeyPoints.from_transformers`](https://supervision.roboflow.com/0.26.0/keypoint/core/#supervision.keypoint.core.KeyPoints.from_transformers). -- Changed [#1820](https://github.com/roboflow/supervision/pull/1820): `sv.LabelAnnotator` now has the ability to ensure labels stay within frame boundaries using the smart_position parameter and control automatic text wrapping for long multi-line labels using the max_line_length parameter. +- Added [#1823](https://github.com/roboflow/supervision/pull/1823): [`sv.xyxy_to_xcycarh`](https://supervision.roboflow.com/0.26.0/detection/utils/converters/#supervision.detection.utils.converters.xyxy_to_xcycarh) function to convert bounding box coordinates from `(x_min, y_min, x_max, y_max)` into measurement space to format `(center x, center y, aspect ratio, height)`, where the aspect ratio is `width / height`. -- Changed [#1825](https://github.com/roboflow/supervision/pull/1825): `sv.LabelAnnotator` now supports non-string labels. +- Added [#1788](https://github.com/roboflow/supervision/pull/1788): [`sv.xyxy_to_xywh`](https://supervision.roboflow.com/0.26.0/detection/utils/converters/#supervision.detection.utils.converters.xyxy_to_xywh) function to convert bounding box coordinates from `(x_min, y_min, x_max, y_max)` format to `(x, y, width, height)` format. -- Changed [#1792](https://github.com/roboflow/supervision/pull/1792): `sv.Detections.from_vlm` now supports bounding boxes and segmentation masks response from [Google Gemini models](https://ai.google.dev/gemini-api/docs/vision). +- Changed [#1820](https://github.com/roboflow/supervision/pull/1820): [`sv.LabelAnnotator`](https://supervision.roboflow.com/0.26.0/detection/annotators/#supervision.annotators.core.LabelAnnotator) now supports the `smart_position` parameter to automatically keep labels within frame boundaries, and the `max_line_length` parameter to control text wrapping for long or multi-line labels. + +- Changed [#1825](https://github.com/roboflow/supervision/pull/1825): [`sv.LabelAnnotator`](https://supervision.roboflow.com/0.26.0/detection/annotators/#supervision.annotators.core.LabelAnnotator) now supports non-string labels. + +- Changed [#1792](https://github.com/roboflow/supervision/pull/1792): [`sv.Detections.from_vlm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.from_vlm) now supports parsing bounding boxes and segmentation masks from responses generated by [Google Gemini models](https://ai.google.dev/gemini-api/docs/vision). ```python import supervision as sv - gemini_response_text = \"\"\"```json + gemini_response_text = """```json [ {"box_2d": [543, 40, 728, 200], "label": "cat", "id": 1}, {"box_2d": [653, 352, 820, 522], "label": "dog", "id": 2} ] - ```\"\"\" + ```""" detections = sv.Detections.from_vlm( sv.VLM.GOOGLE_GEMINI_2_5, @@ -76,9 +74,18 @@ resolution_wh=(1000, 1000), classes=['cat', 'dog'], ) + + detections.xyxy + # array([[543., 40., 728., 200.], [653., 352., 820., 522.]]) + + detections.data + # {'class_name': array(['cat', 'dog'], dtype='Nov 12, 2024 diff --git a/docs/deprecated.md b/docs/deprecated.md index 90c7a79c..47ebcc16 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -7,29 +7,19 @@ status: deprecated These features are phased out due to better alternatives or potential issues in future versions. Deprecated functionalities are supported for **five subsequent releases**, providing time for users to transition to updated methods. -- Constructing [`DetectionDataset`](https://supervision.roboflow.com/latest/datasets/core/#supervision.dataset.core.DetectionDataset) and [`ClassificationDataset`](https://supervision.roboflow.com/latest/datasets/core/#supervision.dataset.core.ClassificationDataset) with parameter `images` as `Dict[str, np.ndarray]` will be removed in `supervision-0.26.0`. Please pass a list of paths `List[str]` instead. - -- The `DetectionDataset.images` property will be removed in `supervision-0.26.0`. Please loop over images with `for path, image, annotation in dataset:`, as that does not require loading all images into memory. - -- `BoundingBoxAnnotator` has been renamed to `BoxAnnotator` after the old implementation of [`BoxAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.BoxAnnotator) has been removed. `BoundingBoxAnnotator` will be removed in `supervision-0.26.0`. - `overlap_filter_strategy` in [`InferenceSlicer.__init__`](https://supervision.roboflow.com/latest/detection/tools/inference_slicer/) is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_strategy` instead. - - `overlap_ratio_wh` in [`InferenceSlicer.__init__`](https://supervision.roboflow.com/latest/detection/tools/inference_slicer/) is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_wh` instead. +- `sv.LMM` enum is deprecated and will be removed in `supervision-0.31.0`. Use `sv.VLM` instead. +- [`sv.Detections.from_lmm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.from_lmm) property is deprecated and will be removed in `supervision-0.31.0`. Use [`sv.Detections.from_vlm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.from_vlm) instead. # Removed ### 0.26.0 - The `sv.DetectionDataset.images` property has been removed in `supervision-0.26.0`. Please loop over images with `for path, image, annotation in dataset:`, as that does not require loading all images into memory. Also, constructing `sv.DetectionDataset` with parameter `images` as `Dict[str, np.ndarray]` is deprecated and has been removed in `supervision-0.26.0`. Please pass a list of paths `List[str]` instead. - - The name `sv.BoundingBoxAnnotator` is deprecated and has been removed in `supervision-0.26.0`. It has been renamed to [`sv.BoxAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.BoxAnnotator). -- `supervision-0.26.0` drops `python3.8` support and upgrade all codes to `python3.9` syntax style. - -### 0.25.0 - -No removals in this version! ### 0.24.0 @@ -43,12 +33,12 @@ No removals in this version! ### 0.22.0 -- `Detections.from_roboflow` is removed as of `supervision-0.22.0`. Use [`Detections.from_inference`](detection/core.md/#supervision.detection.core.Detections.from_inference) instead. -- The method `Color.white()` was removed as of `supervision-0.22.0`. Use the constant `Color.WHITE` instead. -- The method `Color.black()` was removed as of `supervision-0.22.0`. Use the constant `Color.BLACK` instead. -- The method `Color.red()` was removed as of `supervision-0.22.0`. Use the constant `Color.RED` instead. -- The method `Color.green()` was removed as of `supervision-0.22.0`. Use the constant `Color.GREEN` instead. -- The method `Color.blue()` was removed as of `supervision-0.22.0`. Use the constant `Color.BLUE` instead. -- The method `ColorPalette.default()` was removed as of `supervision-0.22.0`. Use the constant [`ColorPalette.DEFAULT`](/utils/draw/#supervision.draw.color.ColorPalette.DEFAULT) instead. -- `BoxAnnotator` was removed as of `supervision-0.22.0`, however `BoundingBoxAnnotator` was immediately renamed to `BoxAnnotator`. Use [`BoxAnnotator`](detection/annotators.md/#supervision.annotators.core.BoxAnnotator) and [`LabelAnnotator`](detection/annotators.md/#supervision.annotators.core.LabelAnnotator) instead of the old `BoxAnnotator`. -- The method `FPSMonitor.__call__` was removed as of `supervision-0.22.0`. Use the attribute [`FPSMonitor.fps`](utils/video.md/#supervision.utils.video.FPSMonitor.fps) instead. +- `sv.Detections.from_roboflow` is removed as of `supervision-0.22.0`. Use [`Detections.from_inference`](detection/core.md/#supervision.detection.core.Detections.from_inference) instead. +- The method `sv.Color.white()` was removed as of `supervision-0.22.0`. Use the constant `sv.Color.WHITE` instead. +- The method `sv.Color.black()` was removed as of `supervision-0.22.0`. Use the constant `sv.Color.BLACK` instead. +- The method `sv.Color.red()` was removed as of `supervision-0.22.0`. Use the constant `sv.Color.RED` instead. +- The method `sv.Color.green()` was removed as of `supervision-0.22.0`. Use the constant `sv.Color.GREEN` instead. +- The method `sv.Color.blue()` was removed as of `supervision-0.22.0`. Use the constant `sv.Color.BLUE` instead. +- The method `sv.ColorPalette.default()` was removed as of `supervision-0.22.0`. Use the constant [`ColorPalette.DEFAULT`](/utils/draw/#supervision.draw.color.ColorPalette.DEFAULT) instead. +- `sv.BoxAnnotator` was removed as of `supervision-0.22.0`, however `sv.BoundingBoxAnnotator` was immediately renamed to `sv.BoxAnnotator`. Use [`BoxAnnotator`](detection/annotators.md/#supervision.annotators.core.BoxAnnotator) and [`LabelAnnotator`](detection/annotators.md/#supervision.annotators.core.LabelAnnotator) instead of the old `sv.BoxAnnotator`. +- The method `sv.FPSMonitor.__call__` was removed as of `supervision-0.22.0`. Use the attribute [`sv.FPSMonitor.fps`](utils/video.md/#supervision.utils.video.FPSMonitor.fps) instead. diff --git a/docs/detection/annotators.md b/docs/detection/annotators.md index afe64ace..938c49ff 100644 --- a/docs/detection/annotators.md +++ b/docs/detection/annotators.md @@ -28,28 +28,26 @@ Annotators accept detections and apply box or mask visualizations to the detecti - + === "BoxCorner" diff --git a/docs/keypoint/core.md b/docs/keypoint/core.md index 6f42c254..7354baba 100644 --- a/docs/keypoint/core.md +++ b/docs/keypoint/core.md @@ -1,5 +1,6 @@ --- comments: true +status: new --- # Keypoint Detection