mmpretrain
mmpretrain copied to clipboard
update metric mAP@k for image retrieval
Motivation
Support mAP@k in image retrieval
Use cases
from mmcls.evaluation.metrics import RetrievalAveragePrecision
index = torch.Tensor([idx for idx in range(100)])
target = torch.Tensor([0, 3, 6, 8, 35,
101, 102, 103, 104, 105,
201, 202, 203, 204, 205])
max_predictions = 100
result = RetrievalAveragePrecision.calculate(index, target, max_predictions)
print(f'mAP@{k} is {result}.')
# mAP@100 is 0.16746031746031745
Checklist
Before PR:
- [ ] Pre-commit or other linting tools are used to fix the potential lint issues.
- [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
- [ ] The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
- [ ] The documentation has been modified accordingly, like docstring or example tutorials.
After PR:
- [ ] If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
- [ ] CLA has been signed and all committers have signed the CLA in this PR.
Codecov Report
Base: 0.02% // Head: 86.82% // Increases project coverage by +86.80%
:tada:
Coverage data is based on head (
d2c51c6
) compared to base (b8b31e9
). Patch has no changes to coverable lines.
:exclamation: Current head d2c51c6 differs from pull request most recent head e6d49dc. Consider uploading reports for the commit e6d49dc to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## dev-1.x #980 +/- ##
============================================
+ Coverage 0.02% 86.82% +86.80%
============================================
Files 121 169 +48
Lines 8217 14016 +5799
Branches 1368 2227 +859
============================================
+ Hits 2 12170 +12168
+ Misses 8215 1462 -6753
- Partials 0 384 +384
Flag | Coverage Δ | |
---|---|---|
unittests | 86.82% <ø> (+86.80%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
mmcls/datasets/transforms/compose.py | ||
mmcls/models/utils/norm.py | 80.00% <0.00%> (ø) |
|
mmcls/evaluation/metrics/retrieval.py | 86.61% <0.00%> (ø) |
|
mmcls/models/backbones/xcit.py | 82.78% <0.00%> (ø) |
|
mmcls/datasets/multi_task.py | 74.46% <0.00%> (ø) |
|
mmcls/models/classifiers/hugging_face.py | 25.64% <0.00%> (ø) |
|
mmcls/utils/analyze.py | 100.00% <0.00%> (ø) |
|
mmcls/models/backbones/mvit.py | 92.46% <0.00%> (ø) |
|
mmcls/models/retrievers/__init__.py | 100.00% <0.00%> (ø) |
|
mmcls/evaluation/metrics/multi_task.py | 94.59% <0.00%> (ø) |
|
... and 160 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.