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

Fix #782 TransformerLayer for rectangle images #800

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

artvive
Copy link

@artvive artvive commented Feb 16, 2017

Fix issue #782
and add the corresponding test.

A few comments about this PR:

  • I chose to only modify the function _transform_affine so that it won't interfere with the TPS Transformer which uses also _interpolate and _meshgrid.
  • This is maybe at the cost of performance because I feel like doing and undoing things that could be taken care of in those two functions.
  • I am not quite satisfied by the test which is very sensitive to the rounding of the indices, so every idea is welcomed.

PS: this is my very first PR so I'd gladly receive any comment and advice.

@f0k
Copy link
Member

f0k commented Feb 16, 2017

Nice, thank you!

This is maybe at the cost of performance because I feel like doing and undoing things that could be taken care of in those two functions.

I guess the performance impact won't be too bad, but we could measure it. It's nice that the change is so local.

With this change, Theta is applied in pixel space. This means the translation must be given in pixels, not as a fraction of the input size. As I argued before, this might not be ideal, as it will require a very different value range for translations compared to rotation and shearing. Also it might make it more difficult to process images of variable input size; there's no easy way to specify cropping the top left corner, for example.
So another solution might be to figure out the aspect ratio and scale either x_s or y_s (not both), depending on whether the width or height is smaller.
In any case, the operation space of Theta should be determined by an option given to the Layer constructor. Existing networks should just work as before. So we could have three alternatives for a new grid_space or grid_domain option: pixels (your new implementation), unit_square (the old implementation, staying the default), and unit_rect (a rectangle with the longer side bounded in [0,1] and the shorter side being shorter). I'm not very sure about the naming, but does this seem sensible to you?

@artvive
Copy link
Author

artvive commented Mar 29, 2017

Yes I agree with your design principles, I'll implement them when I have time

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

Successfully merging this pull request may close these issues.

2 participants