-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Add random affine transformation #411
Conversation
torchvision/transforms/transforms.py
Outdated
format_string += ' shear={0}\n'.format(self.shear) | ||
format_string += ' resample={0}\n'.format(self.resample) | ||
format_string += ' fillcolor={0}\n'.format(self.fillcolor) | ||
format_string += ')' |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Any other feedbacks on the PR are highly appreciated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
I have a couple of minor comments, but apart from that this is very good!
torchvision/transforms/transforms.py
Outdated
format_string += ' shear={0}\n'.format(self.shear) | ||
format_string += ' resample={0}\n'.format(self.resample) | ||
format_string += ' fillcolor={0}\n'.format(self.fillcolor) | ||
format_string += ')' |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
test/test_transforms.py
Outdated
@@ -734,6 +735,109 @@ def test_rotate(self): | |||
|
|||
assert np.all(np.array(result_a) == np.array(result_b)) | |||
|
|||
def test_affine(self): | |||
x = np.zeros((100, 100, 3), dtype=np.uint8) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
if self.shear is not None: | ||
s += ', shear={shear}' | ||
if self.resample > 0: | ||
s += ', resample={resample}' |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@fmassa A precision on matching between transformed points. Take look at the example with scale.
So, I think if we keep these tests, we need to match only manually-verified set in the non-null locations of affine transformed image. |
I refactored a little the code and tests such that I compare transformation matrices and images with accepted error of max N(=3) different pixels (cause of aliasing). With such approach, tests take about 3 mins to execute because of rather bruteforce tests:
Thoughts @fmassa ? |
@fmassa can we merge this ? |
thanks @vfdev-5 |
Random affine transformations with tests.
For usage, see sanity_check.ipynb