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

MeanAveragePrecision does not handle empty predictions or ground truth boxes not in xyxy format #1096

Closed
kouyk opened this issue Jun 18, 2022 · 1 comment · Fixed by #1097
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@kouyk
Copy link
Contributor

kouyk commented Jun 18, 2022

🐛 Bug

When empty ground truth or prediction boxes tensor are provided, MeanAveragePrecision crashes during the conversion to xyxy from other formats.

To Reproduce

Steps to reproduce the behavior...

  1. Have empty boxes tensor in ground truth or prediction
  2. instantiate MeanAveragePrecision with box_format='xywh'
  3. run update with the ground truth and prediction boxes
  4. conversion error

Code sample

import torch
from torchmetrics.detection.mean_ap import MeanAveragePrecision
gts = [
        dict(boxes=torch.Tensor([[10, 20, 15, 25]]), labels=torch.IntTensor([0])),
    ]
preds = [
    dict(boxes=torch.Tensor([]), scores=torch.Tensor([]), labels=torch.IntTensor([])),
]
metric = MeanAveragePrecision(box_format='xywh')
metric.update(preds, gts)

Expected behavior

torchmetrics should skip the conversion for empty boxes.

Environment

  • TorchMetrics version (and how you installed TM, e.g. conda, pip, build from source): 0.9.1 from nix
  • Python & PyTorch Version (e.g., 1.0): Python 3.9, PyTorch 1.11.0
  • Any other relevant information such as OS (e.g., Linux): Linux

Additional context

@kouyk kouyk added bug / fix Something isn't working help wanted Extra attention is needed labels Jun 18, 2022
@github-actions
Copy link

Hi! thanks for your contribution!, great first issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant