🐛 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
🐛 Bug
Hi,
in
torchmetrics.detection.IntersectionOverUnioncases 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:
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_5should be 0.0 instead ofnan(#2778).However I think there should also be an item with
'iou/cl_6': 0.0.Environment