All problems
Mask IoU Head
Problem
Compute intersection over union between a predicted and a target binary mask. If the union is empty, return 1.0.
The signature is mask_iou_head(pred_mask, target_mask). Return a float.
Hint
The IoU head helps the decoder pick the best of several mask candidates.
Test cases
case 1
in: [[[1,0],[0,1]],[[1,0],[0,1]]]
expected: 1
case 2
in: [[[1,0],[0,1]],[[0,1],[0,0]]]
expected: 0
case 3
in: [[[1,1],[1,0]],[[1,0],[1,1]]]
expected: 0.5
case 4
in: [[[0,0]],[[0,0]]]
expected: 1
case 5
in: [[[1,1],[1,1]],[[1,1],[0,1]]]
expected: 0.75
Starter codePython
def mask_iou_head(pred_mask, target_mask):
# Your code here
pass5 test cases · run your code against them in the editor