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

Question on alignment.py #7

Closed
codeslake opened this issue Sep 28, 2021 · 4 comments
Closed

Question on alignment.py #7

codeslake opened this issue Sep 28, 2021 · 4 comments

Comments

@codeslake
Copy link

codeslake commented Sep 28, 2021

Hi,

I have a question on alignment.py in which affine transformation is patch-wisely applied. I am not an expert on deformable convolution, which I believe the code is based on, so please be patient with my question ;)

  1. In def _get_p_n(...), why do you subtract 0.5 and add 0.6 to the range? Is it for the even-size kernel?

  2. In def _get_p(...) Why do you add (self.kernel_size-1)//2+0.5 to affined transformed coordinates? Shouldn't it be (self.kernel_size-1)//2-0.5 for making coordinate range between 0~h-1?

@Tengfei-Wang
Copy link
Owner

It is for even-size kernels. Currently, the alignment only supports ever-sized kerkers. For example, when kernel size is 6, this gives a local mesh grid of [-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]^2.
In this case, add (self.kernel_size-1)//2+0.5=2.5 transform the local mesh grid to 0~5. We then add it on p_0 to obtain global mesh coordinates.

@codeslake
Copy link
Author

codeslake commented Sep 29, 2021

It is for even-size kernels. Currently, the alignment only supports ever-sized kerkers. For example, when kernel size is 6, this gives a local mesh grid of [-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]^2. In this case, add (self.kernel_size-1)//2+0.5=2.5 transform the local mesh grid to 0~5. We then add it on p_0 to obtain global mesh coordinates.

But if you add (self.kernel_size-1)//2+0.5, the range of global mesh coordinate becomes 1~h. It lies between 0~h-1 if we add (self.kernel_size-1)//2-0.5. Isn't it the global mesh coordinate that should be in range 0~h-1?

@Tengfei-Wang
Copy link
Owner

It is for even-size kernels. Currently, the alignment only supports ever-sized kerkers. For example, when kernel size is 6, this gives a local mesh grid of [-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]^2. In this case, add (self.kernel_size-1)//2+0.5=2.5 transform the local mesh grid to 0~5. We then add it on p_0 to obtain global mesh coordinates.

But if you add (self.kernel_size-1)//2+0.5, the range of global mesh coordinate becomes 1h. It lies between 0h if we add (self.kernel_size-1)//2-0.5. Isn't it the global mesh coordinate that should be in range 0~h-1?

Yes, or you may also modify the range of p_0 to [0, h-1].

@codeslake
Copy link
Author

Ok, Thanks for the answer!

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

2 participants