diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff62fd44..7fe9c6d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,3 +38,18 @@ repos: args: [--fix, --exit-non-zero-on-fix] - id: ruff-format types_or: [ python, pyi, jupyter ] + + # - repo: https://github.com/executablebooks/mdformat + # rev: 0.7.17 + # hooks: + # - id: mdformat + # additional_dependencies: + # - "mdformat-mkdocs[recommended]>=2.1.0" + # args: ["--number"] + + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + additional_dependencies: + - tomli diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 18c32736..aa1e72b8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,3 @@ - # Contributor Covenant Code of Conduct ## Our Pledge @@ -18,24 +17,24 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery, and sexual attention or advances of + any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Enforcement Responsibilities @@ -121,14 +120,14 @@ version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. +[Mozilla's code of conduct enforcement ladder][mozilla coc]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/faq][faq]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. +[faq]: https://www.contributor-covenant.org/faq [homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq +[mozilla coc]: https://github.com/mozilla/diversity [translations]: https://www.contributor-covenant.org/translations +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd6797c1..8a06e342 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,13 +11,13 @@ Please read and adhere to our [Code of Conduct](https://supervision.roboflow.com ## Table of Contents - [Contribution Guidelines](#contribution-guidelines) - - [Contributing Features](#contributing-features) + - [Contributing Features](#contributing-features) - [How to Contribute Changes](#how-to-contribute-changes) - [Installation for Contributors](#installation-for-contributors) - [Code Style and Quality](#code-style-and-quality) - - [Pre-commit tool](#pre-commit-tool) - - [Docstrings](#docstrings) - - [Type checking](#type-checking) + - [Pre-commit tool](#pre-commit-tool) + - [Docstrings](#docstrings) + - [Type checking](#type-checking) - [Documentation](#documentation) - [Cookbooks](#cookbooks) - [Tests](#tests) @@ -83,7 +83,7 @@ git push -u origin Use conventional commit messages to clearly describe your changes. The format is: -[optional scope]: +\[optional scope\]: Common types include: @@ -130,45 +130,46 @@ Before starting your work on the project, set up your development environment: 1. Clone your fork of the project: - ```bash - git clone https://github.com/YOUR_USERNAME/supervision.git - cd supervision - ``` + ```bash + git clone https://github.com/YOUR_USERNAME/supervision.git + cd supervision + ``` - Replace `YOUR_USERNAME` with your GitHub username. + Replace `YOUR_USERNAME` with your GitHub username. 2. Create and activate a virtual environment: - ```bash - python3 -m venv .venv - source .venv/bin/activate - ``` + ```bash + python3 -m venv .venv + source .venv/bin/activate + ``` 3. Install Poetry: - Using pip: + Using pip: - ```bash - pip install -U pip setuptools - pip install poetry - ``` + ```bash + pip install -U pip setuptools + pip install poetry + ``` - Or using pipx (recommended for global installation): + Or using pipx (recommended for global installation): - ```bash - pipx install poetry - ``` + ```bash + pipx install poetry + ``` 4. Install project dependencies: - ```bash - poetry install - ``` + ```bash + poetry install + ``` 5. Run pytest to verify the setup: - ```bash - poetry run pytest - ``` + + ```bash + poetry run pytest + ``` ## 🎨 Code Style and Quality diff --git a/README.md b/README.md index 9509a514..b47f9386 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@

-
+
[notebooks](https://github.com/roboflow/notebooks) | [inference](https://github.com/roboflow/inference) | [autodistill](https://github.com/autodistill/autodistill) | [maestro](https://github.com/roboflow/multimodal-maestro) -
+
[![version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision) [![downloads](https://img.shields.io/pypi/dm/supervision)](https://pypistats.org/packages/supervision) @@ -23,6 +23,7 @@ [![gradio](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Roboflow/Annotators) [![discord](https://img.shields.io/discord/1159501506232451173)](https://discord.gg/GbfgXGJ8Bk) [![built-with-material-for-mkdocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/) + ## 👋 hello @@ -54,7 +55,7 @@ import supervision as sv from ultralytics import YOLO image = cv2.imread(...) -model = YOLO('yolov8s.pt') +model = YOLO("yolov8s.pt") result = model(image)[0] detections = sv.Detections.from_ultralytics(result) @@ -97,10 +98,7 @@ image = cv2.imread(...) detections = sv.Detections(...) box_annotator = sv.BoxAnnotator() -annotated_frame = box_annotator.annotate( - scene=image.copy(), - detections=detections -) +annotated_frame = box_annotator.annotate(scene=image.copy(), detections=detections) ``` https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-ab5644f39bce @@ -133,88 +131,69 @@ for path, image, annotation in ds: - load - ```python - dataset = sv.DetectionDataset.from_yolo( - images_directory_path=..., - annotations_directory_path=..., - data_yaml_path=... - ) + ```python + dataset = sv.DetectionDataset.from_yolo( + images_directory_path=..., annotations_directory_path=..., data_yaml_path=... + ) - dataset = sv.DetectionDataset.from_pascal_voc( - images_directory_path=..., - annotations_directory_path=... - ) + dataset = sv.DetectionDataset.from_pascal_voc( + images_directory_path=..., annotations_directory_path=... + ) - dataset = sv.DetectionDataset.from_coco( - images_directory_path=..., - annotations_path=... - ) - ``` + dataset = sv.DetectionDataset.from_coco(images_directory_path=..., annotations_path=...) + ``` - split - ```python - train_dataset, test_dataset = dataset.split(split_ratio=0.7) - test_dataset, valid_dataset = test_dataset.split(split_ratio=0.5) + ```python + train_dataset, test_dataset = dataset.split(split_ratio=0.7) + test_dataset, valid_dataset = test_dataset.split(split_ratio=0.5) - len(train_dataset), len(test_dataset), len(valid_dataset) - # (700, 150, 150) - ``` + len(train_dataset), len(test_dataset), len(valid_dataset) + # (700, 150, 150) + ``` - merge - ```python - ds_1 = sv.DetectionDataset(...) - len(ds_1) - # 100 - ds_1.classes - # ['dog', 'person'] + ```python + ds_1 = sv.DetectionDataset(...) + len(ds_1) + # 100 + ds_1.classes + # ['dog', 'person'] - ds_2 = sv.DetectionDataset(...) - len(ds_2) - # 200 - ds_2.classes - # ['cat'] + ds_2 = sv.DetectionDataset(...) + len(ds_2) + # 200 + ds_2.classes + # ['cat'] - ds_merged = sv.DetectionDataset.merge([ds_1, ds_2]) - len(ds_merged) - # 300 - ds_merged.classes - # ['cat', 'dog', 'person'] - ``` + ds_merged = sv.DetectionDataset.merge([ds_1, ds_2]) + len(ds_merged) + # 300 + ds_merged.classes + # ['cat', 'dog', 'person'] + ``` - save - ```python - dataset.as_yolo( - images_directory_path=..., - annotations_directory_path=..., - data_yaml_path=... - ) + ```python + dataset.as_yolo( + images_directory_path=..., annotations_directory_path=..., data_yaml_path=... + ) - dataset.as_pascal_voc( - images_directory_path=..., - annotations_directory_path=... - ) + dataset.as_pascal_voc(images_directory_path=..., annotations_directory_path=...) - dataset.as_coco( - images_directory_path=..., - annotations_path=... - ) - ``` + dataset.as_coco(images_directory_path=..., annotations_path=...) + ``` - convert - ```python - sv.DetectionDataset.from_yolo( - images_directory_path=..., - annotations_directory_path=..., - data_yaml_path=... - ).as_pascal_voc( - images_directory_path=..., - annotations_directory_path=... - ) - ``` + ```python + sv.DetectionDataset.from_yolo( + images_directory_path=..., annotations_directory_path=..., data_yaml_path=... + ).as_pascal_voc(images_directory_path=..., annotations_directory_path=...) + ``` @@ -266,7 +245,7 @@ We love your input! Please see our [contributing guide](https://github.com/robof
-
+
Aug 28, 2024 - Added [#930](https://github.com/roboflow/supervision/pull/930): `IconAnnotator`, a [new annotator](https://supervision.roboflow.com/0.23.0/detection/annotators/#supervision.annotators.core.IconAnnotator) that allows drawing icons on each detection. Useful if you want to draw a specific icon for each class. @@ -80,10 +82,7 @@ detections = sv.Detections.from_transformers( ```python import supervision as sv -from segment_anything import ( - sam_model_registry, - SamAutomaticMaskGenerator -) +from segment_anything import sam_model_registry, SamAutomaticMaskGenerator sam_model_reg = sam_model_registry[MODEL_TYPE] sam = sam_model_reg(checkpoint=CHECKPOINT_PATH).to(device=DEVICE) @@ -116,19 +115,15 @@ for frame in sv.get_video_frames_generator( - Fix [#1424](https://github.com/roboflow/supervision/pull/1424): `plot_image` function now clearly indicates that the size is in inches. !!! failure "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. !!! failure "Removed" - - 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. + 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. !!! failure "Deprecated" - `overlap_filter_strategy` in `InferenceSlicer.__init__` is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_strategy` instead. !!! failure "Deprecated" - `overlap_ratio_wh` in `InferenceSlicer.__init__` is deprecated and will be removed in `supervision-0.27.0`. Use `overlap_wh` instead. ### 0.22.0 Jul 12, 2024 @@ -136,11 +131,9 @@ for frame in sv.get_video_frames_generator( - Added [#1326](https://github.com/roboflow/supervision/pull/1326): [`sv.DetectionsDataset`](https://supervision.roboflow.com/0.22.0/datasets/core/#supervision.dataset.core.DetectionDataset) and [`sv.ClassificationDataset`](https://supervision.roboflow.com/0.22.0/datasets/core/#supervision.dataset.core.ClassificationDataset) allowing to load the images into memory only when necessary (lazy loading). !!! failure "Deprecated" - Constructing `DetectionDataset` with parameter `images` as `Dict[str, np.ndarray]` is deprecated and will be removed in `supervision-0.26.0`. Please pass a list of paths `List[str]` instead. !!! failure "Deprecated" - The `DetectionDataset.images` property is deprecated and 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. ```python @@ -197,7 +190,7 @@ annotated_frame = mask_annotator.annotate(scene=image.copy(), detections=detecti ``` - Added [#1277](https://github.com/roboflow/supervision/pull/1277): if you provide a font that supports symbols of a language, [`sv.RichLabelAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.LabelAnnotator.annotate) will draw them on your images. - - Various other annotators have been revised to ensure proper in-place functionality when used with `numpy` arrays. Additionally, we fixed a bug where `sv.ColorAnnotator` was filling boxes with solid color when used in-place. + - Various other annotators have been revised to ensure proper in-place functionality when used with `numpy` arrays. Additionally, we fixed a bug where `sv.ColorAnnotator` was filling boxes with solid color when used in-place. ```python import cv2 @@ -223,7 +216,7 @@ train_ds = sv.DetectionDataset.from_yolo( images_directory_path="/content/dataset/train/images", annotations_directory_path="/content/dataset/train/labels", data_yaml_path="/content/dataset/data.yaml", - is_obb=True + is_obb=True, ) _, image, detections in train_ds[0] @@ -235,11 +228,9 @@ annotated_image = obb_annotator.annotate(scene=image.copy(), detections=detectio - Fixed [#1312](https://github.com/roboflow/supervision/pull/1312): Fixed [`CropAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.TraceAnnotator.annotate). !!! failure "Removed" - `BoxAnnotator` was removed, however `BoundingBoxAnnotator` has been renamed to `BoxAnnotator`. Use a combination of [`BoxAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.BoxAnnotator) and [`LabelAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.LabelAnnotator) to simulate old `BoundingBox` behavior. !!! failure "Deprecated" - The name `BoundingBoxAnnotator` has been deprecated and will be removed in `supervision-0.26.0`. It has been renamed to [`BoxAnnotator`](https://supervision.roboflow.com/0.22.0/detection/annotators/#supervision.annotators.core.BoxAnnotator). - Added [#975](https://github.com/roboflow/supervision/pull/975) 📝 New Cookbooks: serialize detections into [json](https://github.com/roboflow/supervision/blob/de896189b83a1f9434c0a37dd9192ee00d2a1283/docs/notebooks/serialise-detections-to-json.ipynb) and [csv](https://github.com/roboflow/supervision/blob/de896189b83a1f9434c0a37dd9192ee00d2a1283/docs/notebooks/serialise-detections-to-csv.ipynb). @@ -249,35 +240,27 @@ annotated_image = obb_annotator.annotate(scene=image.copy(), detections=detectio - Added [#1340](https://github.com/roboflow/supervision/pull/1340): Two new methods for converting between bounding box formats - [`xywh_to_xyxy`](https://supervision.roboflow.com/0.22.0/detection/utils/#supervision.detection.utils.xywh_to_xyxy) and [`xcycwh_to_xyxy`](https://supervision.roboflow.com/0.22.0/detection/utils/#supervision.detection.utils.xcycwh_to_xyxy) !!! failure "Removed" - `from_roboflow` method has been removed due to deprecation. Use [from_inference](https://supervision.roboflow.com/0.22.0/detection/core/#supervision.detection.core.Detections.from_inference) instead. !!! failure "Removed" - `Color.white()` has been removed due to deprecation. Use `color.WHITE` instead. !!! failure "Removed" - `Color.black()` has been removed due to deprecation. Use `color.BLACK` instead. !!! failure "Removed" - `Color.red()` has been removed due to deprecation. Use `color.RED` instead. !!! failure "Removed" - `Color.green()` has been removed due to deprecation. Use `color.GREEN` instead. !!! failure "Removed" - `Color.blue()` has been removed due to deprecation. Use `color.BLUE` instead. !!! failure "Removed" - `ColorPalette.default()` has been removed due to deprecation. Use [ColorPalette.DEFAULT](https://supervision.roboflow.com/0.22.0/utils/draw/#supervision.draw.color.ColorPalette.DEFAULT) instead. !!! failure "Removed" - `FPSMonitor.__call__` has been removed due to deprecation. Use the attribute [FPSMonitor.fps](https://supervision.roboflow.com/0.22.0/utils/video/#supervision.utils.video.FPSMonitor.fps) instead. ### 0.21.0 Jun 5, 2024 @@ -294,7 +277,7 @@ detections = sv.Detections.from_lmm( sv.LMM.PALIGEMMA, paligemma_result, resolution_wh=(1000, 1000), - classes=['cat', 'dog'] + classes=["cat", "dog"], ) detections.xyxy # array([[250., 250., 750., 750.]]) @@ -311,14 +294,8 @@ 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 -) +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/0.21.0/keypoint/core/#supervision.keypoint.core.KeyPoints.from_inference) allowing to create [`sv.KeyPoints`](https://supervision.roboflow.com/0.21.0/keypoint/core/#supervision.keypoint.core.KeyPoints) from [Inference](https://github.com/roboflow/inference) result. @@ -386,7 +363,6 @@ annotated_image = edge_annotators.annotate(image.copy(), keypoints) - 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`. !!! failure "Deprecated" - The `frame_resolution_wh` parameter in `sv.PolygonZone` is deprecated and will be removed in `supervision-0.24.0`. - 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. @@ -492,13 +468,11 @@ annotated_frame = crop_annotator.annotate( - Changed [#787](https://github.com/roboflow/supervision/pull/787): [`sv.ByteTrack`](/0.19.0/trackers/#supervision.tracker.ByteTrack) input arguments and docstrings updated to improve readability and ease of use. !!! failure "Deprecated" - The `track_buffer`, `track_thresh`, and `match_thresh` parameters in `sv.ByteTrack` are deprecated and will be removed in `supervision-0.23.0`. Use `lost_track_buffer,` `track_activation_threshold`, and `minimum_matching_threshold` instead. - Changed [#910](https://github.com/roboflow/supervision/pull/910): [`sv.PolygonZone`](/0.19.0/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. !!! failure "Deprecated" - The `triggering_position ` parameter in `sv.PolygonZone` is deprecated and will be removed in `supervision-0.23.0`. Use `triggering_anchors` instead. - Changed [#875](https://github.com/roboflow/supervision/pull/875): 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. @@ -562,7 +536,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) - Changed [#756](https://github.com/roboflow/supervision/pull/756): [`sv.Color`](/0.18.0/draw/color/#color)'s and [`sv.ColorPalette`](/0.18.0/draw/color/#colorpalette)'s method of accessing predefined colors, transitioning from a function-based approach (`sv.Color.red()`) to a more intuitive and conventional property-based method (`sv.Color.RED`). !!! failure "Deprecated" - `sv.ColorPalette.default()` is deprecated and will be removed in `supervision-0.22.0`. Use `sv.ColorPalette.DEFAULT` instead. - Changed [#769](https://github.com/roboflow/supervision/pull/769): [`sv.ColorPalette.DEFAULT`](/0.18.0/draw/color/#colorpalette) value, giving users a more extensive set of annotation colors. @@ -570,7 +543,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) - Changed [#677](https://github.com/roboflow/supervision/pull/677): `sv.Detections.from_roboflow` to [`sv.Detections.from_inference`](/0.18.0/detection/core/#supervision.detection.core.Detections.from_inference) streamlining its functionality to be compatible with both the both [inference](https://github.com/roboflow/inference) pip package and the Robloflow [hosted API](https://docs.roboflow.com/deploy/hosted-api). !!! failure "Deprecated" - `Detections.from_roboflow()` is deprecated and will be removed in `supervision-0.22.0`. Use `Detections.from_inference` instead. - Fixed [#735](https://github.com/roboflow/supervision/pull/735): [`sv.LineZone`](/0.18.0/detection/tools/line_zone/#linezone) functionality to accurately update the counter when an object crosses a line from any direction, including from the side. This enhancement enables more precise tracking and analytics, such as calculating individual in/out counts for each lane on the road. @@ -668,7 +640,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) - Fixed [#430](https://github.com/roboflow/supervision/pull/430): [`sv.ByteTrack`](/0.16.0/trackers/#supervision.tracker.byte_tracker.core.ByteTrack) to return `np.array([], dtype=int)` when `svDetections` is empty. !!! failure "Deprecated" - `sv.Detections.from_yolov8` and `sv.Classifications.from_yolov8` as those are now replaced by [`sv.Detections.from_ultralytics`](/0.16.0/detection/core/#supervision.detection.core.Detections.from_ultralytics) and [`sv.Classifications.from_ultralytics`](/0.16.0/classification/core/#supervision.classification.core.Classifications.from_ultralytics). ### 0.15.0 October 5, 2023 @@ -736,7 +707,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) - Added [#281](https://github.com/roboflow/supervision/pull/281): [`sv.Classifications.from_ultralytics`](/0.14.0/classification/core/#supervision.classification.core.Classifications.from_ultralytics) to enable seamless integration with [Ultralytics](https://github.com/ultralytics/ultralytics) framework. This will enable you to use supervision with all [models](https://docs.ultralytics.com/models/) that Ultralytics supports. !!! failure "Deprecated" - [sv.Detections.from_yolov8](/0.14.0/detection/core/#supervision.detection.core.Detections.from_yolov8) and [sv.Classifications.from_yolov8](/0.14.0/classification/core/#supervision.classification.core.Classifications.from_yolov8) are now deprecated and will be removed with `supervision-0.16.0` release. - Added [#341](https://github.com/roboflow/supervision/pull/341): First supervision usage example script showing how to detect and track objects on video using YOLOv8 + Supervision. @@ -774,7 +744,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) - Added [#222](https://github.com/roboflow/supervision/pull/222): [`sv.Detections.from_ultralytics`](/0.13.0/detection/core/#supervision.detection.core.Detections.from_ultralytics) to enable seamless integration with [Ultralytics](https://github.com/ultralytics/ultralytics) framework. This will enable you to use `supervision` with all [models](https://docs.ultralytics.com/models/) that Ultralytics supports. !!! failure "Deprecated" - [`sv.Detections.from_yolov8`](/0.13.0/detection/core/#supervision.detection.core.Detections.from_yolov8) is now deprecated and will be removed with `supervision-0.15.0` release. - Added [#191](https://github.com/roboflow/supervision/pull/191): [`sv.Detections.from_paddledet`](/0.13.0/detection/core/#supervision.detection.core.Detections.from_paddledet) to enable seamless integration with [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection) framework. @@ -784,7 +753,6 @@ ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=59, g=82, b=139), ...]) ### 0.12.0 July 24, 2023 !!! failure "Python 3.7. Support Terminated" - With the `supervision-0.12.0` release, we are terminating official support for Python 3.7. - Added [#177](https://github.com/roboflow/supervision/pull/177): initial support for object detection model benchmarking with [`sv.ConfusionMatrix`](/0.12.0/metrics/detection/#confusionmatrix). diff --git a/docs/contributing.md b/docs/contributing.md index ea38c9bf..4f79db8a 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -1 +1 @@ ---8<-- "CONTRIBUTING.md" +--8\<-- "CONTRIBUTING.md" diff --git a/docs/datasets/core.md b/docs/datasets/core.md index 73931515..4e04fada 100644 --- a/docs/datasets/core.md +++ b/docs/datasets/core.md @@ -5,7 +5,6 @@ comments: true # Datasets !!! warning - Dataset API is still fluid and may change. If you use Dataset API in your project until further notice, freeze the `supervision` version in your `requirements.txt` or `setup.py`. diff --git a/docs/deprecated.md b/docs/deprecated.md index 725e17d5..bdd95a9d 100644 --- a/docs/deprecated.md +++ b/docs/deprecated.md @@ -10,10 +10,13 @@ These features are phased out due to better alternatives or potential issues in - The `frame_resolution_wh ` parameter in [`sv.PolygonZone`](detection/tools/polygon_zone.md/#supervision.detection.tools.polygon_zone.PolygonZone) will be removed in `supervision-0.24.0`. - 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. # Removed diff --git a/docs/how_to/detect_and_annotate.md b/docs/how_to/detect_and_annotate.md index 95d095b6..6369cce3 100644 --- a/docs/how_to/detect_and_annotate.md +++ b/docs/how_to/detect_and_annotate.md @@ -20,7 +20,6 @@ First, you'll need to obtain predictions from your object detection or segmentat model. === "Inference" - ```python import cv2 from inference import get_model @@ -31,7 +30,6 @@ model. ``` === "Ultralytics" - ```python import cv2 from ultralytics import YOLO @@ -42,7 +40,6 @@ model. ``` === "Transformers" - ```python import torch from PIL import Image @@ -68,7 +65,6 @@ model. Now that we have predictions from a model, we can load them into Supervision. === "Inference" - We can do so using the [`sv.Detections.from_inference`](/latest/detection/core/#supervision.detection.core.Detections.from_inference) method, which accepts model results from both detection and segmentation models. ```{ .py hl_lines="2 8" } @@ -83,7 +79,6 @@ Now that we have predictions from a model, we can load them into Supervision. ``` === "Ultralytics" - We can do so using the [`sv.Detections.from_ultralytics`](/latest/detection/core/#supervision.detection.core.Detections.from_ultralytics) method, which accepts model results from both detection and segmentation models. ```{ .py hl_lines="2 8" } @@ -98,7 +93,6 @@ Now that we have predictions from a model, we can load them into Supervision. ``` === "Transformers" - We can do so using the [`sv.Detections.from_transformers`](/latest/detection/core/#supervision.detection.core.Detections.from_transformers) method, which accepts model results from both detection and segmentation models. ```{ .py hl_lines="2 19-21" } @@ -138,7 +132,6 @@ You can load predictions from other computer vision frameworks and libraries usi Finally, we can annotate the image with the predictions. Since we are working with an object detection model, we will use the [`sv.BoxAnnotator`](/latest/detection/annotators/#supervision.annotators.core.BoxAnnotator) and [`sv.LabelAnnotator`](/latest/detection/annotators/#supervision.annotators.core.LabelAnnotator) classes. === "Inference" - ```{ .py hl_lines="10-16" } import cv2 import supervision as sv @@ -159,7 +152,6 @@ Finally, we can annotate the image with the predictions. Since we are working wi ``` === "Ultralytics" - ```{ .py hl_lines="10-16" } import cv2 import supervision as sv @@ -180,7 +172,6 @@ Finally, we can annotate the image with the predictions. Since we are working wi ``` === "Transformers" - ```{ .py hl_lines="23-30" } import torch import supervision as sv @@ -222,7 +213,6 @@ will label each detection with its `class_name` (if possible) or `class_id`. You override this behavior by passing a list of custom `labels` to the `annotate` method. === "Inference" - ```{ .py hl_lines="13-17 22" } import cv2 import supervision as sv @@ -249,7 +239,6 @@ override this behavior by passing a list of custom `labels` to the `annotate` me ``` === "Ultralytics" - ```{ .py hl_lines="13-17 22" } import cv2 import supervision as sv @@ -276,7 +265,6 @@ override this behavior by passing a list of custom `labels` to the `annotate` me ``` === "Transformers" - ```{ .py hl_lines="26-30 35" } import torch import supervision as sv @@ -326,7 +314,6 @@ is a drop-in replacement for that will allow you to draw masks instead of boxes. === "Inference" - ```python import cv2 import supervision as sv @@ -347,7 +334,6 @@ that will allow you to draw masks instead of boxes. ``` === "Ultralytics" - ```python import cv2 import supervision as sv @@ -368,7 +354,6 @@ that will allow you to draw masks instead of boxes. ``` === "Transformers" - ```python import torch import supervision as sv diff --git a/docs/how_to/detect_small_objects.md b/docs/how_to/detect_small_objects.md index 604b4688..054bdabf 100644 --- a/docs/how_to/detect_small_objects.md +++ b/docs/how_to/detect_small_objects.md @@ -20,7 +20,6 @@ Small object detection in high-resolution images presents challenges due to the size relative to the image resolution. === "Inference" - ```python import cv2 import supervision as sv @@ -41,7 +40,6 @@ size relative to the image resolution. ``` === "Ultralytics" - ```python import cv2 import supervision as sv @@ -62,7 +60,6 @@ size relative to the image resolution. ``` === "Transformers" - ```python import torch import supervision as sv @@ -108,7 +105,6 @@ identification at the cost of processing speed and increased memory usage. This is less effective for ultra-high-resolution images (4K and above). === "Inference" - ```{ .py hl_lines="5" } import cv2 import supervision as sv @@ -129,7 +125,6 @@ is less effective for ultra-high-resolution images (4K and above). ``` === "Ultralytics" - ```{ .py hl_lines="7" } import cv2 import supervision as sv @@ -162,7 +157,6 @@ objects within each, and aggregating the results. === "Inference" - ```{ .py hl_lines="9-14" } import cv2 import numpy as np @@ -189,7 +183,6 @@ objects within each, and aggregating the results. ``` === "Ultralytics" - ```{ .py hl_lines="9-14" } import cv2 import numpy as np @@ -216,7 +209,6 @@ objects within each, and aggregating the results. ``` === "Transformers" - ```{ .py hl_lines="13-28" } import cv2 import torch @@ -269,7 +261,6 @@ objects within each, and aggregating the results. [`InferenceSlicer`](/latest/detection/tools/inference_slicer/#supervision.detection.tools.inference_slicer.InferenceSlicer) can perform segmentation tasks too. === "Inference" - ```{ .py hl_lines="6 16 19-20" } import cv2 import numpy as np @@ -296,7 +287,6 @@ objects within each, and aggregating the results. ``` === "Ultralytics" - ```{ .py hl_lines="6 16 19-20" } import cv2 import numpy as np diff --git a/docs/how_to/filter_detections.md b/docs/how_to/filter_detections.md index 64e26618..1624d815 100644 --- a/docs/how_to/filter_detections.md +++ b/docs/how_to/filter_detections.md @@ -15,7 +15,6 @@ the filters in their applications. Allows you to select detections that belong only to one selected class. === "After" - ```python import supervision as sv @@ -30,7 +29,6 @@ Allows you to select detections that belong only to one selected class.
=== "Before" - ```python import supervision as sv @@ -49,7 +47,6 @@ Allows you to select detections that belong only to one selected class. Allows you to select detections that belong only to selected set of classes. === "After" - ```python import numpy as np import supervision as sv @@ -66,7 +63,6 @@ Allows you to select detections that belong only to selected set of classes.
=== "Before" - ```python import numpy as np import supervision as sv @@ -87,7 +83,6 @@ Allows you to select detections that belong only to selected set of classes. Allows you to select detections with specific confidence value, for example higher than selected threshold. === "After" - ```python import supervision as sv @@ -102,7 +97,6 @@ Allows you to select detections with specific confidence value, for example high
=== "Before" - ```python import supervision as sv @@ -122,7 +116,6 @@ Allows you to select detections based on their size. We define the area as the n detection in the image. In the example below, we have sifted out the detections that are too small. === "After" - ```python import supervision as sv @@ -137,7 +130,6 @@ detection in the image. In the example below, we have sifted out the detections === "Before" - ```python import supervision as sv @@ -159,7 +151,6 @@ but small on a 3840x2160 image. In such cases, we can filter out detections base occupied by them. In the example below, we remove too large detections. === "After" - ```python import supervision as sv @@ -178,7 +169,6 @@ occupied by them. In the example below, we remove too large detections. === "Before" - ```python import supervision as sv @@ -203,7 +193,6 @@ can be criteria for rejecting detection. Implementing such filtering requires a simple and fast. === "After" - ```python import supervision as sv @@ -220,7 +209,6 @@ simple and fast. === "Before" - ```python import supervision as sv @@ -242,7 +230,6 @@ Allows you to use `Detections` in combination with `PolygonZone` to weed out bou zone. In the example below you can see how to filter out all detections located in the lower part of the image. === "After" - ```python import supervision as sv @@ -259,7 +246,6 @@ zone. In the example below you can see how to filter out all detections located === "Before" - ```python import supervision as sv @@ -280,7 +266,6 @@ zone. In the example below you can see how to filter out all detections located `Detections`' greatest strength, however, is that you can build arbitrarily complex logical conditions by simply combining separate conditions using `&` or `|`. === "After" - ```python import supervision as sv @@ -297,7 +282,6 @@ zone. In the example below you can see how to filter out all detections located === "Before" - ```python import supervision as sv diff --git a/docs/how_to/save_detections.md b/docs/how_to/save_detections.md index 05d5faad..e9e14849 100644 --- a/docs/how_to/save_detections.md +++ b/docs/how_to/save_detections.md @@ -19,7 +19,6 @@ model. You can learn more on this topic in our [How to Detect and Annotate](/latest/how_to/detect_and_annotate.md) guide. === "Inference" - ```python import supervision as sv from inference import get_model @@ -34,7 +33,6 @@ model. You can learn more on this topic in our ``` === "Ultralytics" - ```python import supervision as sv from ultralytics import YOLO @@ -49,7 +47,6 @@ model. You can learn more on this topic in our ``` === "Transformers" - ```python import torch import supervision as sv @@ -83,7 +80,6 @@ and then pass the object resulting from the inference to it. Its fields are parsed and saved on disk. === "Inference" - ```{ .py hl_lines="7 12" } import supervision as sv from inference import get_model @@ -100,7 +96,6 @@ object resulting from the inference to it. Its fields are parsed and saved on di ``` === "Ultralytics" - ```{ .py hl_lines="7 12" } import supervision as sv from ultralytics import YOLO @@ -117,7 +112,6 @@ object resulting from the inference to it. Its fields are parsed and saved on di ``` === "Transformers" - ```{ .py hl_lines="9 23" } import torch import supervision as sv @@ -144,11 +138,11 @@ object resulting from the inference to it. Its fields are parsed and saved on di sink.append(detections, {}) ``` -| x_min | y_min | x_max | y_max | class_id | confidence | tracker_id | class_name | -|---------|----------|---------|----------|----------|------------|------------|------------| -| 2941.14 | 1269.31 | 3220.77 | 1500.67 | 2 | 0.8517 | | car | -| 944.889 | 899.641 | 1235.42 | 1308.80 | 7 | 0.6752 | | truck | -| 1439.78 | 1077.79 | 1621.27 | 1231.40 | 2 | 0.6450 | | car | +| x_min | y_min | x_max | y_max | class_id | confidence | tracker_id | class_name | +| ------- | ------- | ------- | ------- | -------- | ---------- | ---------- | ---------- | +| 2941.14 | 1269.31 | 3220.77 | 1500.67 | 2 | 0.8517 | | car | +| 944.889 | 899.641 | 1235.42 | 1308.80 | 7 | 0.6752 | | truck | +| 1439.78 | 1077.79 | 1621.27 | 1231.40 | 2 | 0.6450 | | car | ## Custom Fields @@ -160,7 +154,6 @@ also allows you to add custom information to each row, which can be passed via t frame index from which the detections originate. === "Inference" - ```{ .py hl_lines="8 12" } import supervision as sv from inference import get_model @@ -177,7 +170,6 @@ frame index from which the detections originate. ``` === "Ultralytics" - ```{ .py hl_lines="8 12" } import supervision as sv from ultralytics import YOLO @@ -194,7 +186,6 @@ frame index from which the detections originate. ``` === "Transformers" - ```{ .py hl_lines="10 23" } import torch import supervision as sv @@ -221,11 +212,11 @@ frame index from which the detections originate. sink.append(detections, {"frame_index": frame_index}) ``` -| x_min | y_min | x_max | y_max | class_id | confidence | tracker_id | class_name | frame_index | -|---------|----------|---------|----------|----------|------------|------------|------------|-------------| -| 2941.14 | 1269.31 | 3220.77 | 1500.67 | 2 | 0.8517 | | car | 0 | -| 944.889 | 899.641 | 1235.42 | 1308.80 | 7 | 0.6752 | | truck | 0 | -| 1439.78 | 1077.79 | 1621.27 | 1231.40 | 2 | 0.6450 | | car | 0 | +| x_min | y_min | x_max | y_max | class_id | confidence | tracker_id | class_name | frame_index | +| ------- | ------- | ------- | ------- | -------- | ---------- | ---------- | ---------- | ----------- | +| 2941.14 | 1269.31 | 3220.77 | 1500.67 | 2 | 0.8517 | | car | 0 | +| 944.889 | 899.641 | 1235.42 | 1308.80 | 7 | 0.6752 | | truck | 0 | +| 1439.78 | 1077.79 | 1621.27 | 1231.40 | 2 | 0.6450 | | car | 0 | ## Save Detections as JSON @@ -236,7 +227,6 @@ with [`sv.JSONSink`](/latest/detection/tools/save_detections/#supervision.detection.tools.csv_sink.JSONSink). === "Inference" - ```{ .py hl_lines="7" } import supervision as sv from inference import get_model @@ -253,7 +243,6 @@ with ``` === "Ultralytics" - ```{ .py hl_lines="7" } import supervision as sv from ultralytics import YOLO @@ -270,7 +259,6 @@ with ``` === "Transformers" - ```{ .py hl_lines="9" } import torch import supervision as sv diff --git a/docs/how_to/track_objects.md b/docs/how_to/track_objects.md index 6812446d..464f6b8d 100644 --- a/docs/how_to/track_objects.md +++ b/docs/how_to/track_objects.md @@ -41,7 +41,6 @@ This `callback` function will be essential in the subsequent steps of the tutori it will be modified to include tracking, labeling, and trace annotations. === "Ultralytics" - ```{ .py } import numpy as np import supervision as sv @@ -63,7 +62,6 @@ it will be modified to include tracking, labeling, and trace annotations. ``` === "Inference" - ```{ .py } import numpy as np import supervision as sv @@ -97,7 +95,6 @@ functionality, each detected object is assigned a unique tracker ID, enabling the continuous following of the object's motion path across different frames. === "Ultralytics" - ```{ .py hl_lines="6 12" } import numpy as np import supervision as sv @@ -121,7 +118,6 @@ enabling the continuous following of the object's motion path across different f ``` === "Inference" - ```{ .py hl_lines="6 12" } import numpy as np import supervision as sv @@ -153,7 +149,6 @@ in Supervision, we can overlay the tracker IDs and class labels on the detected offering a clear visual representation of each object's class and unique identifier. === "Ultralytics" - ```{ .py hl_lines="8 15-19 23-24" } import numpy as np import supervision as sv @@ -188,7 +183,6 @@ offering a clear visual representation of each object's class and unique identif ``` === "Inference" - ```{ .py hl_lines="8 15-19 23-24" } import numpy as np import supervision as sv @@ -235,7 +229,6 @@ allows for visualizing the trajectories of objects, helping in understanding the movement patterns and interactions between objects in the video. === "Ultralytics" - ```{ .py hl_lines="9 26-27" } import numpy as np import supervision as sv @@ -273,7 +266,6 @@ movement patterns and interactions between objects in the video. ``` === "Inference" - ```{ .py hl_lines="9 26-27" } import numpy as np import supervision as sv diff --git a/docs/index.md b/docs/index.md index 4bce227d..08fdb240 100644 --- a/docs/index.md +++ b/docs/index.md @@ -34,9 +34,7 @@ You can install `supervision` in a [**Python>=3.8**](https://www.python.org/) environment. !!! example "pip install (recommended)" - === "pip" - [![version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision) [![downloads](https://img.shields.io/pypi/dm/supervision)](https://pypistats.org/packages/supervision) [![license](https://img.shields.io/pypi/l/supervision)](https://github.com/roboflow/supervision/blob/main/LICENSE.md) @@ -47,9 +45,7 @@ You can install `supervision` in a ``` !!! example "conda/mamba install" - === "conda" - [![conda-recipe](https://img.shields.io/badge/recipe-supervision-green.svg)](https://anaconda.org/conda-forge/supervision) [![conda-downloads](https://img.shields.io/conda/dn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) [![conda-version](https://img.shields.io/conda/vn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) [![conda-platforms](https://img.shields.io/conda/pn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) ```bash @@ -57,7 +53,6 @@ You can install `supervision` in a ``` === "mamba" - [![mamba-recipe](https://img.shields.io/badge/recipe-supervision-green.svg)](https://anaconda.org/conda-forge/supervision) [![mamba-downloads](https://img.shields.io/conda/dn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) [![mamba-version](https://img.shields.io/conda/vn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) [![mamba-platforms](https://img.shields.io/conda/pn/conda-forge/supervision.svg)](https://anaconda.org/conda-forge/supervision) ```bash @@ -65,9 +60,7 @@ You can install `supervision` in a ``` !!! example "git clone (for development)" - === "virtualenv" - ```bash # clone repository and navigate to root directory git clone https://github.com/roboflow/supervision.git @@ -83,7 +76,6 @@ You can install `supervision` in a ``` === "poetry" - ```bash # clone repository and navigate to root directory git clone https://github.com/roboflow/supervision.git @@ -103,48 +95,48 @@ You can install `supervision` in a - **Detect and Annotate** - *** + --- - Annotate predictions from a range of object detection and segmentation models + Annotate predictions from a range of object detection and segmentation models - [:octicons-arrow-right-24: Tutorial](how_to/detect_and_annotate.md) + [:octicons-arrow-right-24: Tutorial](how_to/detect_and_annotate.md) - **Track Objects** - *** + --- - Discover how to enhance video analysis by implementing seamless object tracking + Discover how to enhance video analysis by implementing seamless object tracking - [:octicons-arrow-right-24: Tutorial](how_to/track_objects.md) + [:octicons-arrow-right-24: Tutorial](how_to/track_objects.md) - **Detect Small Objects** - *** + --- - Learn how to detect small objects in images + Learn how to detect small objects in images - [:octicons-arrow-right-24: Tutorial](how_to/detect_small_objects.md) + [:octicons-arrow-right-24: Tutorial](how_to/detect_small_objects.md) - **Count Objects Crossing Line** - *** + --- - Explore methods to accurately count and analyze objects crossing a predefined line + Explore methods to accurately count and analyze objects crossing a predefined line - [:octicons-arrow-right-24: Notebook](https://supervision.roboflow.com/latest/notebooks/count-objects-crossing-the-line/) + [:octicons-arrow-right-24: Notebook](https://supervision.roboflow.com/latest/notebooks/count-objects-crossing-the-line/) - > **Filter Objects in Zone** - *** + --- - Master the techniques to selectively filter and focus on objects within a specific zone + Master the techniques to selectively filter and focus on objects within a specific zone - **Cheatsheet** - *** + --- - Access a quick reference guide to the most common `supervision` functions + Access a quick reference guide to the most common `supervision` functions - [:octicons-arrow-right-24: Cheatsheet](https://roboflow.github.io/cheatsheet-supervision/) + [:octicons-arrow-right-24: Cheatsheet](https://roboflow.github.io/cheatsheet-supervision/) diff --git a/examples/count_people_in_zone/README.md b/examples/count_people_in_zone/README.md index d9d3cdb2..0cb20955 100644 --- a/examples/count_people_in_zone/README.md +++ b/examples/count_people_in_zone/README.md @@ -16,67 +16,76 @@ https://github.com/roboflow/supervision/assets/26109316/f84db7b5-79e2-4142-a1da- - clone repository and navigate to example directory - ```bash - git clone https://github.com/roboflow/supervision.git - cd supervision/examples/count_people_in_zone - ``` + ```bash + git clone https://github.com/roboflow/supervision.git + cd supervision/examples/count_people_in_zone + ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] - ```bash - python3 -m venv venv - source venv/bin/activate - ``` + ```bash + python3 -m venv venv + source venv/bin/activate + ``` - install required dependencies - ```bash - pip install -r requirements.txt - ``` + ```bash + pip install -r requirements.txt + ``` - download `traffic_analysis.pt` and `traffic_analysis.mov` files - ```bash - ./setup.sh - ``` + ```bash + ./setup.sh + ``` ## 🛠️ script arguments - ultralytics - - `--source_weights_path` (optional): The path to the YOLO model's weights file. - Defaults to `"yolov8x.pt"` if not specified. + - `--source_weights_path` (optional): The path to the YOLO model's weights file. + Defaults to `"yolov8x.pt"` if not specified. - - `--zone_configuration_path`: Specifies the path to the JSON file containing zone - configurations. This file defines the polygonal areas in the video where objects will - be counted. - - `--source_video_path`: The path to the source video file that will be analyzed. - - `--target_video_path` (optional): The path to save the output video with annotations. - If not provided, the processed video will be displayed in real-time. - - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO model - to filter detections. Default is `0.3`. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model. Default is `0.7`. + - `--zone_configuration_path`: Specifies the path to the JSON file containing zone + configurations. This file defines the polygonal areas in the video where objects will + be counted. + + - `--source_video_path`: The path to the source video file that will be analyzed. + + - `--target_video_path` (optional): The path to save the output video with annotations. + If not provided, the processed video will be displayed in real-time. + + - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO model + to filter detections. Default is `0.3`. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model. Default is `0.7`. - inference - - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided - directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment - variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) - to acquire your `API KEY`. - - `--model_id` (optional): Designates the Roboflow model ID to be used. The default - value is `"yolov8x-1280"`. + - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided + directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment + variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) + to acquire your `API KEY`. - - `--zone_configuration_path`: Specifies the path to the JSON file containing zone - configurations. This file defines the polygonal areas in the video where objects will - be counted. - - `--source_video_path`: The path to the source video file that will be analyzed. - - `--target_video_path` (optional): The path to save the output video with annotations. - If not provided, the processed video will be displayed in real-time. - - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO model - to filter detections. Default is `0.3`. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model. Default is `0.7`. + - `--model_id` (optional): Designates the Roboflow model ID to be used. The default + value is `"yolov8x-1280"`. + + - `--zone_configuration_path`: Specifies the path to the JSON file containing zone + configurations. This file defines the polygonal areas in the video where objects will + be counted. + + - `--source_video_path`: The path to the source video file that will be analyzed. + + - `--target_video_path` (optional): The path to save the output video with annotations. + If not provided, the processed video will be displayed in real-time. + + - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO model + to filter detections. Default is `0.3`. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model. Default is `0.7`. ## 📌 zone configuration @@ -89,35 +98,35 @@ https://github.com/roboflow/supervision/assets/26109316/f84db7b5-79e2-4142-a1da- - ultralytics - ```bash - python ultralytics_example.py \ - --zone_configuration_path data/multi-zone-config.json \ - --source_video_path data/market-square.mp4 \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 - ``` + ```bash + python ultralytics_example.py \ + --zone_configuration_path data/multi-zone-config.json \ + --source_video_path data/market-square.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 + ``` - inference - ```bash - python inference_example.py \ - --roboflow_api_key \ - --zone_configuration_path data/multi-zone-config.json \ - --source_video_path data/market-square.mp4 \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 - ``` + ```bash + python inference_example.py \ + --roboflow_api_key \ + --zone_configuration_path data/multi-zone-config.json \ + --source_video_path data/market-square.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 + ``` ## © license This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/examples/heatmap_and_track/README.md b/examples/heatmap_and_track/README.md index 0c589841..2c2fc58c 100644 --- a/examples/heatmap_and_track/README.md +++ b/examples/heatmap_and_track/README.md @@ -6,7 +6,6 @@ This script performs heatmap and tracking analysis using YOLOv8, an object-detec ByteTrack, a simple yet effective online multi-object tracking method. It uses the supervision package for multiple tasks such as drawing heatmap annotations, tracking objects, etc. - ## 💻 install - clone repository and navigate to example directory @@ -16,7 +15,7 @@ supervision package for multiple tasks such as drawing heatmap annotations, trac cd supervision/examples/heatmap_and_track ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] ```bash python3 -m venv venv @@ -32,17 +31,17 @@ supervision package for multiple tasks such as drawing heatmap annotations, trac ## 🛠️ script arguments - `--source_weights_path`: Required. Specifies the path to the weights file for the -YOLO model. This file contains the trained model data necessary for object detection. + YOLO model. This file contains the trained model data necessary for object detection. - `--source_video_path` (optional): The path to the source video file that will be -analyzed. This is the input video on which crowd analysis will be performed. -If not specified default is `people-walking.mp4` from supervision assets + analyzed. This is the input video on which crowd analysis will be performed. + If not specified default is `people-walking.mp4` from supervision assets - `--target_video_path` (optional): The path to save the output.mp4 video with annotations. - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO model -to filter detections. Default is `0.3`. This determines how confident the model should -be to recognize an object in the video. + to filter detections. Default is `0.3`. This determines how confident the model should + be to recognize an object in the video. - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold -for the model. Default is 0.7. This value is used to manage object detection accuracy, -particularly in distinguishing between different objects. + for the model. Default is 0.7. This value is used to manage object detection accuracy, + particularly in distinguishing between different objects. - `--heatmap_alpha` (optional): Opacity of the overlay mask, between 0 and 1. - `--radius` (optional): Radius of the heat circle. - `--track_threshold` (optional): Detection confidence threshold for track activation. @@ -53,11 +52,11 @@ particularly in distinguishing between different objects. ```bash python script.py \ ---source_weights_path weight.pt \ ---source_video_path input_video.mp4 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.5 \ ---target_video_path output_video.mp4 + --source_weights_path weight.pt \ + --source_video_path input_video.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 \ + --target_video_path output_video.mp4 ``` ## © license @@ -65,11 +64,11 @@ python script.py \ This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/examples/speed_estimation/README.md b/examples/speed_estimation/README.md index 46a97e5c..08a2018b 100644 --- a/examples/speed_estimation/README.md +++ b/examples/speed_estimation/README.md @@ -11,7 +11,7 @@ supervision package for multiple tasks such as tracking, annotations, etc. https://github.com/roboflow/supervision/assets/26109316/d50118c1-2ae4-458d-915a-5d860fd36f71 -> [!IMPORTANT] +> \[!IMPORTANT\] > Adjust the [`SOURCE`](https://github.com/roboflow/supervision/blob/e32b05a636dab2ea1f39299e529c4b22b8baa8da/examples/speed_estimation/ultralytics_example.py#L10) > and [`TARGET`](https://github.com/roboflow/supervision/blob/e32b05a636dab2ea1f39299e529c4b22b8baa8da/examples/speed_estimation/ultralytics_example.py#L15) > configuration if you plan to run a speed estimation script on your video file. Those must be adjusted separately for each camera view. You can learn more @@ -21,97 +21,102 @@ https://github.com/roboflow/supervision/assets/26109316/d50118c1-2ae4-458d-915a- - clone repository and navigate to example directory - ```bash - git clone https://github.com/roboflow/supervision.git - cd supervision/examples/speed_estimation - ``` + ```bash + git clone https://github.com/roboflow/supervision.git + cd supervision/examples/speed_estimation + ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] - ```bash - python3.10 -m venv venv - source venv/bin/activate - ``` + ```bash + python3.10 -m venv venv + source venv/bin/activate + ``` - install required dependencies - ```bash - pip install -r requirements.txt - ``` + ```bash + pip install -r requirements.txt + ``` - download `vehicles.mp4` file - ```bash - python3.10 video_downloader.py - ``` + ```bash + python3.10 video_downloader.py + ``` ## 🛠️ script arguments - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided - directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment - variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) - to acquire your `API KEY`. + directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment + variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) + to acquire your `API KEY`. + - `--model_id` (optional): Designates the Roboflow model ID to be used. The default - value is `"yolov8x-1280"`. + value is `"yolov8x-1280"`. - `--source_weights_path`: Required. Specifies the path to the YOLO model's weights - file, which is essential for the object detection process. This file contains the - data that the model uses to identify objects in the video. + file, which is essential for the object detection process. This file contains the + data that the model uses to identify objects in the video. + - `--source_video_path`: Required. The path to the source video file that will be - analyzed. This is the input video on which traffic flow analysis will be performed. + analyzed. This is the input video on which traffic flow analysis will be performed. + - `--target_video_path`: The path to save the output video with - annotations. If not specified, the processed video will be displayed in real-time - without being saved. + annotations. If not specified, the processed video will be displayed in real-time + without being saved. + - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO - model to filter detections. Default is `0.3`. This determines how confident the - model should be to recognize an object in the video. + model to filter detections. Default is `0.3`. This determines how confident the + model should be to recognize an object in the video. + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model. Default is 0.7. This value is used to manage object detection - accuracy, particularly in distinguishing between different objects. + for the model. Default is 0.7. This value is used to manage object detection + accuracy, particularly in distinguishing between different objects. ## ⚙️ run - yolo-nas - ```bash + ```bash python yolo_nas_example.py \ - --source_video_path data/vehicles.mp4 \ - --target_video_path data/vehicles-result.mp4 \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 - ``` + --source_video_path data/vehicles.mp4 \ + --target_video_path data/vehicles-result.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 + ``` - inference - ```bash + ```bash python inference_example.py \ - --roboflow_api_key \ - --source_video_path data/vehicles.mp4 \ - --target_video_path data/vehicles-result.mp4 \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 - ``` + --roboflow_api_key \ + --source_video_path data/vehicles.mp4 \ + --target_video_path data/vehicles-result.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 + ``` - ultralytics - ```bash + ```bash python ultralytics_example.py \ - --source_video_path data/vehicles.mp4 \ - --target_video_path data/vehicles-result.mp4 \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 - ``` + --source_video_path data/vehicles.mp4 \ + --target_video_path data/vehicles-result.mp4 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 + ``` ## © license This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/examples/time_in_zone/README.md b/examples/time_in_zone/README.md index 0a366a94..b40e29eb 100644 --- a/examples/time_in_zone/README.md +++ b/examples/time_in_zone/README.md @@ -15,23 +15,23 @@ https://github.com/roboflow/supervision/assets/26109316/d051cc8a-dd15-41d4-aa36- - clone repository and navigate to example directory - ```bash - git clone https://github.com/roboflow/supervision.git - cd supervision/examples/time_in_zone - ``` + ```bash + git clone https://github.com/roboflow/supervision.git + cd supervision/examples/time_in_zone + ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] - ```bash - python3 -m venv venv - source venv/bin/activate - ``` + ```bash + python3 -m venv venv + source venv/bin/activate + ``` - install required dependencies - ```bash - pip install -r requirements.txt - ``` + ```bash + pip install -r requirements.txt + ``` ## 🛠 scripts @@ -45,16 +45,16 @@ This script allows you to download a video from YouTube. ```bash python scripts/download_from_youtube.py \ ---url "https://www.youtube.com/watch?v=-8zyEwAa50Q" \ ---output_path "data/checkout" \ ---file_name "video.mp4" + --url "https://www.youtube.com/watch?v=-8zyEwAa50Q" \ + --output_path "data/checkout" \ + --file_name "video.mp4" ``` ```bash python scripts/download_from_youtube.py \ ---url "https://www.youtube.com/watch?v=MNn9qKG2UFI" \ ---output_path "data/traffic" \ ---file_name "video.mp4" + --url "https://www.youtube.com/watch?v=MNn9qKG2UFI" \ + --output_path "data/traffic" \ + --file_name "video.mp4" ``` ### `stream_from_file` @@ -68,14 +68,14 @@ mock a live video stream for local testing. Video will be streamed in a loop und ```bash python scripts/stream_from_file.py \ ---video_directory "data/checkout" \ ---number_of_streams 1 + --video_directory "data/checkout" \ + --number_of_streams 1 ``` ```bash python scripts/stream_from_file.py \ ---video_directory "data/traffic" \ ---number_of_streams 1 + --video_directory "data/traffic" \ + --number_of_streams 1 ``` ### `draw_zones` @@ -86,24 +86,27 @@ window where you can draw polygons on the source image or video file. The polygo be saved as a JSON file. - `--source_path`: Path to the source image or video file for drawing polygons. + - `--zone_configuration_path`: Path where the polygon annotations will be saved as a JSON file. - - `enter` - finish drawing the current polygon. + - `escape` - cancel drawing the current polygon. + - `q` - quit the drawing window. + - `s` - save zone configuration to a JSON file. ```bash python scripts/draw_zones.py \ ---source_path "data/checkout/video.mp4" \ ---zone_configuration_path "data/checkout/config.json" + --source_path "data/checkout/video.mp4" \ + --zone_configuration_path "data/checkout/config.json" ``` ```bash python scripts/draw_zones.py \ ---source_path "data/traffic/video.mp4" \ ---zone_configuration_path "data/traffic/config.json" + --source_path "data/traffic/video.mp4" \ + --zone_configuration_path "data/traffic/config.json" ``` https://github.com/roboflow/supervision/assets/26109316/9d514c9e-2a61-418b-ae49-6ac1ad6ae5ac @@ -114,33 +117,33 @@ https://github.com/roboflow/supervision/assets/26109316/9d514c9e-2a61-418b-ae49- Script to run object detection on a video file using the Roboflow Inference model. - - `--zone_configuration_path`: Path to the zone configuration JSON file. - - `--source_video_path`: Path to the source video file. - - `--model_id`: Roboflow model ID. - - `--classes`: List of class IDs to track. If empty, all classes are tracked. - - `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. - - `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. +- `--zone_configuration_path`: Path to the zone configuration JSON file. +- `--source_video_path`: Path to the source video file. +- `--model_id`: Roboflow model ID. +- `--classes`: List of class IDs to track. If empty, all classes are tracked. +- `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. +- `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. ```bash python inference_file_example.py \ ---zone_configuration_path "data/checkout/config.json" \ ---source_video_path "data/checkout/video.mp4" \ ---model_id "yolov8x-640" \ ---classes 0 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/checkout/config.json" \ + --source_video_path "data/checkout/video.mp4" \ + --model_id "yolov8x-640" \ + --classes 0 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` https://github.com/roboflow/supervision/assets/26109316/d051cc8a-dd15-41d4-aa36-d38b86334c39 ```bash python inference_file_example.py \ ---zone_configuration_path "data/traffic/config.json" \ ---source_video_path "data/traffic/video.mp4" \ ---model_id "yolov8x-640" \ ---classes 2 5 6 7 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/traffic/config.json" \ + --source_video_path "data/traffic/video.mp4" \ + --model_id "yolov8x-640" \ + --classes 2 5 6 7 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` https://github.com/roboflow/supervision/assets/26109316/5ec896d7-4b39-4426-8979-11e71666878b @@ -149,31 +152,31 @@ https://github.com/roboflow/supervision/assets/26109316/5ec896d7-4b39-4426-8979- Script to run object detection on a video stream using the Roboflow Inference model. - - `--zone_configuration_path`: Path to the zone configuration JSON file. - - `--rtsp_url`: Complete RTSP URL for the video stream. - - `--model_id`: Roboflow model ID. - - `--classes`: List of class IDs to track. If empty, all classes are tracked. - - `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. - - `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. +- `--zone_configuration_path`: Path to the zone configuration JSON file. +- `--rtsp_url`: Complete RTSP URL for the video stream. +- `--model_id`: Roboflow model ID. +- `--classes`: List of class IDs to track. If empty, all classes are tracked. +- `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. +- `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. ```bash python inference_stream_example.py \ ---zone_configuration_path "data/checkout/config.json" \ ---rtsp_url "rtsp://localhost:8554/live0.stream" \ ---model_id "yolov8x-640" \ ---classes 0 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/checkout/config.json" \ + --rtsp_url "rtsp://localhost:8554/live0.stream" \ + --model_id "yolov8x-640" \ + --classes 0 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` ```bash python inference_stream_example.py \ ---zone_configuration_path "data/traffic/config.json" \ ---rtsp_url "rtsp://localhost:8554/live0.stream" \ ---model_id "yolov8x-640" \ ---classes 2 5 6 7 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/traffic/config.json" \ + --rtsp_url "rtsp://localhost:8554/live0.stream" \ + --model_id "yolov8x-640" \ + --classes 2 5 6 7 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ```
@@ -183,68 +186,68 @@ python inference_stream_example.py \ Script to run object detection on a video file using the Ultralytics YOLOv8 model. - - `--zone_configuration_path`: Path to the zone configuration JSON file. - - `--source_video_path`: Path to the source video file. - - `--weights`: Path to the model weights file. Default is `'yolov8s.pt'`. - - `--device`: Computation device (`'cpu'`, `'mps'` or `'cuda'`). Default is `'cpu'`. - - `--classes`: List of class IDs to track. If empty, all classes are tracked. - - `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. - - `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. +- `--zone_configuration_path`: Path to the zone configuration JSON file. +- `--source_video_path`: Path to the source video file. +- `--weights`: Path to the model weights file. Default is `'yolov8s.pt'`. +- `--device`: Computation device (`'cpu'`, `'mps'` or `'cuda'`). Default is `'cpu'`. +- `--classes`: List of class IDs to track. If empty, all classes are tracked. +- `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. +- `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. ```bash python ultralytics_file_example.py \ ---zone_configuration_path "data/checkout/config.json" \ ---source_video_path "data/checkout/video.mp4" \ ---weights "yolov8x.pt" \ ---device "cpu" \ ---classes 0 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/checkout/config.json" \ + --source_video_path "data/checkout/video.mp4" \ + --weights "yolov8x.pt" \ + --device "cpu" \ + --classes 0 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` ```bash python ultralytics_file_example.py \ ---zone_configuration_path "data/traffic/config.json" \ ---source_video_path "data/traffic/video.mp4" \ ---weights "yolov8x.pt" \ ---device "cpu" \ ---classes 2 5 6 7 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/traffic/config.json" \ + --source_video_path "data/traffic/video.mp4" \ + --weights "yolov8x.pt" \ + --device "cpu" \ + --classes 2 5 6 7 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` ### `ultralytics_stream_example` Script to run object detection on a video stream using the Ultralytics YOLOv8 model. - - `--zone_configuration_path`: Path to the zone configuration JSON file. - - `--rtsp_url`: Complete RTSP URL for the video stream. - - `--weights`: Path to the model weights file. Default is `'yolov8s.pt'`. - - `--device`: Computation device (`'cpu'`, `'mps'` or `'cuda'`). Default is `'cpu'`. - - `--classes`: List of class IDs to track. If empty, all classes are tracked. - - `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. - - `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. +- `--zone_configuration_path`: Path to the zone configuration JSON file. +- `--rtsp_url`: Complete RTSP URL for the video stream. +- `--weights`: Path to the model weights file. Default is `'yolov8s.pt'`. +- `--device`: Computation device (`'cpu'`, `'mps'` or `'cuda'`). Default is `'cpu'`. +- `--classes`: List of class IDs to track. If empty, all classes are tracked. +- `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`. +- `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`. ```bash python ultralytics_stream_example.py \ ---zone_configuration_path "data/checkout/config.json" \ ---rtsp_url "rtsp://localhost:8554/live0.stream" \ ---weights "yolov8x.pt" \ ---device "cpu" \ ---classes 0 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/checkout/config.json" \ + --rtsp_url "rtsp://localhost:8554/live0.stream" \ + --weights "yolov8x.pt" \ + --device "cpu" \ + --classes 0 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ``` ```bash python ultralytics_stream_example.py \ ---zone_configuration_path "data/traffic/config.json" \ ---rtsp_url "rtsp://localhost:8554/live0.stream" \ ---weights "yolov8x.pt" \ ---device "cpu" \ ---classes 2 5 6 7 \ ---confidence_threshold 0.3 \ ---iou_threshold 0.7 + --zone_configuration_path "data/traffic/config.json" \ + --rtsp_url "rtsp://localhost:8554/live0.stream" \ + --weights "yolov8x.pt" \ + --device "cpu" \ + --classes 2 5 6 7 \ + --confidence_threshold 0.3 \ + --iou_threshold 0.7 ```
@@ -254,11 +257,11 @@ python ultralytics_stream_example.py \ This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/examples/tracking/README.md b/examples/tracking/README.md index 5f258656..cb167712 100644 --- a/examples/tracking/README.md +++ b/examples/tracking/README.md @@ -9,93 +9,100 @@ detection and Supervision for tracking and annotation. - clone repository and navigate to example directory - ```bash - git clone https://github.com/roboflow/supervision.git - cd supervision/examples/tracking - ``` + ```bash + git clone https://github.com/roboflow/supervision.git + cd supervision/examples/tracking + ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] - ```bash - python3 -m venv venv - source venv/bin/activate - ``` + ```bash + python3 -m venv venv + source venv/bin/activate + ``` - install required dependencies - ```bash - pip install -r requirements.txt - ``` + ```bash + pip install -r requirements.txt + ``` ## 🛠️ script arguments - ultralytics - - `--source_weights_path`: Required. Specifies the path to the YOLO model's weights - file, which is essential for the object detection process. This file contains the data - that the model uses to identify objects in the video. + - `--source_weights_path`: Required. Specifies the path to the YOLO model's weights + file, which is essential for the object detection process. This file contains the data + that the model uses to identify objects in the video. - - `--source_video_path`: Required. The path to the source video file to be processed. - This is the video on which object detection and annotation will be performed. - - `--target_video_path`: Required. The path where the processed video, with annotations - added, will be saved. This is your output video file. - - `--confidence_threshold` (optional): Sets the confidence level at which the model - identifies objects in the video. Default is `0.3`. A higher threshold makes the model - more selective, while a lower threshold makes it more inclusive in identifying objects. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model, defaulting to `0.7`. This parameter helps in differentiating between - distinct objects, especially in crowded scenes. + - `--source_video_path`: Required. The path to the source video file to be processed. + This is the video on which object detection and annotation will be performed. + + - `--target_video_path`: Required. The path where the processed video, with annotations + added, will be saved. This is your output video file. + + - `--confidence_threshold` (optional): Sets the confidence level at which the model + identifies objects in the video. Default is `0.3`. A higher threshold makes the model + more selective, while a lower threshold makes it more inclusive in identifying objects. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model, defaulting to `0.7`. This parameter helps in differentiating between + distinct objects, especially in crowded scenes. - inference - - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided - directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment - variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) - to acquire your `API KEY`. - - `--model_id` (optional): Designates the Roboflow model ID to be used. The default - value is `"yolov8x-1280"`. + - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided + directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment + variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) + to acquire your `API KEY`. - - `--source_video_path`: Required. The path to the source video file to be processed. - This is the video on which object detection and annotation will be performed. - - `--target_video_path`: Required. The path where the processed video, with annotations - added, will be saved. This is your output video file. - - `--confidence_threshold` (optional): Sets the confidence level at which the model - identifies objects in the video. Default is `0.3`. A higher threshold makes the model - more selective, while a lower threshold makes it more inclusive in identifying objects. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model, defaulting to `0.7`. This parameter helps in differentiating between - distinct objects, especially in crowded scenes. + - `--model_id` (optional): Designates the Roboflow model ID to be used. The default + value is `"yolov8x-1280"`. + + - `--source_video_path`: Required. The path to the source video file to be processed. + This is the video on which object detection and annotation will be performed. + + - `--target_video_path`: Required. The path where the processed video, with annotations + added, will be saved. This is your output video file. + + - `--confidence_threshold` (optional): Sets the confidence level at which the model + identifies objects in the video. Default is `0.3`. A higher threshold makes the model + more selective, while a lower threshold makes it more inclusive in identifying objects. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model, defaulting to `0.7`. This parameter helps in differentiating between + distinct objects, especially in crowded scenes. ## ⚙️ run - inference - ```bash - python inference_example.py \ - --roboflow_api_key \ - --source_video_path input.mp4 \ - --target_video_path tracking_result.mp4 - ``` + ```bash + python inference_example.py \ + --roboflow_api_key \ + --source_video_path input.mp4 \ + --target_video_path tracking_result.mp4 + ``` - ultralytics - ```bash - python ultralytics_example.py \ - --source_weights_path yolov8s.pt \ - --source_video_path input.mp4 \ - --target_video_path tracking_result.mp4 - ``` + ```bash + python ultralytics_example.py \ + --source_weights_path yolov8s.pt \ + --source_video_path input.mp4 \ + --target_video_path tracking_result.mp4 + ``` ## © license This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/examples/traffic_analysis/README.md b/examples/traffic_analysis/README.md index 3c882805..feac8d91 100644 --- a/examples/traffic_analysis/README.md +++ b/examples/traffic_analysis/README.md @@ -12,105 +12,112 @@ https://github.com/roboflow/supervision/assets/26109316/c9436828-9fbf-4c25-ae8c- - clone repository and navigate to example directory - ```bash - git clone https://github.com/roboflow/supervision.git - cd supervision/examples/traffic_analysis - ``` + ```bash + git clone https://github.com/roboflow/supervision.git + cd supervision/examples/traffic_analysis + ``` -- setup python environment and activate it [optional] +- setup python environment and activate it \[optional\] - ```bash - python3 -m venv venv - source venv/bin/activate - ``` + ```bash + python3 -m venv venv + source venv/bin/activate + ``` - install required dependencies - ```bash - pip install -r requirements.txt - ``` + ```bash + pip install -r requirements.txt + ``` - download `traffic_analysis.pt` and `traffic_analysis.mov` files - ```bash - ./setup.sh - ``` + ```bash + ./setup.sh + ``` ## 🛠️ script arguments - ultralytics - - `--source_weights_path`: Required. Specifies the path to the YOLO model's weights - file, which is essential for the object detection process. This file contains the - data that the model uses to identify objects in the video. + - `--source_weights_path`: Required. Specifies the path to the YOLO model's weights + file, which is essential for the object detection process. This file contains the + data that the model uses to identify objects in the video. - - `--source_video_path`: Required. The path to the source video file that will be - analyzed. This is the input video on which traffic flow analysis will be performed. - - `--target_video_path` (optional): The path to save the output video with - annotations. If not specified, the processed video will be displayed in real-time - without being saved. - - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO - model to filter detections. Default is `0.3`. This determines how confident the - model should be to recognize an object in the video. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model. Default is 0.7. This value is used to manage object detection - accuracy, particularly in distinguishing between different objects. + - `--source_video_path`: Required. The path to the source video file that will be + analyzed. This is the input video on which traffic flow analysis will be performed. + + - `--target_video_path` (optional): The path to save the output video with + annotations. If not specified, the processed video will be displayed in real-time + without being saved. + + - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO + model to filter detections. Default is `0.3`. This determines how confident the + model should be to recognize an object in the video. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model. Default is 0.7. This value is used to manage object detection + accuracy, particularly in distinguishing between different objects. - inference - - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided - directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment - variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) - to acquire your `API KEY`. - - `--model_id` (optional): Designates the Roboflow model ID to be used. The default - value is `"vehicle-count-in-drone-video/6"`. + - `--roboflow_api_key` (optional): The API key for Roboflow services. If not provided + directly, the script tries to fetch it from the `ROBOFLOW_API_KEY` environment + variable. Follow [this guide](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key) + to acquire your `API KEY`. - - `--source_video_path`: Required. The path to the source video file that will be - analyzed. This is the input video on which traffic flow analysis will be performed. - - `--target_video_path` (optional): The path to save the output video with - annotations. If not specified, the processed video will be displayed in real-time - without being saved. - - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO - model to filter detections. Default is `0.3`. This determines how confident the - model should be to recognize an object in the video. - - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold - for the model. Default is 0.7. This value is used to manage object detection - accuracy, particularly in distinguishing between different objects. + - `--model_id` (optional): Designates the Roboflow model ID to be used. The default + value is `"vehicle-count-in-drone-video/6"`. + + - `--source_video_path`: Required. The path to the source video file that will be + analyzed. This is the input video on which traffic flow analysis will be performed. + + - `--target_video_path` (optional): The path to save the output video with + annotations. If not specified, the processed video will be displayed in real-time + without being saved. + + - `--confidence_threshold` (optional): Sets the confidence threshold for the YOLO + model to filter detections. Default is `0.3`. This determines how confident the + model should be to recognize an object in the video. + + - `--iou_threshold` (optional): Specifies the IOU (Intersection Over Union) threshold + for the model. Default is 0.7. This value is used to manage object detection + accuracy, particularly in distinguishing between different objects. ## ⚙️ run - ultralytics - ```bash - python ultralytics_example.py \ - --source_weights_path data/traffic_analysis.pt \ - --source_video_path data/traffic_analysis.mov \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 \ - --target_video_path data/traffic_analysis_result.mov - ``` + ```bash + python ultralytics_example.py \ + --source_weights_path data/traffic_analysis.pt \ + --source_video_path data/traffic_analysis.mov \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 \ + --target_video_path data/traffic_analysis_result.mov + ``` - inference - ```bash - python inference_example.py \ - --roboflow_api_key \ - --source_video_path data/traffic_analysis.mov \ - --confidence_threshold 0.3 \ - --iou_threshold 0.5 \ - --target_video_path data/traffic_analysis_result.mov - ``` + ```bash + python inference_example.py \ + --roboflow_api_key \ + --source_video_path data/traffic_analysis.mov \ + --confidence_threshold 0.3 \ + --iou_threshold 0.5 \ + --target_video_path data/traffic_analysis_result.mov + ``` ## © license This demo integrates two main components, each with its own licensing: - ultralytics: The object detection model used in this demo, YOLOv8, is distributed - under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - You can find more details about this license here. + under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). + You can find more details about this license here. - supervision: The analytics code that powers the zone-based analysis in this demo is - based on the Supervision library, which is licensed under the - [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This - makes the Supervision part of the code fully open source and freely usable in your - projects. + based on the Supervision library, which is licensed under the + [MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This + makes the Supervision part of the code fully open source and freely usable in your + projects. diff --git a/pyproject.toml b/pyproject.toml index 6be83783..9f443b62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -236,6 +236,12 @@ skip-magic-trailing-comma = false # Like Black, automatically detect the appropriate line ending. line-ending = "auto" +[tool.codespell] +skip = "*.ipynb,poetry.lock" +count = true +quiet-level = 3 +ignore-words-list = "STrack,sTrack,strack" + [tool.setuptools] include-package-data = false diff --git a/release_process.md b/release_process.md index 3130fc9c..effaa8dd 100644 --- a/release_process.md +++ b/release_process.md @@ -6,19 +6,19 @@ It assumes you already have the code changes, as well as a draft of the release 1. Make sure you have all required changes were merged into `develop`. 2. Create and merge a PR, merging `develop` into `main`, containing: - - A commit that updates the project version in `pyproject.toml`. - - All changes made during the release. + - A commit that updates the project version in `pyproject.toml`. + - All changes made during the release. 3. Tag the commit with the new supervision version. - - make sure to pull from `main` ! - - Verify that the latest merge commits exists. `git log`. - - Run `git tag x.y.z`, with your version - - Check with `git log`. - - Run `git push origin --tags` - - Upon pushing the tag, the [PyPi](https://pypi.org/project/supervision/) should update to the new version. Check this! + - make sure to pull from `main` ! + - Verify that the latest merge commits exists. `git log`. + - Run `git tag x.y.z`, with your version + - Check with `git log`. + - Run `git push origin --tags` + - Upon pushing the tag, the [PyPi](https://pypi.org/project/supervision/) should update to the new version. Check this! 4. Open and merge a PR, merging `main` into `develop`. 5. Update the docs by running the [Supervision Release Documentation Workflow 📚](https://github.com/roboflow/supervision/actions/workflows/publish-release-docs.yml) workflow from GitHub. - - Select the `main` branch from the dropdown. + - Select the `main` branch from the dropdown. 6. Create a release on GitHub. - - Go to releases - - Assign the release notes to the tag created in step 3. - - Publish the release. + - Go to releases + - Assign the release notes to the tag created in step 3. + - Publish the release. diff --git a/supervision/detection/line_zone.py b/supervision/detection/line_zone.py index 2131c14c..93c4150d 100644 --- a/supervision/detection/line_zone.py +++ b/supervision/detection/line_zone.py @@ -369,7 +369,7 @@ class LineZoneAnnotator: label is rectangular. Returns: - Tuple[int, int]: xy, pont in an image where the label will be placed. + Tuple[int, int]: xy, point in an image where the label will be placed. """ line_angle = self._get_line_angle(line_zone) diff --git a/test/dataset/formats/test_coco.py b/test/dataset/formats/test_coco.py index b023a260..3a68894a 100644 --- a/test/dataset/formats/test_coco.py +++ b/test/dataset/formats/test_coco.py @@ -308,7 +308,7 @@ def test_group_coco_annotations_by_image_id( ), ), DoesNotRaise(), - ), # two image annotations with mask, one mask as polygon ans second as RLE + ), # two image annotations with mask, one mask as polygon and second as RLE ( [ mock_coco_annotation(