Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-331

Segmentation IoU with Ignore Label

Problem

Compute foreground IoU while ignoring pixels whose target equals ignore. Remaining pixels contribute to the intersection when both maps are 1 and to the union when either map is 1.

Return intersection / union rounded to 4 decimal places, or 0.0 when the union is empty.

Test cases

case 1
in: [[[1,0],[1,1]],[[1,1],[1,-1]],-1]
expected: 0.6667
case 2
in: [[[0,0],[0,0]],[[0,0],[1,1]],-1]
expected: 0
case 3
in: [[[1,1]],[[1,1]],-1]
expected: 1
case 4
in: [[[0,1]],[[-1,-1]],-1]
expected: 0
Starter codePython
def seg_iou_ignore(pred, target, ignore):
    # Your code here
    pass

4 test cases · run your code against them in the editor