All problems
Generalized IoU
Problem
Compute the generalized IoU (GIoU) of two boxes.
GIoU = IoU - (C - union) / C, where C is the area of the smallest axis-aligned box enclosing both boxes. Return the value rounded to 4 decimal places, or 0.0 when the union is empty.
Hint
GIoU is 1 for identical boxes and approaches -1 for far-apart boxes.
Test cases
case 1
in: [[0,0,2,2],[0,0,2,2]]
expected: 1
case 2
in: [[0,0,2,2],[3,3,5,5]]
expected: -0.68
case 3
in: [[0,0,2,2],[1,1,3,3]]
expected: -0.0794
case 4
in: [[0,0,4,4],[0,0,2,2]]
expected: 0.25
Starter codePython
def giou(box_a, box_b):
# Your code here
pass4 test cases · run your code against them in the editor