Challenge - 5 Problems
Segmentation Metrics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Calculate IoU for two binary masks
Given two binary masks representing segmentation results, what is the output of the following code calculating the Intersection over Union (IoU)?
Computer Vision
import numpy as np mask1 = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 0]]) mask2 = np.array([[1, 1, 0], [0, 1, 0], [1, 0, 1]]) intersection = np.logical_and(mask1, mask2).sum() union = np.logical_or(mask1, mask2).sum() iou = intersection / union print(round(iou, 2))
Attempts:
2 left
💡 Hint
Count how many pixels overlap and how many pixels are in either mask.
✗ Incorrect
IoU is the ratio of overlapping pixels (intersection) to total pixels covered by either mask (union). Here, intersection is 3 and union is 6, so IoU = 3/6 = 0.50.
🧠 Conceptual
intermediate1:30remaining
Understanding Dice coefficient properties
Which of the following statements about the Dice coefficient is TRUE?
Attempts:
2 left
💡 Hint
Think about what perfect overlap means for Dice.
✗ Incorrect
Dice coefficient ranges from 0 to 1, with 1 meaning perfect overlap (identical masks). It cannot be negative. Dice is usually larger than IoU for the same masks.
❓ Metrics
advanced1:30remaining
Calculate Dice coefficient from confusion matrix values
Given true positives (TP)=30, false positives (FP)=10, and false negatives (FN)=20, what is the Dice coefficient?
Attempts:
2 left
💡 Hint
Dice = 2 * TP / (2 * TP + FP + FN)
✗ Incorrect
Dice = 2*30 / (2*30 + 10 + 20) = 60 / 90 = 0.67
🔧 Debug
advanced2:00remaining
Identify the error in IoU calculation code
What error does the following code produce when calculating IoU for two numpy arrays mask1 and mask2?
Computer Vision
intersection = (mask1 & mask2).sum() union = (mask1 | mask2).sum() iou = intersection / union print(iou)
Attempts:
2 left
💡 Hint
Consider what happens if both masks are empty.
✗ Incorrect
If both masks are empty, union is zero causing division by zero error.
❓ Model Choice
expert2:30remaining
Choosing the best metric for imbalanced segmentation
You have a segmentation task where the object occupies only 1% of the image pixels. Which metric is most reliable to evaluate your model's performance?
Attempts:
2 left
💡 Hint
Think about which metric handles small object sizes better.
✗ Incorrect
Dice coefficient is more sensitive to overlap in small objects and less biased by large background pixels than accuracy or MSE.