0
0
Computer Visionml~20 mins

Segmentation evaluation (IoU, Dice) in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Segmentation Metrics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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))
A0.43
B0.50
C0.57
D0.67
Attempts:
2 left
💡 Hint
Count how many pixels overlap and how many pixels are in either mask.
🧠 Conceptual
intermediate
1:30remaining
Understanding Dice coefficient properties
Which of the following statements about the Dice coefficient is TRUE?
ADice coefficient can be negative if masks have no overlap.
BDice coefficient measures the difference between masks, not overlap.
CDice coefficient is always smaller than IoU for the same masks.
DDice coefficient equals 1 when two masks are identical.
Attempts:
2 left
💡 Hint
Think about what perfect overlap means for Dice.
Metrics
advanced
1: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?
A0.67
B0.60
C0.75
D0.80
Attempts:
2 left
💡 Hint
Dice = 2 * TP / (2 * TP + FP + FN)
🔧 Debug
advanced
2: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)
AZeroDivisionError if union is zero
BValueError due to shape mismatch of mask1 and mask2
CTypeError because bitwise operators cannot be used on numpy arrays
DNo error, code runs correctly and prints IoU
Attempts:
2 left
💡 Hint
Consider what happens if both masks are empty.
Model Choice
expert
2: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?
AIoU, because it balances false positives and false negatives
BAccuracy, because it measures overall pixel correctness
CDice coefficient, because it is sensitive to small object overlap
DMean Squared Error, because it measures pixel intensity differences
Attempts:
2 left
💡 Hint
Think about which metric handles small object sizes better.