File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 77# First Alternative Mean IoU Calculations with PyTorch
88########################################################
99def mean_iou (predicted_label , label , eps = 1e-10 , num_classes = 10 ):
10+ """
11+ Calculates the mean Intersection over Union (IoU) for multiple classes between predicted labels and true labels.
12+
13+ The mean IoU is a common evaluation metric for semantic segmentation tasks.
14+ It measures the average overlap between the predicted and true labels for each class.
15+
16+ Args:
17+ predicted_label (Tensor): Predicted labels from the model.
18+ label (Tensor): True labels or ground truth values.
19+ eps (float, optional): Smoothing parameter to avoid division by zero. Default is 1e-10.
20+ num_classes (int, optional): Number of classes. Default is 10.
21+
22+ Returns:
23+ float: Mean IoU value.
24+ """
1025 with torch .no_grad ():
1126 predicted_label = F .softmax (predicted_label , dim = 1 )
1227 predicted_label = torch .argmax (predicted_label , dim = 1 )
You can’t perform that action at this time.
0 commit comments