whai362 / pan_pp.pytorch

Official implementations of PSENet, PAN and PAN++.
Apache License 2.0
439 stars 90 forks source link

Regarding pa.pyx #4

Closed liuch37 closed 4 years ago

liuch37 commented 4 years ago

Hi,

I try to run your code and figure out that in your last line in pa.pyx

return _pa(kernels[:-1], emb, label, cc, kernel_num, label_num, min_area)

Looks like this should be

return _pa(kernels, emb, label, cc, kernel_num, label_num, min_area)

So that we can scan over all kernels (you skip the last kernel) and there is no crash in this function. Am I correct?

Thanks.

whai362 commented 4 years ago

"return _pa(kernels[:-1], emb, label, cc, kernel_num, label_num, min_area)" is right. The last kernel has been used to generate "label".

liuch37 commented 4 years ago

Hi,

sorry to follow up, in your 'get_results' function you define:

kernels = out[:, :2, :, :] > 0

so we know there is only two dimensions for kernels (kernel 0 and kernel 1) (by ignoring batch).

But in your pa.pyx you have the following statement:

if kernels[kernel_idx, tmpx, tmpy] == 0

kernel_idx starts from 1 since kernel_num is 2.

If you pass kernels[:-1] to _pa, there will be only kernel 0 being left and hence the above 'if' condition will crash at kernel_idx==1. This is what happens when I run the code. Is there any comment on this?

Thanks again.

whai362 commented 4 years ago

I have fixed this bug in the newest push. Fortunately, the performance has no change. Thank you for your reminder!