jeong-tae / RACNN-pytorch

This is a third party implementation of RA-CNN in pytorch.
201 stars 63 forks source link

Some mistake in APN #23

Closed klrc closed 4 years ago

klrc commented 4 years ago

Hi, very nice code but seems that the APN doesn't work. there are some problems in AttentionCropFunction and I changed it as below:

            tx, ty, tl = locs[i][0], locs[i][1], locs[i][2]
            # tx = tx if tx > (in_size/3) else in_size/3
            # tx = tx if (in_size/3*2) < tx else (in_size/3*2)
            # ty = ty if ty > (in_size/3) else in_size/3
            # ty = ty if (in_size/3*2) < ty else (in_size/3*2)
            # tl = tl if tl > (in_size/3) else in_size/3
            ## this should generate a more reasonable anchor here
            tl = tl if tl > (in_size/3) else in_size/3
            tx = tx if tx > tl else tl
            tx = tx if tx < in_size-tl else in_size-tl
            ty = ty if ty > tl else tl
            ty = ty if ty < in_size-tl else in_size-tl

            w_off = int(tx-tl) if (tx-tl) > 0 else 0
            h_off = int(ty-tl) if (ty-tl) > 0 else 0
            w_end = int(tx+tl) if (tx+tl) < in_size else in_size
            h_end = int(ty+tl) if (ty+tl) < in_size else in_size

            mk = (h(x-w_off) - h(x-w_end)) * (h(y-h_off) - h(y-h_end))
            xatt = images[i] * mk

        #  xatt_cropped = xatt[:, h_off : h_end, w_off : w_end]
        ##  axis h,w here seems to be reversed wrongly?
            xatt_cropped = xatt[:, w_off: w_end, h_off: h_end] 

Hope that helps great reproduction btw 5380800a19d8bc3e09bd993f8f8ba61ea9d3458b

pshroff04 commented 4 years ago

Hi @klrc ,

Seems better 👍 Thanks for it. Is it possible to share your code if you have implemented? Thanks.

jeong-tae commented 4 years ago

Thank you! https://github.com/jeong-tae/RACNN-pytorch/commit/084bd9a7dcfa8ba4f3aa1c5ada38c39a498a9451 your code is applied in this commit.

For slicing, https://github.com/jeong-tae/RACNN-pytorch/issues/6 this will help you to understand why I set xatt_cropped = xatt[:, h_off : h_end, w_off : w_end]

klrc commented 4 years ago

Hi @klrc ,

Seems better +1 Thanks for it. Is it possible to share your code if you have implemented? Thanks.

Hi @pshroff04 my implementation here: RACNN-pytorch the author also applied these changes, you can try the code now.

but I'm still confused on the xatt_cropped = xatt[:, h_off : h_end, w_off : w_end], it just doesn't work, maybe it's because of my other changes. you are welcome to try both!

klrc commented 4 years ago

Thank you! 084bd9a your code is applied in this commit.

For slicing, #6 this will help you to understand why I set xatt_cropped = xatt[:, h_off : h_end, w_off : w_end]

Hi @jeong-tae , I'm still confused about the slicing, but it should be ok! Thanks for the reply !

jeong-tae commented 4 years ago

@klrc I will figure out soon. I am very shame that I can't work to fix this problem right now. As this repository getting attention of yours, I feel some responsibility to provide good reproduction.

When I am available to fix this, I guess I can help you guys. If figure out before then, please let me know. Thank you