Programming Assignment 1 - IOU

Hi, I have completed the iou function. I don’t understand why did we use max(height,0) and max(width,0) to calculate inter_area. Can somebody explain that to me please? Thank You

Intersection dimensions i.e. height and width shouldn’t be negative.
Please remove the max function and try this.

box1 = (1, 1, 3, 3)
box2 = (10, 10, 20, 20)
assert iou(box1, box2) == 0, f'Expected 0 got {iou(box1, box2)}'

I don’t understand what you’ve said

max(x, 0) will choose the maximum value. If x is greater than 0, it will choose x but if x is negative, it will choose 0. As Balaji mentioned height and width cannot be negative.

Best,
Saif.

Oh, right. Thank You