Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-219

Visual Grounding IoU

Problem

Return the intersection-over-union of two boxes given as [x1, y1, x2, y2].

Clamp the intersection width and height at 0, and return 0.0 when the union area is 0.

Hint

Union is the sum of both areas minus the intersection.

Test cases

case 1
in: [[0,0,2,2],[0,0,2,2]]
expected: 1
case 2
in: [[0,0,2,2],[1,1,3,3]]
expected: 0.14285714285714285
case 3
in: [[0,0,1,1],[2,2,3,3]]
expected: 0
case 4
in: [[0,0,0,0],[0,0,0,0]]
expected: 0
case 5
in: [[0,0,4,4],[1,1,3,3]]
expected: 0.25
Starter codePython
def visual_grounding_iou(box_a, box_b):
    # Your code here
    pass

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