Skip to content

Commit 3dc8bad

Browse files
committed
"updating"
1 parent 9bce844 commit 3dc8bad

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

mean_iou.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
# First Alternative Mean IoU Calculations with PyTorch
88
########################################################
99
def 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)

0 commit comments

Comments
 (0)