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

COCO mAP metric #2901

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
34a1a3f
Keep only cocomap-related changes
sadra-barikbin May 17, 2023
24fe980
Some improvements
sadra-barikbin May 28, 2023
e2ac8ee
Update docs
sadra-barikbin May 28, 2023
e4683de
Merge branch 'master' into cocomap
sadra-barikbin May 28, 2023
7cf53e1
Fix a bug in docs
sadra-barikbin May 29, 2023
4aa9c5d
Fix a tiny bug related to allgather
sadra-barikbin Jun 15, 2023
950c388
Fix a few bugs
sadra-barikbin Jun 16, 2023
9f5f796
Redesign code:
sadra-barikbin Jun 16, 2023
ffb1ba4
Merge branch 'master' into cocomap
sadra-barikbin Jun 16, 2023
65cdd08
Remove all_gather with different shape
sadra-barikbin Jun 17, 2023
e54af52
Merge branch 'master' into cocomap
sadra-barikbin Jun 21, 2023
aac2e55
Add test for all_gather_with_different_shape func
sadra-barikbin Jun 21, 2023
4cf3972
Merge branch 'master' into cocomap
vfdev-5 Jun 21, 2023
6070e18
A few improvements
sadra-barikbin Aug 23, 2023
aa83e60
Merge remote-tracking branch 'upstream/cocomap' into cocomap
sadra-barikbin Aug 23, 2023
deebbde
Add an output transform
sadra-barikbin Aug 31, 2023
62ca5fb
Add a test for the output_transform
sadra-barikbin Aug 31, 2023
418fcf4
Remove 'flavor' because all DeciAI, Ultralytics, Detectron and pycoco…
sadra-barikbin Sep 1, 2023
5fea0cd
Merge branch 'master' into cocomap
sadra-barikbin Sep 1, 2023
79fa1e2
Revert Metric change and a few bug fix
sadra-barikbin Sep 10, 2023
26c96b8
A tiny improvement in local variable names
sadra-barikbin Sep 15, 2023
d18f793
Merge branch 'master' into cocomap
sadra-barikbin Sep 15, 2023
a361ca8
Add max_dep and area_range
sadra-barikbin Dec 4, 2023
ce48583
some improvements
sadra-barikbin Jun 28, 2024
cf02dc0
Improvement in code
sadra-barikbin Jul 11, 2024
1593dfb
Some improvements
sadra-barikbin Jul 12, 2024
e425e12
Fix a bug; Some improvements; Improve docs
sadra-barikbin Jul 16, 2024
bb15f0f
Fix metrics.rst
sadra-barikbin Jul 16, 2024
a184ba5
Merge branch 'master' into cocomap
sadra-barikbin Jul 16, 2024
6fcc97f
Remove @override which is for 3.12
sadra-barikbin Jul 16, 2024
120c755
Fix mypy issues
sadra-barikbin Jul 16, 2024
7c26d08
Fix two tests
sadra-barikbin Jul 16, 2024
c3c4a82
Fix a typo in tests
sadra-barikbin Jul 16, 2024
2405937
Fix dist tests
sadra-barikbin Jul 16, 2024
9b3100d
Merge branch 'master' into cocomap
sadra-barikbin Sep 3, 2024
356f618
Add common obj. det. metrics
sadra-barikbin Sep 3, 2024
bbfc4c7
Merge branch 'master' into cocomap
sadra-barikbin Sep 3, 2024
cb6a328
Change an annotation for the sake of M1 python3.8
sadra-barikbin Sep 3, 2024
248fe89
Use if check on torch.double usages for MPS backend
sadra-barikbin Sep 3, 2024
8bfb802
Fix a typo
sadra-barikbin Sep 4, 2024
4038c2b
Fix a bug related to tensors on same devices
sadra-barikbin Sep 4, 2024
4b6afdd
Fix a bug related to MPS and torch.double
sadra-barikbin Sep 4, 2024
d0e82b3
Fix a bug related to MPS
sadra-barikbin Sep 4, 2024
085e0df
Fix a bug related to MPS
sadra-barikbin Sep 4, 2024
3658f95
Fix a bug related to MPS
sadra-barikbin Sep 4, 2024
0444933
Resolve MPS's lack of cummax
sadra-barikbin Sep 4, 2024
c433718
Revert MPS fallback
sadra-barikbin Sep 4, 2024
dacf407
Apply comments
sadra-barikbin Sep 4, 2024
67454c3
Merge branch 'master' into cocomap
sadra-barikbin Sep 5, 2024
67e38c4
Revert unnecessary changes
sadra-barikbin Sep 5, 2024
978791b
Merge branch 'master' into cocomap
vfdev-5 Sep 9, 2024
7b43c69
Apply review comments
sadra-barikbin Sep 20, 2024
4d3fc57
Merge branch 'master' into cocomap
sadra-barikbin Sep 20, 2024
479d1b7
Merge branch 'master' into cocomap
sadra-barikbin Sep 29, 2024
954d130
Skip MPS on test_integraion as well
sadra-barikbin Sep 29, 2024
d2978cf
Merge branch 'master' into cocomap
sadra-barikbin Oct 5, 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
4 changes: 4 additions & 0 deletions docs/source/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,17 @@ Complete list of metrics
Frequency
Loss
MeanAbsoluteError
MeanAveragePrecision
MeanPairwiseDistance
MeanSquaredError
metric.Metric
metric_group.MetricGroup
metrics_lambda.MetricsLambda
MultiLabelConfusionMatrix
MutualInformation
ObjectDetectionAvgPrecisionRecall
CommonObjectDetectionMetrics
vision.object_detection_average_precision_recall.coco_tensor_list_to_dict_list
precision.Precision
PSNR
recall.Recall
Expand Down
10 changes: 10 additions & 0 deletions ignite/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ignite.metrics.loss import Loss
from ignite.metrics.maximum_mean_discrepancy import MaximumMeanDiscrepancy
from ignite.metrics.mean_absolute_error import MeanAbsoluteError
from ignite.metrics.mean_average_precision import MeanAveragePrecision
from ignite.metrics.mean_pairwise_distance import MeanPairwiseDistance
from ignite.metrics.mean_squared_error import MeanSquaredError
from ignite.metrics.metric import BatchFiltered, BatchWise, EpochWise, Metric, MetricUsage
Expand All @@ -38,6 +39,11 @@
from ignite.metrics.running_average import RunningAverage
from ignite.metrics.ssim import SSIM
from ignite.metrics.top_k_categorical_accuracy import TopKCategoricalAccuracy
from ignite.metrics.vision.object_detection_average_precision_recall import (
coco_tensor_list_to_dict_list,
CommonObjectDetectionMetrics,
ObjectDetectionAvgPrecisionRecall,
)

__all__ = [
"Metric",
Expand Down Expand Up @@ -88,4 +94,8 @@
"PrecisionRecallCurve",
"RocCurve",
"ROC_AUC",
"MeanAveragePrecision",
"ObjectDetectionAvgPrecisionRecall",
"CommonObjectDetectionMetrics",
"coco_tensor_list_to_dict_list",
]
394 changes: 394 additions & 0 deletions ignite/metrics/mean_average_precision.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ignite/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def _is_list_of_tensors_or_numbers(x: Sequence[Union[torch.Tensor, float]]) -> b
return isinstance(x, Sequence) and all([isinstance(t, (torch.Tensor, Number)) for t in x])


def _to_batched_tensor(x: Union[torch.Tensor, float], device: Optional[torch.device] = None) -> torch.Tensor:
def _to_batched_tensor(x: Union[torch.Tensor, Number], device: Optional[torch.device] = None) -> torch.Tensor:
if isinstance(x, torch.Tensor):
return x.unsqueeze(dim=0)
return torch.tensor([x], device=device)
18 changes: 14 additions & 4 deletions ignite/metrics/metric_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Sequence
from typing import Any, Callable, Dict, Sequence, Tuple

import torch

Expand All @@ -15,6 +15,11 @@ class MetricGroup(Metric):
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
form expected by the metric. `output_transform` of each metric in the group is also
called upon its update.
skip_unrolling: specifies whether output should be unrolled before being fed to update method. Should be
true for multi-output model, for example, if ``y_pred`` and ``y`` contain multi-ouput as
``(y_pred_a, y_pred_b)`` and ``(y_a, y_b)``, in which case the update method is called for
``(y_pred_a, y_a)`` and ``(y_pred_b, y_b)``.Alternatively, ``output_transform`` can be used to handle
this.

Examples:
We construct a group of metrics, attach them to the engine at once and retrieve their result.
Expand All @@ -34,13 +39,18 @@ class MetricGroup(Metric):

# And also altogether
state.metrics["eval_metrics"]

.. versionchanged:: 0.5.2
``skip_unrolling`` argument is added.
"""

_state_dict_all_req_keys = ("metrics",)
_state_dict_all_req_keys: Tuple[str, ...] = ("metrics",)

def __init__(self, metrics: Dict[str, Metric], output_transform: Callable = lambda x: x):
def __init__(
self, metrics: Dict[str, Metric], output_transform: Callable = lambda x: x, skip_unrolling: bool = False
):
self.metrics = metrics
super(MetricGroup, self).__init__(output_transform=output_transform)
super(MetricGroup, self).__init__(output_transform=output_transform, skip_unrolling=skip_unrolling)

def reset(self) -> None:
for m in self.metrics.values():
Expand Down
3 changes: 3 additions & 0 deletions ignite/metrics/vision/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ignite.metrics.vision.object_detection_average_precision_recall import ObjectDetectionAvgPrecisionRecall

__all__ = ["ObjectDetectionAvgPrecisionRecall"]
Loading
Loading