All problems
DIoU Center Penalty
Problem
Compute the center-distance penalty of distance IoU (DIoU).
The penalty is rho^2 / c^2, where rho^2 is the squared distance between the box centers and c^2 is the squared diagonal length of the smallest enclosing box. Return it rounded to 4 decimal places, or 0.0 when the enclosing diagonal is zero.
Test cases
case 1
in: [[0,0,2,2],[0,0,2,2]]
expected: 0
case 2
in: [[0,0,2,2],[2,2,4,4]]
expected: 0.25
case 3
in: [[0,0,1,1],[1,1,2,2]]
expected: 0.25
case 4
in: [[0,0,2,2],[1,1,3,3]]
expected: 0.1111
Starter codePython
def diou_penalty(box_a, box_b):
# Your code here
pass4 test cases · run your code against them in the editor