Closed joshuasv closed 1 month ago
The target is:
target
[ {'boxes': tensor([[ 8.0000, 70.0000, 76.0000, 110.0000], [247.0000, 131.0000, 315.0000, 175.0000], [361.0000, 177.0000, 395.0000, 203.0000]]), 'labels': tensor([0, 0, 0])} ]
The preds is:
preds
[ {'boxes': empty(size=(0, 4)), 'labels': tensor([], dtype=torch.int64), 'scores': tensor([])} ]
The last item of preds is empty, when using torchmetrics.detection.iou.IntersectionOverUnion to calculate IoU, the result is nan.
A correct iou value, i.e: 0.0
Hi! thanks for your contribution!, great first issue!
🐛 Bug
To Reproduce
The
target
is:The
preds
is:The last item of preds is empty, when using torchmetrics.detection.iou.IntersectionOverUnion to calculate IoU, the result is nan.
Code sample
```python import torch from torch import tensor from torch import empty from torchmetrics.detection import IntersectionOverUnion def calc_iou(preds: list, target: list): metric = IntersectionOverUnion() metric.update(preds, target) result = metric.compute() return result target = [ {'boxes': tensor([[ 8.0000, 70.0000, 76.0000, 110.0000], [247.0000, 131.0000, 315.0000, 175.0000], [361.0000, 177.0000, 395.0000, 203.0000]]), 'labels': tensor([0, 0, 0])} ] preds = [ {'boxes': empty(size=(0, 4)), 'labels': tensor([], dtype=torch.int64), 'scores': tensor([])} ] calc_iou(preds, target) ``` ```bash {'iou': tensor(nan)} ```Expected behavior
A correct iou value, i.e: 0.0
Environment
Additional context