You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtorch_=torch.manual_seed(0)
fromtorchmetrics.segmentationimportMeanIoUmiou=MeanIoU(num_classes=3)
preds=torch.randint(0, 2, (5,))
target=torch.as_tensor((0, 1, 2, 0, 255)) # An index of 255 is a tag to be ignored.miou(preds, target)
>>>Thiswillresultinanerror
Motivation
When I generate the sample pairs, the opposite mask (assuming 3 classes), but not all pixels in the entire mask should be classified into a particular class, so I set these pixels to 255. The pixel is then ignored in the loss calculation using torch.nn.CrossEntropyLoss(ignore_index=255). However, the IOU calculation does not have this feature, which leads to errors in the IOU calculation, so I wondered if it could be made to support the ignore_index parameter as well, to ignore certain pixels.
Pitch
importtorch_=torch.manual_seed(0)
fromtorchmetrics.segmentationimportMeanIoUmiou=MeanIoU(num_classes=3, ignore_index=255) # support ignore_index param to ignore index 255preds=torch.randint(0, 2, (5,))
target=torch.as_tensor((0, 1, 2, 0, 255)) # An index of 255 is a tag to be ignored.miou(preds, target)
🚀 Feature
when we compute IOU
Motivation
When I generate the sample pairs, the opposite mask (assuming 3 classes), but not all pixels in the entire mask should be classified into a particular class, so I set these pixels to 255. The pixel is then ignored in the loss calculation using
torch.nn.CrossEntropyLoss(ignore_index=255)
. However, the IOU calculation does not have this feature, which leads to errors in the IOU calculation, so I wondered if it could be made to support the ignore_index parameter as well, to ignore certain pixels.Pitch
Alternatives
torchmetrics/src/torchmetrics/functional/segmentation/mean_iou.py
Line 42 in 62d9d32
torchmetrics/src/torchmetrics/functional/segmentation/mean_iou.py
Lines 52 to 55 in 62d9d32
Additional context
The text was updated successfully, but these errors were encountered: