ITADN
roboflow/supervision

版本发布 8

supervision-0.27.0.post0.27.0.post2
? · 2026-03-14

**Full Changelog**: https://github.com/roboflow/supervision/compare/0.27.0...0.27.0.post2

supervision-0.26.00.26.0
? · 2025-07-16

> [!WARNING] > `supervision-0.26.0` drops `python3.8` support and upgrade all codes to `python3.9` syntax style. > [!TIP] > Our [docs page](https://supervision.roboflow.com/) 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 - Added 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). ([#1788](https://github.com/roboflow/supervision/pull/1788)) https://github.com/user-attachments/assets/f1917032-29d8-4b88-b871-65c2e28a756e - Added 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). ([#1774](https://github.com/roboflow/supervision/pull/1774)) ```python import numpy as np import supervision as sv 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 [`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. ([#1874](https://github.com/roboflow/supervision/pull/1874)) - Added 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). ([#1816](https://github.com/roboflow/supervision/pull/1816)) - Added [`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`. ([#1823](https://github.com/roboflow/supervision/pull/1823)) - Added [`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. ([#1788](https://github.com/roboflow/supervision/pull/1788)) ## 🌱 Changed - [`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. ([#1820](https://github.com/roboflow/supervision/pull/1820)) https://github.com/user-attachments/assets/b6427371-b994-44bf-aa48-08ef636eb48d - [`sv.LabelAnnotator`](https://supervision.roboflow.com/0.26.0/detection/annotators/#supervision.annotators.core.LabelAnnotator) now supports non-string labels. ([#1825](https://github.com/roboflow/supervision/pull/1825)) - [`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). You can test Gemini prompting, result parsing, and visualization with Supervision using [this example notebook](https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/zero-shot-object-detection-and-segmentation-with-google-gamini-2-5.ipynb). ([#1792](https://github.com/roboflow/supervision/pull/1792)) ```python import supervision as sv 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, gemini_response_text, 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='<U26')} detections.class_id # array([0, 1]) ``` <img width="715" height="944" alt="image(1)" src="https://github.com/user-attachments/assets/3472786a-8130-40c5-9a0d-df4c4f2a6d18" /> - [`sv.Detections.from_vlm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.from_vlm) now supports parsing bounding boxes from responses generated by [Moondream](https://github.com/vikhyat/moondream). ([#1878](https://github.com/roboflow/supervision/pull/1878)) ```python import supervision as sv moondream_result = { 'objects': [ { 'x_min': 0.5704046934843063, 'y_min': 0.20069346576929092, 'x_max': 0.7049859315156937, 'y_max': 0.3012596592307091 }, { 'x_min': 0.6210969910025597, 'y_min': 0.3300672620534897, 'x_max': 0.8417936339974403, 'y_max': 0.4961046129465103 } ] } detections = sv.Detections.from_vlm( sv.VLM.MOONDREAM, moondream_result, resolution_wh=(1000, 1000), ) detections.xyxy # array([[1752.28, 818.82, 2165.72, 1229.14], # [1908.01, 1346.67, 2585.99, 2024.11]]) ``` <img width="715" height="944" alt="image(2)" src="https://github.com/user-attachments/assets/2dc1cf79-7548-434d-bf02-f716b91a0719" /> - [`sv.Detections.from_vlm`](https://supervision.roboflow.com/0.26.0/detection/core/#supervision.detection.core.Detections.from_vlm) now supports parsing bounding boxes from responses generated by [Qwen-2.5 VL](https://github.com/QwenLM/Qwen2.5-VL). You can test Qwen2.5-VL prompting, result parsing, and visualization with Supervision using [this example notebook](https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/zero-shot-object-detection-with-qwen2-5-vl.ipynb). ([#1709](https://github.com/roboflow/supervision/pull/1790)) ```python import supervision as sv qwen_2_5_vl_result = """```json [ {"bbox_2d": [139, 768, 315, 954], "label": "cat"}, {"bbox_2d": [366, 679, 536, 849], "label": "dog"} ] ```""" detections = sv.Detections.from_vlm( sv.VLM.QWEN_2_5_VL, qwen_2_5_vl_result, input_wh=(1000, 1000), resolution_wh=(1000, 1000), classes=['cat', 'dog'], ) detections.xyxy # array([[139., 768., 315., 954.], [366., 679., 536., 849.]]) detections.class_id # array([0, 1]) detections.data # {'class_name': array(['cat', 'dog'], dtype='<U10')} detections.class_id # array([0, 1]) ``` ![GkFgGs9XMAA873M](https://github.com/user-attachments/assets/67ce82b7-f731-48d1-b81e-f4bf07ab6971) - Significantly improved the speed of HSV color mapping in [`sv.HeatMapAnnotator`](https://supervision.roboflow.com/0.26.0/detection/annotators/#supervision.annotators.core.HeatMapAnnotator), achieving approximately 28x faster performance on 1920x1080 frames. ([#1786](https://github.com/roboflow/supervision/pull/1786)) <img width="950" height="543" alt="heat-map-annotator-example-purple" src="https://github.com/user-attachments/assets/647c3e9c-0a1f-4150-af13-2d68225d5b22" /> ## 🔧 Fixed - Supervision’s [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.0/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) is now fully aligned with [pycocotools](https://github.com/ppwwyyxx/cocoapi), the official COCO evaluation tool, ensuring accurate and standardized metrics. ([#1834](https://github.com/roboflow/supervision/pull/1834)) ```python import supervision as sv from supervision.metrics import MeanAveragePrecision predictions = sv.Detections(...) targets = sv.Detections(...) map_metric = MeanAveragePrecision() map_metric.update(predictions, targets).compute() # Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.464 # Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.637 # Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.203 # Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.284 # Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.497 # Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.629 ``` > [!TIP] > The updated mAP implementation enabled us to build an updated version of the [Computer Vision Model Leaderboard](https://leaderboard.roboflow.com/). <img width="1492" height="1014" alt="imageedit_1_8427510007" src="https://github.com/user-attachments/assets/1f46b877-abbc-486b-b8f9-2829f43716e1" /> - Fix [#1767](https://github.com/roboflow/supervision/pull/1767): Fixed losing `sv.Detections.data` when detections filtering. ## ⚠️ Deprecated - `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 - 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. - Cconstructing `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). ## 🏆 Contributors @onuralpszr ([Onuralp SEZER](https://www.linkedin.com/in/osezer/)), @SkalskiP ([Piotr Skalski](https://www.linkedin.com/in/skalskip92/)), @SunHao-AI ([Hao Sun](https://github.com/SunHao-AI)), @rafaelpadilla [Rafael Padilla](https://www.linkedin.com/in/rafael-padilla/), @Ashp116 ([Ashp116](https://github.com/Ashp116)), @capjamesg ([James Gallagher](https://www.linkedin.com/in/jg12927/)), @blakeburch ([Blake Burch](https://www.linkedin.com/in/blakeburch/)), @hidara2000 ([hidara2000](https://github.com/hidara2000)), @Armaggheddon ([Alessandro Brunello](https://www.linkedin.com/in/brunelloalessandro/)), @soumik12345 ([Soumik Rakshit](https://www.linkedin.com/in/soumikrakshit/)).

supervision-0.24.00.24.0
? · 2024-10-04

**`Supervision 0.24.0` is here! We've added many new changes, including the F1 score, enhancements to LineZone, EasyOCR support, NCNN support, and the best Cookbook to date! You can also try out our annotators directly in the browser. Check out the release notes to find out more!** ## 📢 Announcements [![image-1](https://github.com/user-attachments/assets/7bbfd9dc-6459-4f6c-8f50-27b37f6bb7e3)](https://github.com/roboflow/supervision/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest) - Supervision is celebrating [Hacktoberfest](https://hacktoberfest.com/)! Whether you're a newcomer to open source or a veteran contributor, we welcome you to join us in improving `supervision`. You can grab any issue without an assigned contributor: [Hacktoberfest Issues Board](https://github.com/roboflow/supervision/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest). We'll be adding many more issues next week! 🎉 - We recently launched the [Model Leaderboard](https://leaderboard.roboflow.com/). Come check how the latest models perform! It is also open-source, so you can [contribute](https://github.com/roboflow/model-leaderboard) to it as well! 🚀 # Changelog ## 🚀 Added - Added [F1 score](https://supervision.roboflow.com/0.24.0/metrics/f1_score/#supervision.metrics.f1_score.F1Score) as a new metric for detection and segmentation. The F1 score balances precision and recall, providing a single metric for model evaluation. #1521 ```python import supervision as sv from supervision.metrics import F1Score predictions = sv.Detections(...) targets = sv.Detections(...) f1_metric = F1Score() f1_result = f1_metric.update(predictions, targets).compute() print(f1_result) print(f1_result.f1_50) print(f1_result.small_objects.f1_50) ``` ![image-8-with-new](https://github.com/user-attachments/assets/6e1c68ea-a437-4efd-8380-ce78aa0d2e6b) - Added new cookbook: [Small Object Detection with SAHI](https://supervision.roboflow.com/0.24.0/notebooks/small-object-detection-with-sahi/). This cookbook provides a detailed guide on using [`InferenceSlicer`](https://supervision.roboflow.com/0.24.0/detection/tools/inference_slicer/) for small object detection, and is one of the best cookbooks we've ever seen. Thank you @ediardo! #1483 ![SAHI principle](https://raw.githubusercontent.com/obss/sahi/main/resources/sliced_inference.gif) ![Inference Slicer in action](https://github.com/user-attachments/assets/a40095f5-96af-457b-a9fd-7d9751e2a07a) - You can now try supervision annotators on your own images. Check out the [annotator docs](https://supervision.roboflow.com/0.24.0/detection/annotators/). The preview is powered by an [Embedded Workflow](https://roboflow.com/workflows). Thank you @joaomarcoscrs! #1533 ![Embedded workflow example](https://github.com/user-attachments/assets/2bf6bd03-f32b-4169-9e74-82c4e30a72f1) - Enhanced [`LineZoneAnnotator`](https://supervision.roboflow.com/0.24.0/detection/tools/line_zone/#supervision.detection.line_zone.LineZoneAnnotator), allowing the labels to align with the line, even when it's not horizontal. Also, you can now disable text background, and choose to draw labels off-center which minimizes overlaps for multiple [`LineZone`](https://supervision.roboflow.com/develop/detection/tools/line_zone/#supervision.detection.line_zone.LineZone) labels. Thank you @jcruz-ferreyra! #854 ```python import supervision as sv import cv2 image = cv2.imread("<SOURCE_IMAGE_PATH>") line_zone = sv.LineZone( start=sv.Point(0, 100), end=sv.Point(50, 200) ) line_zone_annotator = sv.LineZoneAnnotator( text_orient_to_line=True, display_text_box=False, text_centered=False ) annotated_frame = line_zone_annotator.annotate( frame=image.copy(), line_counter=line_zone ) sv.plot_image(frame) ``` https://github.com/user-attachments/assets/d7694b81-26ca-4236-bc66-af3d9e79d367 - Added per-class counting capabilities to [`LineZone`](https://supervision.roboflow.com/0.24.0/detection/tools/line_zone/#supervision.detection.line_zone.LineZone) and introduced [`LineZoneAnnotatorMulticlass`](https://supervision.roboflow.com/0.24.0/detection/tools/line_zone/#supervision.detection.line_zone.LineZoneAnnotatorMulticlass) for visualizing the counts per class. This feature allows tracking of individual classes crossing a line, enhancing the flexibility of use cases like traffic monitoring or crowd analysis. #1555 ```python import supervision as sv import cv2 image = cv2.imread("<SOURCE_IMAGE_PATH>") line_zone = sv.LineZone( start=sv.Point(0, 100), end=sv.Point(50, 200) ) line_zone_annotator = sv.LineZoneAnnotatorMulticlass() frame = line_zone_annotator.annotate( frame=frame, line_zones=[line_zone] ) sv.plot_image(frame) ``` https://github.com/user-attachments/assets/b109f5bd-6ae7-473b-b4e8-910a869736b4 - Added [`from_easyocr`](https://supervision.roboflow.com/0.24.0/detection/core/#supervision.detection.core.Detections.from_easyocr), allowing integration of OCR results into the supervision framework. [EasyOCR](https://github.com/JaidedAI/EasyOCR) is an open-source optical character recognition (OCR) library that can read text from images. Thank you @onuralpszr! #1515 ```python import supervision as sv import easyocr import cv2 image = cv2.imread("<SOURCE_IMAGE_PATH>") reader = easyocr.Reader(["en"]) result = reader.readtext("<SOURCE_IMAGE_PATH>", paragraph=True) detections = sv.Detections.from_easyocr(result) box_annotator = sv.BoxAnnotator(color_lookup=sv.ColorLookup.INDEX) label_annotator = sv.LabelAnnotator(color_lookup=sv.ColorLookup.INDEX) annotated_image = image.copy() annotated_image = box_annotator.annotate(scene=annotated_image, detections=detections) annotated_image = label_annotator.annotate(scene=annotated_image, detections=detections) sv.plot_image(annotated_image) ``` ![EasyOCR example](https://github.com/user-attachments/assets/1c8711ff-b882-4fdc-aed9-5a50a48c23b2) - Added [`oriented_box_iou_batch`](https://supervision.roboflow.com/0.24.0/detection/utils/#supervision.detection.utils.oriented_box_iou_batch) function to `detection.utils`. This function computes Intersection over Union (IoU) for oriented or rotated bounding boxes (OBB), making it easier to evaluate detections with non-axis-aligned boxes. Thank you @patel-zeel! #1502 ```python import numpy as np boxes_true = np.array([[[1, 0], [0, 1], [3, 4], [4, 3]]]) boxes_detection = np.array([[[1, 1], [2, 0], [4, 2], [3, 3]]]) ious = sv.oriented_box_iou_batch(boxes_true, boxes_detection) print("IoU between true and detected boxes:", ious) ``` Note: the IoU is approximated as mask IoU. ![Approximated OBB overlap](https://github.com/user-attachments/assets/10fc7143-9fde-4a77-bcd8-57517f05f054) - Extended [`PolygonZoneAnnotator`](https://supervision.roboflow.com/0.24.0/detection/tools/polygon_zone/#supervision.detection.tools.polygon_zone.PolygonZoneAnnotator) to allow setting opacity when drawing zones, providing enhanced visualization by filling the zone with adjustable transparency. Thank you @grzegorz-roboflow! #1527 - Added [`from_ncnn`](https://supervision.roboflow.com/0.24.0/detection/core/#supervision.detection.core.Detections.from_ncnn), a connector for the [NCNN](https://github.com/Tencent/ncnn). It is a powerful object detection framework from Tencent, written from ground-up in C++, with no third party dependencies. Thank you @onuralpszr! #1524 ```python import cv2 from ncnn.model_zoo import get_model import supervision as sv image = cv2.imread("<SOURCE_IMAGE_PATH>") model = get_model( "yolov8s", target_size=640, prob_threshold=0.5, nms_threshold=0.45, num_threads=4, use_gpu=True, ) result = model(image) detections = sv.Detections.from_ncnn(result) ``` ## 🌱 Changed - Supervision now depends on `opencv-python` rather than `opencv-python-headless`. #1530 - Fixed broken or outdated links in documentation and notebooks, improving navigation and ensuring accuracy of references. Thanks to @capjamesg for identifying these issues. #1523 - Enabled and fixed Ruff rules for code formatting, including changes like avoiding unnecessary iterable allocations and using Optional for default mutable arguments. #1526 ## 🔧 Fixed - Updated the COCO 101 point Average Precision algorithm to correctly interpolate precision, providing a more precise calculation of average precision without averaging out intermediate values. #1500 - Resolved miscellaneous issues highlighted when building documentation. This mostly includes whitespace adjustments and type inconsistencies. Updated documentation for clarity and fixed formatting issues. Added explicit version for `mkdocstrings-python`. #1549 - Clarified documentation around the `overlap_ratio_wh` argument deprecation in `InferenceSlicer`. #1547 ## ✅ No deprecations this time! ## ❌ Removed - The `frame_resolution_wh` parameter in [`PolygonZone`](https://supervision.roboflow.com/develop/detection/tools/polygon_zone/#supervision.detection.tools.polygon_zone.PolygonZone) has been removed due to deprecation. - Supervision installation methods "headless" and "desktop" removed, as they are no longer needed. `pip install supervision[headless]` will install the base library and warn of non-existent extra. # 🏆 Contributors @onuralpszr ([Onuralp SEZER](https://www.linkedin.com/in/osezer/)), @joaomarcoscrs ([João Marcos Cardoso Ramos da Silva](https://www.linkedin.com/in/joaomarcoscrs/)), @jcruz-ferreyra ([Juan Cruz](https://www.linkedin.com/in/jcruz-ferreyra/)), @patel-zeel ([Zeel B Patel](https://www.linkedin.com/in/zeel-b-patel/)), @grzegorz-roboflow ([Grzegorz Klimaszewski](https://www.linkedin.com/in/techgk/)), @Kadermiyanyedi ([Kader Miyanyedi](https://www.linkedin.com/in/kadermiyanyedi/)), @ediardo ([Eddie Ramirez](https://www.linkedin.com/in/ediardo/)), @CharlesCNorton, @ethanwhite (Ethan White), @josephofiowa ([Joseph Nelson](https://www.linkedin.com/in/josephofiowa/)), @tibeoh ([Thibault Itart-Longueville](https://www.linkedin.com/in/tibeoh/)), @SkalskiP ([Piotr Skalski](https://www.linkedin.com/in/skalskip92/)), @LinasKo ([Linas Kondrackis](https://www.linkedin.com/in/linasko/)) Thank you to [Pexels](https://www.pexels.com/) for providing fantastic images and videos!

supervision-0.23.00.23.0
? · 2024-08-28

## 🚀 Added - [`BackgroundOverlayAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.BackgroundOverlayAnnotator) annotates the background of your image! #1385 https://github.com/user-attachments/assets/c1f3ce11-08c1-4648-9176-4e7920b91a8a _(video by [Pexels](https://www.pexels.com/))_ - We're introducing [metrics](https://supervision.roboflow.com/latest/metrics/mean_average_precision/)! Over the next few releases, `supervision` will focus on adding more metrics, allowing you to evaluate your model performance. This holds true for boxes, masks, and oriented bounding boxes. #1442 > [!TIP] > Help in implementing metrics is very welcome! Keep an eye on our [issue board](https://github.com/roboflow/supervision/issues) if you'd like to contribute! ```python import supervision as sv from supervision.metrics import MeanAveragePrecision predictions = sv.Detections(...) targets = sv.Detections(...) map_metric = MeanAveragePrecision() map_result = map_metric.update(predictions, targets).compute() print(map_result) print(map_result.map50_95) print(map_result.large_objects.map50_95) map_result.plot() ``` Here's a very basic way to compare model results: <details> <summary>📊 Example code</summary> ```python import supervision as sv from supervision.metrics import MeanAveragePrecision from inference import get_model import matplotlib.pyplot as plt # !wget https://media.roboflow.com/notebooks/examples/dog.jpeg image = "dog.jpeg" model_1 = get_model("yolov8n-640") model_2 = get_model("yolov8s-640") model_3 = get_model("yolov8m-640") model_4 = get_model("yolov8l-640") results_1 = model_1.infer(image)[0] results_2 = model_2.infer(image)[0] results_3 = model_3.infer(image)[0] results_4 = model_4.infer(image)[0] detections_1 = sv.Detections.from_inference(results_1) detections_2 = sv.Detections.from_inference(results_2) detections_3 = sv.Detections.from_inference(results_3) detections_4 = sv.Detections.from_inference(results_4) map_n_metric = MeanAveragePrecision().update([detections_1], [detections_4]).compute() map_s_metric = MeanAveragePrecision().update([detections_2], [detections_4]).compute() map_m_metric = MeanAveragePrecision().update([detections_3], [detections_4]).compute() labels = ["YOLOv8n", "YOLOv8s", "YOLOv8m"] map_values = [map_n_metric.map50_95, map_s_metric.map50_95, map_m_metric.map50_95] plt.title("YOLOv8 Model Comparison") plt.bar(labels, map_values) ax = plt.gca() ax.set_ylim([0, 1]) plt.show() ``` </details> ![mini-benchmark](https://github.com/user-attachments/assets/7ca7626f-d3f3-4442-bfca-35ea82b12f11) - Added the [`IconAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.IconAnnotator), which allows you to place icons on your images. #930 https://github.com/user-attachments/assets/ff80acf5-67f2-4c20-a3fe-b63cac07ae31 (Video by [Pexels](https://www.pexels.com/), icons by [Icons8](https://icons8.com/)) ```python import supervision as sv from inference import get_model image = <SOURCE_IMAGE_PATH> icon_dog = <DOG_PNG_PATH> icon_cat = <CAT_PNG_PATH> model = get_model(model_id="yolov8n-640") results = model.infer(image)[0] detections = sv.Detections.from_inference(results) icon_paths = [] for class_name in detections.data["class_name"]: if class_name == "dog": icon_paths.append(icon_dog) elif class_name == "cat": icon_paths.append(icon_cat) else: icon_paths.append("") icon_annotator = sv.IconAnnotator() annotated_frame = icon_annotator.annotate( scene=image.copy(), detections=detections, icon_path=icon_paths ) ``` - Segment Anything 2 was released this month. And while you can load its results via [`from_sam`](https://supervision.roboflow.com/latest/detection/core/#supervision.detection.core.Detections.from_sam), we've added support to [`from_ultralytics`](https://supervision.roboflow.com/latest/detection/core/#supervision.detection.core.Detections.from_ultralytics) for loading the results if you ran it with Ultralytics. #1354 ```python import cv2 import supervision as sv from ultralytics import SAM image = cv2.imread("...") model = SAM("mobile_sam.pt") results = model(image, bboxes=[[588, 163, 643, 220]]) detections = sv.Detections.from_ultralytics(results[0]) polygon_annotator = sv.PolygonAnnotator() mask_annotator = sv.MaskAnnotator() annoated_image = mask_annotator.annotate(image.copy(), detections) annoated_image = polygon_annotator.annotate(annoated_image, detections) sv.plot_image(annoated_image, (12,12)) ``` SAM2 with our annotators: https://github.com/user-attachments/assets/6a98d651-2596-43e9-b485-ea6f0de4fffa - [`TriangleAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.TriangleAnnotator) and [`DotAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.DotAnnotator) contour color customization #1458 - [`VertexLabelAnnotator`](https://supervision.roboflow.com/latest/keypoint/annotators/#supervision.keypoint.annotators.VertexLabelAnnotator) for keypoints now has `text_color` parameter #1409 ## 🌱 Changed - Updated [`sv.Detections.from_transformers`](https://supervision.roboflow.com/latest/detection/core/#supervision.detection.core.Detections.from_transformers) to support the `transformers v5` functions. This includes the `DetrImageProcessor` methods `post_process_object_detection`, `post_process_panoptic_segmentation`, `post_process_semantic_segmentation`, and `post_process_instance_segmentation`. #1386 - [`InferenceSlicer`](https://supervision.roboflow.com/latest/detection/tools/inference_slicer/) now features an `overlap_ratio_wh` parameter, making it easier to compute slice sizes when handling overlapping slices. #1434 ```python image_with_small_objects = cv2.imread("...") model = get_model("yolov8n-640") def callback(image_slice: np.ndarray) -> sv.Detections: print("image_slice.shape:", image_slice.shape) result = model.infer(image_slice)[0] return sv.Detections.from_inference(result) slicer = sv.InferenceSlicer( callback=callback, slice_wh=(128, 128), overlap_ratio_wh=(0.2, 0.2), ) detections = slicer(image_with_small_objects) ``` ## 🛠️ Fixed - Annotator type fixes #1448 - New way of seeking to a specific video frame, where other methods don't work #1348 - `plot_image` now clearly states the size is in inches. #1424 ## ⚠️ Deprecated - `overlap_filter_strategy` in `InferenceSlicer.__init__` is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_strategy` instead. - `overlap_ratio_wh` in `InferenceSlicer.__init__` is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_wh` instead. ## ❌ Removed - The `track_buffer`, `track_thresh`, and `match_thresh` parameters in [`ByteTrack`](trackers.md/#supervision.tracker.byte_tracker.core.ByteTrack) are deprecated and were removed as of `supervision-0.23.0`. Use `lost_track_buffer,` `track_activation_threshold`, and `minimum_matching_threshold` instead. - The `triggering_position ` parameter in [`sv.PolygonZone`](detection/tools/polygon_zone.md/#supervision.detection.tools.polygon_zone.PolygonZone) was removed as of `supervision-0.23.0`. Use `triggering_anchors ` instead. # 🏆 Contributors @shaddu, @onuralpszr (Onuralp SEZER), @Kadermiyanyedi (Kader Miyanyedi), @xaristeidou (Christoforos Aristeidou), @Gk-rohan (Rohan Gupta), @Bhavay-2001 (Bhavay Malhotra), @arthurcerveira (Arthur Cerveira), @J4BEZ (Ju Hoon Park), @venkatram-dev, @eric220, @capjamesg (James), @yeldarby (Brad Dwyer), @SkalskiP (Piotr Skalski), @LinasKo (LinasKo)

supervision-0.22.00.22.0
? · 2024-07-12

## 🚀 Added - [Supervision Cheatsheet](https://roboflow.github.io/cheatsheet-supervision/) 🔥 ![supervision cheatsheet](https://github.com/user-attachments/assets/5e68c232-fea5-416d-914b-efcbad1d1028) - [`sv.KeyPoints.from_mediapipe`](https://supervision.roboflow.com/latest/keypoint/core/#supervision.keypoint.core.KeyPoints.from_mediapipe) adding support for Mediapipe keypoint models (both [legacy](https://colab.research.google.com/github/googlesamples/mediapipe/blob/main/examples/pose_landmarker/python/%5BMediaPipe_Python_Tasks%5D_Pose_Landmarker.ipynb) and [modern](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker/python)), along with default visualizers for face and body pose keypoints. ([#1232](https://github.com/roboflow/supervision/pull/1232), [#1316](https://github.com/roboflow/supervision/pull/1316)) ```python import numpy as np import mediapipe as mp import supervision as sv from PIL import Image model = mp.solutions.face_mesh.FaceMesh() edge_annotator = sv.EdgeAnnotator(color=sv.Color.BLACK, thickness=2) image = Image.open(<PATH_TO_IMAGE>).convert('RGB') results = model.process(np.array(image)) key_points = sv.KeyPoints.from_mediapipe(results, resolution_wh=image.size) annotated_image = edge_annotator.annotate(scene=image, key_points=key_points) ``` https://github.com/user-attachments/assets/883a6bcc-5e39-41b0-9b6d-0348b5b2fe0e - [`sv.KeyPoints.from_detectron2`](https://supervision.roboflow.com/latest/keypoint/core/#supervision.keypoint.core.KeyPoints.from_detectron2) and [`sv.Detections.from_detectron2`](https://supervision.roboflow.com/latest/detection/core/#supervision.detection.core.Detections.from_detectron2) extending support for [Detectron2](https://github.com/facebookresearch/detectron2) models. ([#1310](https://github.com/roboflow/supervision/pull/1310), [#1300](https://github.com/roboflow/supervision/pull/1300)) - [`sv.RichLabelAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.LabelAnnotator.annotate) allowing to draw unicode characters (e.g. from non-latin languages), as long as you provide a compatible font. ([#1277](https://github.com/roboflow/supervision/pull/1277)) https://github.com/user-attachments/assets/cc728fbc-9dec-478d-b0da-5705107eccbc ## 🌱 Changed - [`sv.DetectionsDataset`](https://supervision.roboflow.com/latest/datasets/core/#supervision.dataset.core.DetectionDataset) and [`sv.ClassificationDataset`](https://supervision.roboflow.com/latest/datasets/core/#supervision.dataset.core.ClassificationDataset) allowing to load the images into memory only when necessary (lazy loading). ([#1326](https://github.com/roboflow/supervision/pull/1326)) ```python import roboflow from roboflow import Roboflow import supervision as sv roboflow.login() rf = Roboflow() project = rf.workspace(<WORKSPACE_ID>).project(<PROJECT_ID>) dataset = project.version(<PROJECT_VERSION>).download("coco") ds_train = sv.DetectionDataset.from_coco( images_directory_path=f"{dataset.location}/train", annotations_path=f"{dataset.location}/train/_annotations.coco.json", ) path, image, annotation = ds_train[0] # loads image on demand for path, image, annotation in ds_train: # loads image on demand ``` - [`sv.Detections.from_lmm`](https://supervision.roboflow.com/latest/detection/core/#supervision.detection.core.Detections.from_lmm) allowing to parse [Florence-2](https://blog.roboflow.com/florence-2/) text result into [`sv.Detections`](https://supervision.roboflow.com/develop/detection/core/) object. ([#1296](https://github.com/roboflow/supervision/pull/1296)) ![florence-2-result](https://github.com/user-attachments/assets/27c629ef-5655-48f6-ae5b-a0be72b8938c) - [`sv.DotAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.DotAnnotator) and [`sv.TriangleAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.DotAnnotator.annotate) allowing to add marker outlines. ([#1294](https://github.com/roboflow/supervision/pull/1294)) ## 🛠️ Fixed - [`sv.ColorAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.ColorAnnotator) and [`sv.CropAnnotator`](https://supervision.roboflow.com/latest/detection/annotators/#supervision.annotators.core.CropAnnotator) buggy behaviours. ([#1277](https://github.com/roboflow/supervision/pull/1277), [#1312](https://github.com/roboflow/supervision/pull/1312)) ## 🧑‍🍳 Cookbooks This release, @onuralpszr added two new Cookbooks to our [collection](https://supervision.roboflow.com/latest/cookbooks/). Check them out to learn how to save `Detections` to a file and convert it back to `Detections`! - [Serialize detections to JSON](https://github.com/roboflow/supervision/blob/de896189b83a1f9434c0a37dd9192ee00d2a1283/docs/notebooks/serialise-detections-to-json.ipynb) ([#975](https://github.com/roboflow/supervision/pull/975)) - [Serialize detections to CSV](https://github.com/roboflow/supervision/blob/de896189b83a1f9434c0a37dd9192ee00d2a1283/docs/notebooks/serialise-detections-to-csv.ipynb) ([#975](https://github.com/roboflow/supervision/pull/975)). # 🏆 Contributors @onuralpszr (Onuralp SEZER), @David-rn (David Redó), @jeslinpjames (Jeslin P James), @Bhavay-2001 (Bhavay Malhotra), @hardikdava (Hardik Dava), @kirilman, @dsaha21 (Dripto Saha), @cdragos (Dragos Catarahia), @mqasim41 (Muhammad Qasim), @SkalskiP (Piotr Skalski), @LinasKo (Linas Kondrackis) Special thanks to @rolson24 (Raif Olson) for helping the community with `ByteTrack`!

supervision-0.21.00.21.0
? · 2024-06-06

# 📅 Timeline The `supervision-0.21.0` release is around the corner. Here is the timeline: - `5 Jun 2024 08:00 PM CEST (UTC +2) / 5 Jun 2024 11:00 AM PDT (UTC -7)` - merge `develop` into `main` - closing list `supervision-0.21.0` features - `6 Jun 2024 11:00 AM CEST (UTC +2) / 6 Jun 2024 02:00 AM PDT (UTC -7)` - release `supervision-0.21.0` # 🪵 Changelog ## 🚀 Added - [`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. ([#500](https://github.com/roboflow/supervision/pull/500)) ![non-max-merging](https://github.com/roboflow/supervision/assets/26109316/9c5c21ed-6133-4f9c-9919-d3e6b8439629) - [`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. ([#1221](https://github.com/roboflow/supervision/pull/1221)) ```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]) ``` - [`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. ([#1236](https://github.com/roboflow/supervision/pull/1236)) ```python import supervision as sv image = ... key_points = sv.KeyPoints(...) LABELS = [ "nose", "left eye", "right eye", "left ear", "right ear", "left shoulder", "right shoulder", "left elbow", "right elbow", "left wrist", "right wrist", "left hip", "right hip", "left knee", "right knee", "left ankle", "right ankle" ] COLORS = [ "#FF6347", "#FF6347", "#FF6347", "#FF6347", "#FF6347", "#FF1493", "#00FF00", "#FF1493", "#00FF00", "#FF1493", "#00FF00", "#FFD700", "#00BFFF", "#FFD700", "#00BFFF", "#FFD700", "#00BFFF" ] COLORS = [sv.Color.from_hex(color_hex=c) for c in COLORS] vertex_label_annotator = sv.VertexLabelAnnotator( color=COLORS, text_color=sv.Color.BLACK, border_radius=5 ) annotated_frame = vertex_label_annotator.annotate( scene=image.copy(), key_points=key_points, labels=labels ) ``` ![vertex-label-annotator-custom-example (1)](https://github.com/roboflow/supervision/assets/26109316/397a0c0a-47a1-449d-b128-470d2a571a66) - [`sv.KeyPoints.from_inference`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints.from_inference) and [`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 [Inference](https://github.com/roboflow/inference) and [YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) result. ([#1147](https://github.com/roboflow/supervision/pull/1147) and [#1138](https://github.com/roboflow/supervision/pull/1138)) - [`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. ([#1163](https://github.com/roboflow/supervision/pull/1163)) ![mask-to-rle (1)](https://github.com/roboflow/supervision/assets/26109316/c4ba0eeb-2eff-4209-ac6b-03d7a6e2e312) ## 🌱 Changed - [`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`). ([#1236](https://github.com/roboflow/supervision/pull/1236)) - [`sv.InferenceSlicer`](https://supervision.roboflow.com/develop/detection/tools/inference_slicer/) adding instance segmentation model support. ([#1178](https://github.com/roboflow/supervision/pull/1178)) ```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) ``` ![inference-slicer-segmentation-example](https://github.com/roboflow/supervision/assets/26109316/36e28daf-a92d-4e4c-a627-d1f4a89ced0c) - [`sv.LineZone`](https://supervision.roboflow.com/develop/detection/tools/line_zone/) making it 10-20 times faster, depending on the use case. ([#1228](https://github.com/roboflow/supervision/pull/1228)) ![output](https://github.com/roboflow/supervision/assets/26109316/41b357f4-e825-4ba3-abb7-1c5aa0aec0a9) - [`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. ([#1163](https://github.com/roboflow/supervision/pull/1163)) # 🏆 Contributors @onuralpszr (Onuralp SEZER), @LinasKo (Linas Kondrackis), @rolson24 (Raif Olson), @xaristeidou (Christoforos Aristeidou), @ManzarIMalik (Manzar Iqbal Malik), @tc360950 (Tomasz Cąkała), @emSko, @SkalskiP (Piotr Skalski)

supervision-0.20.00.20.0
? · 2024-04-24

## 🚀 Added - [`sv.KeyPoints`](https://supervision.roboflow.com/develop/keypoint/core/#supervision.keypoint.core.KeyPoints) to provide initial support for pose estimation and broader keypoint detection models. ([#1128](https://github.com/roboflow/supervision/pull/1128)) - [`sv.EdgeAnnotator`](https://supervision.roboflow.com/develop/keypoint/annotators/#supervision.keypoint.annotators.EdgeAnnotator) and [`sv.VertexAnnotator`](https://supervision.roboflow.com/develop/keypoint/annotators/#supervision.keypoint.annotators.VertexAnnotator) to enable rendering of results from keypoint detection models. ([#1128](https://github.com/roboflow/supervision/pull/1128)) ```python import cv2 import supervision as sv from ultralytics import YOLO image = cv2.imread(<SOURCE_IMAGE_PATH>) model = YOLO('yolov8l-pose') result = model(image, verbose=False)[0] keypoints = sv.KeyPoints.from_ultralytics(result) edge_annotators = sv.EdgeAnnotator(color=sv.Color.GREEN, thickness=5) annotated_image = edge_annotators.annotate(image.copy(), keypoints) ``` ![edge-annotator-example](https://github.com/roboflow/supervision/assets/26109316/eefdd879-4949-4ea8-aec6-fa5273c5316d) ```python import cv2 import supervision as sv from ultralytics import YOLO image = cv2.imread(<SOURCE_IMAGE_PATH>) model = YOLO('yolov8l-pose') result = model(image, verbose=False)[0] keypoints = sv.KeyPoints.from_ultralytics(result) vertex_annotators = sv.VertexAnnotator(color=sv.Color.GREEN, radius=10) annotated_image = vertex_annotators.annotate(image.copy(), keypoints) ``` ![vertex-annotator-example](https://github.com/roboflow/supervision/assets/26109316/e931979b-c46d-4ad0-b474-19ebbf167895) ## 🌱 Changed - [`sv.LabelAnnotator`](https://supervision.roboflow.com/develop/annotators/#supervision.annotators.core.LabelAnnotator) by adding an additional `corner_radius` argument that allows for rounding the corners of the bounding box. ([#1037](https://github.com/roboflow/supervision/pull/1037)) - [`sv.PolygonZone`](https://supervision.roboflow.com/develop/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`. ([#1109](https://github.com/roboflow/supervision/pull/1109)) > [!WARNING] > The `frame_resolution_wh` parameter in `sv.PolygonZone` is deprecated and will be removed in `supervision-0.24.0`. - [`sv.get_polygon_center`](https://supervision.roboflow.com/develop/utils/geometry/#supervision.geometry.core.utils.get_polygon_center) to calculate a more accurate polygon centroid. ([#1084](https://github.com/roboflow/supervision/pull/1084)) - [`sv.Detections.from_transformers`](https://supervision.roboflow.com/develop/detection/core/#supervision.detection.core.Detections.from_transformers) by adding support for Transformers segmentation models and extract class names values. ([#1069](https://github.com/roboflow/supervision/pull/1069)) ```python import torch import supervision as sv from PIL import Image from transformers import DetrImageProcessor, DetrForSegmentation processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50-panoptic") model = DetrForSegmentation.from_pretrained("facebook/detr-resnet-50-panoptic") image = Image.open(<SOURCE_IMAGE_PATH>) inputs = processor(images=image, return_tensors="pt") with torch.no_grad(): outputs = model(**inputs) width, height = image.size target_size = torch.tensor([[height, width]]) results = processor.post_process_segmentation( outputs=outputs, target_sizes=target_size)[0] detections = sv.Detections.from_transformers(results, id2label=model.config.id2label) mask_annotator = sv.MaskAnnotator() label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER) annotated_image = mask_annotator.annotate( scene=image, detections=detections) annotated_image = label_annotator.annotate( scene=annotated_image, detections=detections) ``` ## 🛠️ Fixed - [`sv.ByteTrack.update_with_detections`](https://supervision.roboflow.com/develop/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. ([#787](https://github.com/roboflow/supervision/pull/787)) # 🏆 Contributors @onuralpszr (Onuralp SEZER), @rolson24 (Raif Olson), @xaristeidou (Christoforos Aristeidou), @jeslinpjames (Jeslin P James), @Griffin-Sullivan (Griffin Sullivan), @PawelPeczek-Roboflow (Paweł Pęczek), @pirnerjonas (Jonas Pirner), @sharingan000, @macc-n, @LinasKo (Linas Kondrackis), @SkalskiP (Piotr Skalski)

supervision-0.19.00.19.0
? · 2024-03-15

## 🧑‍🍳 Cookbooks [Supervision Cookbooks](https://supervision.roboflow.com/develop/cookbooks/) - A curated open-source collection crafted by the community, offering practical examples, comprehensive guides, and walkthroughs for leveraging Supervision alongside diverse Computer Vision models. ([#860](https://github.com/roboflow/supervision/pull/860)) ## 🚀 Added - [`sv.CSVSink`](https://supervision.roboflow.com/develop/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. ([#818](https://github.com/roboflow/supervision/pull/818)) ```python import supervision as sv from ultralytics import YOLO model = YOLO(<SOURCE_MODEL_PATH>) csv_sink = sv.CSVSink(<RESULT_CSV_FILE_PATH>) frames_generator = sv.get_video_frames_generator(<SOURCE_VIDEO_PATH>) with csv_sink: for frame in frames_generator: result = model(frame)[0] detections = sv.Detections.from_ultralytics(result) csv_sink.append(detections, custom_data={<CUSTOM_LABEL>:<CUSTOM_DATA>}) ``` https://github.com/roboflow/supervision/assets/26109316/621588f9-69a0-44fe-8aab-ab4b0ef2ea1b - [`sv.JSONSink`](https://supervision.roboflow.com/develop/detection/tools/save_detections/#supervision.detection.tools.csv_sink.JSONSink) allowing for the straightforward saving of image, video, or stream inference results in a `.json` file. ([#819](https://github.com/roboflow/supervision/pull/819)) ```python import supervision as sv from ultralytics import YOLO model = YOLO(<SOURCE_MODEL_PATH>) json_sink = sv.JSONSink(<RESULT_JSON_FILE_PATH>) frames_generator = sv.get_video_frames_generator(<SOURCE_VIDEO_PATH>) with json_sink: for frame in frames_generator: result = model(frame)[0] detections = sv.Detections.from_ultralytics(result) json_sink.append(detections, custom_data={<CUSTOM_LABEL>:<CUSTOM_DATA>}) ``` - [`sv.mask_iou_batch`](https://supervision.roboflow.com/develop/detection/utils/#supervision.detection.utils.mask_iou_batch) allowing to compute Intersection over Union (IoU) of two sets of masks. ([#847](https://github.com/roboflow/supervision/pull/847)) - [`sv.mask_non_max_suppression`](https://supervision.roboflow.com/develop/detection/utils/#supervision.detection.utils.mask_non_max_suppression) allowing to perform Non-Maximum Suppression (NMS) on segmentation predictions. ([#847](https://github.com/roboflow/supervision/pull/847)) - [`sv.CropAnnotator`](https://supervision.roboflow.com/develop/annotators/#supervision.annotators.core.CropAnnotator) allowing users to annotate the scene with scaled-up crops of detections. ([#888](https://github.com/roboflow/supervision/pull/888)) ```python import cv2 import supervision as sv from inference import get_model image = cv2.imread(<SOURCE_IMAGE_PATH>) model = get_model(model_id="yolov8n-640") result = model.infer(image)[0] detections = sv.Detections.from_inference(result) crop_annotator = sv.CropAnnotator() annotated_frame = crop_annotator.annotate( scene=image.copy(), detections=detections ) ``` https://github.com/roboflow/supervision/assets/26109316/72d42395-17f2-431d-9bd2-f03138770293 ## 🌱 Changed - [`sv.ByteTrack.reset`](https://supervision.roboflow.com/develop/trackers/#supervision.tracker.byte_tracker.core.ByteTrack.reset) allowing users to clear trackers state, enabling the processing of multiple video files in sequence. ([#827](https://github.com/roboflow/supervision/pull/827)) - [`sv.LineZoneAnnotator`](https://supervision.roboflow.com/develop/detection/tools/line_zone/#supervision.detection.line_zone.LineZone) allowing to hide in/out count using `display_in_count` and `display_out_count` properties. ([#802](https://github.com/roboflow/supervision/pull/802)) - [`sv.ByteTrack`](https://supervision.roboflow.com/develop/trackers/#supervision.tracker.byte_tracker.core.ByteTrack) input arguments and docstrings updated to improve readability and ease of use. ([#787](https://github.com/roboflow/supervision/pull/787)) > [!WARNING] > The `track_buffer`, `track_thresh`, and `match_thresh` parameters in `sv.ByterTrack` are deprecated and will be removed in `supervision-0.23.0`. Use `lost_track_buffer,` `track_activation_threshold`, and `minimum_matching_threshold` instead. - [`sv.PolygonZone`](https://supervision.roboflow.com/develop/detection/tools/polygon_zone/#supervision.detection.tools.polygon_zone.PolygonZone) to now accept a list of specific box anchors that must be in zone for a detection to be counted. ([#910](https://github.com/roboflow/supervision/pull/910)) > [!WARNING] > The `triggering_position ` parameter in `sv.PolygonZone` is deprecated and will be removed in `supervision-0.23.0`. Use `triggering_anchors` instead. - Annotators adding support for Pillow images. All supervision Annotators can now accept an image as either a numpy array or a Pillow Image. They automatically detect its type, draw annotations, and return the output in the same format as the input. ([#875](https://github.com/roboflow/supervision/pull/875)) ## 🛠️ Fixed - [`sv.DetectionsSmoother`](https://supervision.roboflow.com/develop/detection/tools/smoother/#supervision.detection.tools.smoother.DetectionsSmoother) removing `tracking_id` from `sv.Detections`. ([#944](https://github.com/roboflow/supervision/pull/944)) - [`sv.DetectionDataset`](https://supervision.roboflow.com/develop/datasets/#supervision.dataset.core.DetectionDataset) which, after changes introduced in `supervision-0.18.0`, failed to load datasets in YOLO, PASCAL VOC, and COCO formats. ## 🏆 Contributors @onuralpszr (Onuralp SEZER), @LinasKo (Linas Kondrackis), @LeviVasconcelos (Levi Vasconcelos), @AdonaiVera (Adonai Vera), @xaristeidou (Christoforos Aristeidou), @Kadermiyanyedi (Kader Miyanyedi), @NickHerrig (Nick Herrig), @PacificDou (Shuyang Dou), @iamhatesz (Tomasz Wrona), @capjamesg (James Gallagher), @sansyo, @SkalskiP (Piotr Skalski)