-
Notifications
You must be signed in to change notification settings - Fork 7.2k
add rotate and RandomRotation to transforms #303
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
Conversation
torchvision/transforms.py
Outdated
return img | ||
|
||
|
||
def rotate(img, angle, resample=False, expand=False, center=None, translate=None): |
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.
torchvision/transforms.py
Outdated
angle += 360 | ||
else: | ||
angle -= 360 | ||
warnings.warn("You could use {} as angle to obtain the same result". format(angle)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchvision/transforms.py
Outdated
if not _is_pil_image(img): | ||
raise TypeError('img should be PIL Image. Got {}'.format(type(img))) | ||
|
||
if angle < -360 or angle > 360: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
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.
Thanks @daavoo, this looks pretty good. I just have a minor comment about the get_params
method.
test/test_transforms.py
Outdated
with self.assertRaises(TypeError): | ||
F.rotate(x, 10) | ||
|
||
img = Image.fromarray(x) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchvision/transforms/transforms.py
Outdated
self.center = center | ||
|
||
@staticmethod | ||
def get_params(degrees, resample, expand, center): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchvision/transforms/transforms.py
Outdated
|
||
|
||
class RandomRotation(object): | ||
"""Rotate the image by angle and then (optionally) translate it by (n_columns, n_rows) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Hey @daavoo, We're thinking of cutting a new release of torchvision soon, It'd be good to get this in too. I think this is pretty good to go except for the minor changes. If you can make those, this is good to merge. |
Sure thing.
El 8 nov. 2017 15:27, "Alykhan Tejani" <notifications@github.com> escribió:
… Hey @daavoo <https://github.com/daavoo>,
We're thinking of cutting a new release of torchvision soon, It'd be good
to get this in too. I think this is pretty good to go except for the minor
changes. If you can make those, this is good to merge.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#303 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AMFyZVC4zTiPGlBupNAg7RZM1GYYINQ3ks5s0bo5gaJpZM4P_MFr>
.
|
@alykhantejani done |
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.
Thanks @daavoo !
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.
@daavoo the tests also need to be updated to call get_params
with only 1 arg
test/test_transforms.py
Outdated
assert params[0] > -10 and params[0] < 10 | ||
|
||
t = transforms.RandomRotation((-10, 10)) | ||
params = t.get_params(t.degrees, t.resample, t.expand, t.center) |
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.
Thanks @daavoo! |
Using PIL.Image.rotate and the current transforms API.