Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core system for Metrics #1442

Merged
merged 32 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7d7e5f1
Initial attempt at definining a metric
LinasKo Aug 8, 2024
b061f4f
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Aug 12, 2024
4c903cf
Metrics changes + tests
LinasKo Aug 12, 2024
d6d71a0
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Aug 12, 2024
6f566b5
Remove incorrect test
LinasKo Aug 12, 2024
4add8c8
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Aug 12, 2024
0305cee
Simplified tests
LinasKo Aug 12, 2024
3e860a5
Add invalid value test
LinasKo Aug 12, 2024
a4cf260
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Aug 12, 2024
5565241
Basic mask tests
LinasKo Aug 12, 2024
e1ffd0e
Address some review comments
LinasKo Aug 14, 2024
dabd18c
Remove duplicate box_iou_batch method
LinasKo Aug 14, 2024
b40cddd
Validate class IDs together
LinasKo Aug 14, 2024
758b9d6
Expose class_id, add missing docs
LinasKo Aug 14, 2024
0e8365f
Add dependency: typing-extensions
LinasKo Aug 14, 2024
6675844
Simplified core metrics
LinasKo Aug 15, 2024
6f47cd3
Add to_pandas to IoU
LinasKo Aug 15, 2024
85e0a54
Return dataclass for IoU. plot + as_pandas in result.
LinasKo Aug 15, 2024
ab76a47
Refactored metrics store, removed typing extensions
LinasKo Aug 16, 2024
c31d96d
Merge branch 'develop' into feat/metrics-module-initial
onuralpszr Aug 19, 2024
fe27e44
supervision metrics module
LinasKo Aug 21, 2024
a5bb93d
bugfix: hstack confidence, class_id
LinasKo Aug 26, 2024
d1e5e03
bugfix: incorrect indexing into 0-sized data in data stores
LinasKo Aug 26, 2024
026a243
Give descriptive names to data_1, data_2 in mAP
LinasKo Aug 27, 2024
84bb44d
Metrics docs overhaul
LinasKo Aug 27, 2024
57e5c10
Merge branch 'develop' into feat/metrics-module-initial
LinasKo Aug 27, 2024
ec5790a
Removed print statement internal_data_store
LinasKo Aug 27, 2024
8ff0d31
Removed internal store from mAP
LinasKo Aug 27, 2024
162f9ed
fix mAP for small/medium/large objects
LinasKo Aug 28, 2024
6ac0f84
fix small object area calculation
LinasKo Aug 28, 2024
6bb5929
Remove IoU metric for now - unclear external API
LinasKo Aug 28, 2024
55c8c07
Rename legacy metrics doc to metrics, preserve url
LinasKo Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/detection/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
comments: true
---

# Metrics
# Legacy Metrics

Starting with `0.23.0`, a new metrics module is being introduced to supervision.
Metrics here are part of the legacy evaluation API and will be deprecated in the future.

<div class="md-typeset">
<h2><a href="#supervision.metrics.detection.ConfusionMatrix">ConfusionMatrix</a></h2>
Expand Down
18 changes: 18 additions & 0 deletions docs/metrics/mean_average_precision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
comments: true
status: new
---

# Mean Average Precision

<div class="md-typeset">
<h2><a href="#supervision.metrics.mean_average_precision.MeanAveragePrecision">MeanAveragePrecision</a></h2>
</div>

:::supervision.metrics.mean_average_precision.MeanAveragePrecision

<div class="md-typeset">
<h2><a href="#supervision.metrics.mean_average_precision.MeanAveragePrecisionResult">MeanAveragePrecisionResult</a></h2>
</div>

:::supervision.metrics.mean_average_precision.MeanAveragePrecisionResult
92 changes: 44 additions & 48 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extra_css:
- stylesheets/extra.css
- stylesheets/cookbooks-card.css


nav:
- Supervision: index.md
- Learn:
Expand All @@ -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
- 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:
- mAP: metrics/mean_average_precision.md
- Legacy Metrics: detection/metrics.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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -155,8 +153,6 @@ plugins:
- git-revision-date-localized:
enable_creation_date: true



markdown_extensions:
- admonition
- pymdownx.details
Expand Down
112 changes: 111 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ scipy = [
matplotlib = ">=3.6.0"
pyyaml = ">=5.3"
defusedxml = "^0.7.1"
pillow = ">=9.4"
opencv-python = { version = ">=4.5.5.64", optional = true }
opencv-python-headless = ">=4.5.5.64"
requests = { version = ">=2.26.0,<=2.32.3", optional = true }
tqdm = { version = ">=4.62.3,<=4.66.5", optional = true }
pillow = ">=9.4"
# pandas: picked lowest major version that supports Python 3.8
pandas = { version = ">=2.0.0", optional = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onuralpszr, do we need to do something extra here?

Copy link
Collaborator

@onuralpszr onuralpszr Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SkalskiP Sorry, I miss this message because was hidden, making optional to add is correct I also see "stub" package which also optional also good. If I may I would like to also say If you need faster metrics and better RAM management, We should strongly consider "polars" as well. I can give you raw example and send you colab example what I meant about it. Plus we can convert to pandas as well. or read from pandas,numpy etc as well. So cards are still open. You saw speed of "ruff" (rust) you can see this one too.

cc : @LinasKo please check as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pandas-stubs = { version = ">=2.0.0.230412", optional = true }

[tool.poetry.extras]
desktop = ["opencv-python"]
assets = ["requests", "tqdm"]
metrics = ["pandas", "pandas-stubs"]

[tool.poetry.group.dev.dependencies]
twine = "^5.1.1"
Expand All @@ -79,7 +83,6 @@ docutils = [
{ version = "^0.21.1", python = ">=3.9" },
]


[tool.poetry.group.docs.dependencies]
mkdocs-material = { extras = ["imaging"], version = "^9.5.5" }
mkdocstrings = { extras = ["python"], version = "^0.25.2" }
Expand Down
10 changes: 10 additions & 0 deletions supervision/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from supervision.metrics.core import CLASS_ID_NONE, Metric, MetricTarget
from supervision.metrics.mean_average_precision import (
MeanAveragePrecision,
MeanAveragePrecisionResult,
)
from supervision.metrics.utils.object_size import (
ObjectSizeCategory,
get_detection_size_category,
get_object_size_category,
)
Loading