lucasjinreal / CenterNet_Pro_Max

Experiments based on CenterNet (more backbones, TensorRT deployment and mask head)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Original code of gaussian_radius has been fixed

kikirizki opened this issue · comments

the code for gaussian radius from CenterNet repo was brought from Cornernet and the gaussian_radius() function is wrong, it has been fixed by the author here is the code

def gaussian_radius(det_size, min_overlap):
    height, width = det_size

    a1  = 1
    b1  = (height + width)
    c1  = width * height * (1 - min_overlap) / (1 + min_overlap)
    sq1 = np.sqrt(b1 ** 2 - 4 * a1 * c1)
    r1  = (b1 - sq1) / (2 * a1)

    a2  = 4
    b2  = 2 * (height + width)
    c2  = (1 - min_overlap) * width * height
    sq2 = np.sqrt(b2 ** 2 - 4 * a2 * c2)
    r2  = (b2 - sq2) / (2 * a2)

    a3  = 4 * min_overlap
    b3  = -2 * min_overlap * (height + width)
    c3  = (min_overlap - 1) * width * height
    sq3 = np.sqrt(b3 ** 2 - 4 * a3 * c3)
    r3  = (b3 + sq3) / (2 * a3)
    return min(r1, r2, r3)

Please refer to this for formula derivation
princeton-vl/CornerNet#110

thanks for this useful info!

what's the side effect due to wrong gaussian radius anyway?

@fenglv12345 show significant improvement in average recall princeton-vl/CornerNet#110 (comment)

got it, will try it

thanks for this useful info!

what's the side effect due to wrong gaussian radius anyway?

Lower average recall

commented

the code for gaussian radius from CenterNet repo was brought from Cornernet and the gaussian_radius() function is wrong, it has been fixed by the author here is the code
def gaussian_radius(det_size, min_overlap):
height, width = det_size

a1  = 1
b1  = (height + width)
c1  = width * height * (1 - min_overlap) / (1 + min_overlap)
sq1 = np.sqrt(b1 ** 2 - 4 * a1 * c1)
r1  = (b1 - sq1) / (2 * a1)

a2  = 4
b2  = 2 * (height + width)
c2  = (1 - min_overlap) * width * height
sq2 = np.sqrt(b2 ** 2 - 4 * a2 * c2)
r2  = (b2 - sq2) / (2 * a2)

a3  = 4 * min_overlap
b3  = -2 * min_overlap * (height + width)
c3  = (min_overlap - 1) * width * height
sq3 = np.sqrt(b3 ** 2 - 4 * a3 * c3)
r3  = (b3 + sq3) / (2 * a3)
return min(r1, r2, r3)

Please refer to this for formula derivation
princeton-vl/CornerNet#110

for r1 and r2, why is b-sq not b+sq? they all are positive.