Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some mistake in APN #23

Closed
klrc opened this issue Dec 24, 2019 · 5 comments
Closed

Some mistake in APN #23

klrc opened this issue Dec 24, 2019 · 5 comments

Comments

@klrc
Copy link

klrc commented Dec 24, 2019

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
Copy link

Hi @klrc ,

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

jeong-tae added a commit that referenced this issue Dec 26, 2019
#23 mentioned this issue and will solve the problem.
@jeong-tae
Copy link
Owner

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]

@klrc
Copy link
Author

klrc commented Dec 26, 2019

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
Copy link
Author

klrc commented Dec 26, 2019

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
Copy link
Owner

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants