My use case is pretty much the same with this example:
from torchmetrics import JaccardIndex
import torch
pred = torch.tensor([1, 2, 19, 17, 17])
target = torch.tensor([1, 2, 3, 17, 4])
jaccard = JaccardIndex(num_classes=21)
jaccard(pred, pred)
Out: tensor([0., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
0., 1., 0.])
How can I correctly calculate mIoU between pred and target when there are non-present classes? In other words, I don’t want it to simply assign zero to classes that were not even present in the test dataset. Also, we need to consider the zeros only if it is really a wrong prediction, instead of an absent class.