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

Detection IoU ignores predictions without ground truth #2905

Open
sirtris opened this issue Jan 15, 2025 · 0 comments
Open

Detection IoU ignores predictions without ground truth #2905

sirtris opened this issue Jan 15, 2025 · 0 comments
Labels
bug / fix Something isn't working help wanted Extra attention is needed v1.6.x

Comments

@sirtris
Copy link

sirtris commented Jan 15, 2025

🐛 Bug

Hi,
in torchmetrics.detection.IntersectionOverUnion cases where a bounding box for a "non-existing" class are predicted are ignored. They should be 0 for that class instead.
Here "non-existing" means that the class does generally exist, just not in that image/examle.

To Reproduce

Take the snippet from the documentation and change the prediction:

import torch
from torchmetrics.detection import IntersectionOverUnion
preds = [
   {
       "boxes": torch.tensor([
            [296.55, 93.96, 314.97, 152.79],
            [298.55, 98.96, 314.97, 151.79]]),
       "labels": torch.tensor([4, 6]),
   }
]
target = [
   {
       "boxes": torch.tensor([
              [300.00, 100.00, 315.00, 150.00],
              [300.00, 100.00, 315.00, 150.00]
       ]),
       "labels": torch.tensor([4, 5]),
   }
]
metric = IntersectionOverUnion(class_metrics=True)
metric(preds, target)

The output is:
{'iou': tensor(0.6898), 'iou/cl_4': tensor(0.6898), 'iou/cl_5': tensor(nan)}

Expected behavior

First of all iou/cl_5 should be 0.0 instead of nan (#2778).
However I think there should also be an item with 'iou/cl_6': 0.0.

Environment

  • TorchMetrics version: 1.6.1
  • Python: 3.11.10
  • PyTorch Version: 2.5.1
@sirtris sirtris added bug / fix Something isn't working help wanted Extra attention is needed labels Jan 15, 2025
@sirtris sirtris changed the title Detection IoU ignores predictions without grond truth Detection IoU ignores predictions without ground truth Jan 15, 2025
@Borda Borda added the v1.6.x label Jan 16, 2025
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 v1.6.x
Projects
None yet
Development

No branches or pull requests

2 participants