CornerNet icon indicating copy to clipboard operation
CornerNet copied to clipboard

How to compute the gaussian_radius?Who can tell me the formula about it?Thank you!

Open qiuhaining opened this issue 5 years ago • 54 comments

qiuhaining avatar May 30 '19 17:05 qiuhaining

i have the same question. i have tryed to derive the mathematical formulas.but mine is different with the author's code

fenglv12345 avatar Jun 01 '19 02:06 fenglv12345

here is one of my mathematical formulas for (r3) image

fenglv12345 avatar Jun 01 '19 02:06 fenglv12345

here is one of my mathematical formulas for (r3) image

I guess that it is the two peaks of redius value。The minimum value should be obtained from the two peaks. But,i cannot prove my guess. Your answer is the one of the peaks.

image

qiuhaining avatar Jun 01 '19 05:06 qiuhaining

for r1 image

for r2 image

for r3 image

conclusion: with great possibility,the authour's mathmatical formulas are not correct and are not corresponding to the mind in papers.

fenglv12345 avatar Jun 02 '19 02:06 fenglv12345

the correct formulas as below image

fenglv12345 avatar Jun 02 '19 03:06 fenglv12345

the correct formulas as below image

what is the redius of the object as below?? image

qiuhaining avatar Jun 03 '19 07:06 qiuhaining

compute as below image by the way,i am improving the method in this way.

fenglv12345 avatar Jun 03 '19 10:06 fenglv12345

compute as below image by the way,i am improving the method in this way.

Yes,this is the same as my idea,i look forward to the result, but,we need a dataset including various aspect ratios to confirm the idea!

qiuhaining avatar Jun 03 '19 10:06 qiuhaining

just the previous datasets like COCO is ok

fenglv12345 avatar Jun 03 '19 10:06 fenglv12345

just the previous datasets like COCO is ok

Its my code in CenterNet and it can improve the performance a little! The formula can get by MATLAB Simulink. I need time to do this.

a = min((1 - min_overlap) / (1 + min_overlap) * width, 0.5 * width) b = min((1 - min_overlap) / (1 + min_overlap) * height, 0.5 * height) return a, b

qiuhaining avatar Jun 04 '19 02:06 qiuhaining

@qiuhaining ok,can you underline the code you have changed or just a picture,because i can not easily find the diversity

fenglv12345 avatar Jun 04 '19 11:06 fenglv12345

6ff0f58b-74cc-4637-bbb9-1ea3aec26cdc

gtwell avatar Jun 06 '19 10:06 gtwell

Was this a small bug? Has someone noticed any improvement after re-typing the formulas?

ggsggs avatar Aug 06 '19 10:08 ggsggs

@ggsggs i have tried.the result is that AP is almost the same,but AR is higher. i haven't found the reason why

fenglv12345 avatar Aug 18 '19 05:08 fenglv12345

@ggsggs i have tried.the result is that AP is almost the same,but AR is higher. i haven't found the reason why

Oh, interesting. Was it a significant improvement in AR?

ggsggs avatar Aug 18 '19 16:08 ggsggs

@ggsggs the result as below: gaussian

fenglv12345 avatar Aug 19 '19 01:08 fenglv12345

@ggsggs by the way,my work is based on the paper centernet(objects as points),using the model resdcn-18

fenglv12345 avatar Aug 19 '19 01:08 fenglv12345

@ggsggs the result as below: gaussian

@fenglv12345 Thank you for the experiments. ~1-3 points higher! It's not bad at all :)

@ggsggs by the way,my work is based on the paper centernet(objects as points),using the model resdcn-18

I am also working with CenterNet(objects as points one), actually. So it is good to know.

ggsggs avatar Aug 22 '19 17:08 ggsggs

@ggsggs thanks for your reminding which make me deep into the problem,perhaps i found the reason why. And i have a idea to make the AP higher while the AP is higher. By the way,there is some other method which has the problem (COCO detection challenge . focus on the MSRA)

image

fenglv12345 avatar Aug 23 '19 00:08 fenglv12345

@fenglv12345 @ggsggs , In CenterNet I use the modified gaussian_radius you mentioned above, and keep other training parameters invariable,I use DLA34dcn, but both the AP and AR reduce. Can you tell me how you get the AR increase? Do you change any other hyper-parameter?

CF2220160244 avatar Aug 27 '19 09:08 CF2220160244

@CF2220160244 my work in based on resdcn18 ,i didn't change any hyper-parameter,maybe there is some wrong with your implement. the formula as below.or you can show me your code image

fenglv12345 avatar Aug 27 '19 13:08 fenglv12345

@fenglv12345 ,my code is:
r = 0.5*(1-np.sqrt(0.7))*np.sqrt(width ** 2 + height ** 2) return r

CF2220160244 avatar Aug 28 '19 02:08 CF2220160244

what about a and b? please understand the formula,you should also change the gaussian function,rather than just the r

fenglv12345 avatar Aug 28 '19 03:08 fenglv12345

(1)get r (2)get a and b (3)change the gasssian function as above (when you change this,you will find some details should be changed)

fenglv12345 avatar Aug 28 '19 03:08 fenglv12345

by the way,you don't have to calculate this :np.sqrt(width ** 2 + height ** 2),just use w and h

fenglv12345 avatar Aug 28 '19 03:08 fenglv12345

Thank you very much, I will try! @fenglv12345

CF2220160244 avatar Aug 28 '19 03:08 CF2220160244

@fenglv12345 Is it right? I change the code to the following,

#def gaussian2D(shape, sigma=1): def gaussian2D(shape, a=1,b=1): m, n = [(ss - 1.) / 2. for ss in shape] y, x = np.ogrid[-m:m+1,-n:n+1] #h = np.exp(-(x * x + y * y) / (2 * sigma * sigma)) h = np.exp(-(x * x ) / (2 * a/3 * a/3)-(y * y) / (2 * b/3 * b/3)) h[h < np.finfo(h.dtype).eps * h.max()] = 0 return h

def draw_umich_gaussian(heatmap, center, radius, k=1): diameter = 2 * radius + 1 height, width = heatmap.shape[0:2] gaussian = gaussian2D((diameter, diameter), a=0.1155 * width, b=0.1155 * height) #gaussian = gaussian2D((diameter, diameter), sigma=diameter / 6) x, y = int(center[0]), int(center[1]) #height, width = heatmap.shape[0:2] ....

def gaussian_radius(det_size, min_overlap=0.7): height, width = det_size r = 0.5*(1-np.sqrt(min_overlap))*np.sqrt(width ** 2 + height ** 2) return r

CF2220160244 avatar Aug 28 '19 06:08 CF2220160244

diameter = 2 * radius + 1 height, width = heatmap.shape[0:2] gaussian = gaussian2D((diameter, diameter),

the diameter should be changed, understanding the meaning of diameter and its relationship with a and b for some reason,i can't see my code now,sorry.

fenglv12345 avatar Aug 28 '19 07:08 fenglv12345

@fenglv12345 thank you! Can you tell me what is the meaning of diameter and its relationship with a and b ? I think the radius should be sigma_a and sigma_b, so i use:

def draw_umich_gaussian(heatmap, center, radius, k=1): height, width = heatmap.shape[0:2] sigma_a = 0.1155 * width/3 sigma_b = 0.1155 * height/3 diameter_a = 2 * sigma_a + 1 diameter_b = 2 * sigma_b + 1 gaussian = gaussian2D((diameter_a, diameter_b), sigma_a, sigma_b)

CF2220160244 avatar Aug 28 '19 08:08 CF2220160244

image

fenglv12345 avatar Aug 28 '19 09:08 fenglv12345