Address some review comments

This commit is contained in:
LinasKo 2024-08-14 15:38:50 +03:00
parent 5565241ef5
commit e1ffd0e8a9
3 changed files with 54 additions and 63 deletions

View File

@ -33,7 +33,6 @@ extra_css:
- stylesheets/extra.css
- stylesheets/cookbooks-card.css
nav:
- Supervision: index.md
- Learn:
@ -45,50 +44,50 @@ nav:
- Process Datasets: how_to/process_datasets.md
- Reference - Code API:
- Detection and Segmentation:
- Core: detection/core.md
- Annotators: detection/annotators.md
- Metrics: detection/metrics.md
- Double Detection Filter: detection/double_detection_filter.md
- Utils: detection/utils.md
- Keypoint Detection:
- Core: keypoint/core.md
- Annotators: keypoint/annotators.md
- Classification:
- Core: classification/core.md
- Tools:
- Line Zone: detection/tools/line_zone.md
- Polygon Zone: detection/tools/polygon_zone.md
- Inference Slicer: detection/tools/inference_slicer.md
- Detection Smoother: detection/tools/smoother.md
- Save Detections: detection/tools/save_detections.md
- Trackers: trackers.md
- Datasets:
- Core: datasets/core.md
- Utils: datasets/utils.md
- Utils:
- Video: utils/video.md
- Image: utils/image.md
- Iterables: utils/iterables.md
- Notebook: utils/notebook.md
- File: utils/file.md
- Draw: utils/draw.md
- Geometry: utils/geometry.md
- Assets: assets.md
- Detection and Segmentation:
- Core: detection/core.md
- Annotators: detection/annotators.md
- Metrics: detection/metrics.md
- Double Detection Filter: detection/double_detection_filter.md
- Utils: detection/utils.md
- Keypoint Detection:
- Core: keypoint/core.md
- Annotators: keypoint/annotators.md
- Classification:
- Core: classification/core.md
- Tools:
- Line Zone: detection/tools/line_zone.md
- Polygon Zone: detection/tools/polygon_zone.md
- Inference Slicer: detection/tools/inference_slicer.md
- Detection Smoother: detection/tools/smoother.md
- Save Detections: detection/tools/save_detections.md
- Trackers: trackers.md
- Datasets:
- Core: datasets/core.md
- Utils: datasets/utils.md
- Metrics:
- IoU: metrics/intersection_over_union.md
- Utils:
- Video: utils/video.md
- Image: utils/image.md
- Iterables: utils/iterables.md
- Notebook: utils/notebook.md
- File: utils/file.md
- Draw: utils/draw.md
- Geometry: utils/geometry.md
- Assets: assets.md
- Cookbooks: cookbooks.md
- Cheatsheet: https://roboflow.github.io/cheatsheet-supervision/
- Contribute:
- Contributing: contributing.md
- Code of Conduct: code_of_conduct.md
- License: license.md
- Contributing: contributing.md
- Code of Conduct: code_of_conduct.md
- License: license.md
- Release Notes:
- Changelog: changelog.md
- Deprecated: deprecated.md
- Changelog: changelog.md
- Deprecated: deprecated.md
theme:
name: 'material'
name: "material"
icon:
edit: material/pencil
logo: assets/supervision-lenny.png
@ -105,19 +104,18 @@ theme:
palette:
# Palette for light mode
- scheme: default
primary: 'custom'
primary: "custom"
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for dark mode
- scheme: slate
primary: 'custom'
primary: "custom"
toggle:
icon: material/brightness-4
name: Switch to light mode
font:
text: Roboto
code: Roboto Mono
@ -128,10 +126,10 @@ theme:
plugins:
- search
- mkdocs-jupyter:
kernel_name: python3
execute: false
include_source: True
include_requirejs: true
kernel_name: python3
execute: false
include_source: True
include_requirejs: true
- mkdocstrings:
default_handler: python
handlers:
@ -155,8 +153,6 @@ plugins:
- git-revision-date-localized:
enable_creation_date: true
markdown_extensions:
- admonition
- pymdownx.details

View File

@ -6,6 +6,7 @@ from typing import Any, Dict, Iterator, Optional, Tuple, Union
import numpy as np
import numpy.typing as npt
from typing_extensions import Self
from supervision import config
from supervision.detection.core import Detections
@ -20,15 +21,10 @@ class Metric(ABC):
"""
@abstractmethod
def update(self, *args, **kwargs) -> Metric:
def update(self, *args, **kwargs) -> Self:
"""
Add data to the metric, without computing the result.
Return the metric itself to allow method chaining, for example:
Example:
```python
result = metric.update(data).compute()
```
Return the metric itself to allow method chaining.
"""
raise NotImplementedError

View File

@ -1,14 +1,12 @@
from typing import TYPE_CHECKING, Dict, Union
from typing import Dict, Union
import numpy as np
import numpy.typing as npt
from typing_extensions import Self
from supervision.detection.core import Detections
from supervision.metrics.core import InternalMetricDataStore, Metric, MetricTarget
if TYPE_CHECKING:
pass
class IntersectionOverUnion(Metric):
def __init__(
@ -36,14 +34,15 @@ class IntersectionOverUnion(Metric):
self,
data_1: Union[npt.NDArray, Detections],
data_2: Union[npt.NDArray, Detections],
) -> Metric:
) -> Self:
"""
Add data to the metric, without computing the result.
The arguments can be:
* Boxes of shape (N, 4), float32,
* Masks of shape (N, H, W), bool
* Oriented bounding boxes of shape (N, 8), float32.
* Boxes of shape `(N, 4)`, `float32`,
* Masks of shape `(N, H, W)`, `bool`
* Oriented bounding boxes of shape `(N, 8)`, `float32`.
* Detections object.
Args: