From 93a8110908b68016cadd3ef74c2abfb7fd095c17 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Tue, 3 Oct 2023 11:38:28 +0200 Subject: [PATCH] Refactor documentation structure and improve annotator details Update the file and section structure of the project documentation for better readability. Removed 'annotate.md' and replaced it with an expanded 'annotators.md'. The new document provides examples of each annotator and includes preview images for better understanding. The API reference structure was flattened for simplicity and related documents 'core.py' and 'mkdocs.yml' were updated accordingly. The core tracker and dataset documents were renamed for consistency. --- docs/annotators.md | 149 ++++++++++++++++++++++++++ docs/{dataset/core.md => datasets.md} | 0 docs/detection/annotate.md | 23 ---- docs/{tracker/core.md => trackers.md} | 0 mkdocs.yml | 44 ++++---- supervision/annotators/core.py | 12 ++- 6 files changed, 177 insertions(+), 51 deletions(-) create mode 100644 docs/annotators.md rename docs/{dataset/core.md => datasets.md} (100%) delete mode 100644 docs/detection/annotate.md rename docs/{tracker/core.md => trackers.md} (100%) diff --git a/docs/annotators.md b/docs/annotators.md new file mode 100644 index 00000000..2077e58d --- /dev/null +++ b/docs/annotators.md @@ -0,0 +1,149 @@ +=== "BoundingBox" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> bounding_box_annotator = sv.BoundingBoxAnnotator() + >>> annotated_frame = bounding_box_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![bounding-box-annotator-example](https://media.roboflow.com/supervision-annotator-examples/bounding-box-annotator-example.png){ align=center width="800" } + +
+ +=== "Mask" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> mask_annotator = sv.MaskAnnotator() + >>> annotated_frame = mask_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![mask-annotator-example](https://media.roboflow.com/supervision-annotator-examples/mask-annotator-example.png){ align=center width="800" } + +
+ +=== "Ellipse" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> ellipse_annotator = sv.EllipseAnnotator() + >>> annotated_frame = ellipse_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![ellipse-annotator-example](https://media.roboflow.com/supervision-annotator-examples/ellipse-annotator-example.png){ align=center width="800" } + +
+ +=== "BoxCorner" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> corner_annotator = sv.BoxCornerAnnotator() + >>> annotated_frame = corner_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![box-corner-annotator-example](https://media.roboflow.com/supervision-annotator-examples/box-corner-annotator-example.png){ align=center width="800" } + +
+ +=== "Circle" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> circle_annotator = sv.CircleAnnotator() + >>> annotated_frame = circle_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![circle-annotator-example](https://media.roboflow.com/supervision-annotator-examples/circle-annotator-example.png){ align=center width="800" } + +
+ +=== "Label" + + ```python + >>> import supervision as sv + + >>> image = ... + >>> detections = sv.Detections(...) + + >>> label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER) + >>> annotated_frame = label_annotator.annotate( + ... scene=image.copy(), + ... detections=detections + ... ) + ``` + +
+ + ![label-annotator-example](https://media.roboflow.com/supervision-annotator-examples/label-annotator-example-2.png){ align=center width="800" } + +
+ +## BoundingBoxAnnotator + +:::supervision.annotators.core.BoundingBoxAnnotator + +## MaskAnnotator + +:::supervision.annotators.core.MaskAnnotator + +## EllipseAnnotator + +:::supervision.annotators.core.EllipseAnnotator + +## BoxCornerAnnotator + +:::supervision.annotators.core.BoxCornerAnnotator + +## CircleAnnotator + +:::supervision.annotators.core.CircleAnnotator + +## LabelAnnotator + +:::supervision.annotators.core.LabelAnnotator diff --git a/docs/dataset/core.md b/docs/datasets.md similarity index 100% rename from docs/dataset/core.md rename to docs/datasets.md diff --git a/docs/detection/annotate.md b/docs/detection/annotate.md deleted file mode 100644 index c548b794..00000000 --- a/docs/detection/annotate.md +++ /dev/null @@ -1,23 +0,0 @@ -## BoundingBoxAnnotator - -:::supervision.annotators.core.BoundingBoxAnnotator - -## MaskAnnotator - -:::supervision.annotators.core.MaskAnnotator - -## EllipseAnnotator - -:::supervision.annotators.core.EllipseAnnotator - -## BoxCornerAnnotator - -:::supervision.annotators.core.BoxCornerAnnotator - -## CircleAnnotator - -:::supervision.annotators.core.CircleAnnotator - -## LabelAnnotator - -:::supervision.annotators.core.LabelAnnotator diff --git a/docs/tracker/core.md b/docs/trackers.md similarity index 100% rename from docs/tracker/core.md rename to docs/trackers.md diff --git a/mkdocs.yml b/mkdocs.yml index fee74016..41054db0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -28,29 +28,27 @@ nav: - Home: index.md - Quickstart: - Detections: quickstart/detections.md - - API reference: - - Classifications: - - Core: classification/core.md - - Detections: - - Core: detection/core.md - - Annotate: detection/annotate.md - - Utils: detection/utils.md - - Tools: - - Polygon Zone: detection/tools/polygon_zone.md - - Inference Slicer: detection/tools/inference_slicer.md - - Trackers: - - Core: tracker/core.md - - Dataset: - - Core: dataset/core.md - - Metrics: - - Detection Models: metrics/detection.md - - Draw: - - Utils: draw/utils.md - - Utils: - - Video: utils/video.md - - Image: utils/image.md - - Notebook: utils/notebook.md - - File: utils/file.md + - Classifications: + - Core: classification/core.md + - Detections: + - Core: detection/core.md + - Annotate: detection/annotate.md + - Utils: detection/utils.md + - Tools: + - Polygon Zone: detection/tools/polygon_zone.md + - Inference Slicer: detection/tools/inference_slicer.md + - Annotators: annotators.md + - Trackers: trackers.md + - Datasets: datasets.md + - Metrics: + - Object Detection: metrics/detection.md + - Draw: + - Utils: draw/utils.md + - Utils: + - Video: utils/video.md + - Image: utils/image.md + - Notebook: utils/notebook.md + - File: utils/file.md - Changelog: changelog.md theme: diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index e4a4b9d2..d108af8e 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -346,13 +346,15 @@ class CircleAnnotator(BaseAnnotator): detections: Detections, ) -> np.ndarray: """ - Draws circle on the frame using the detections provided. + Annotates the given scene with circles based on the provided detections. + Args: - scene (np.ndarray): The image on which the circle will be drawn - detections (Detections): The detections for which the - circle will be drawn + scene (np.ndarray): The image where box corners will be drawn. + detections (Detections): Object detections to annotate. + Returns: - np.ndarray: The image with the circle drawn on it + np.ndarray: The annotated image. + Example: ```python >>> import supervision as sv