Skip to content

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Oct 19, 2017

Using PIL.Image.rotate and the current transforms API.

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.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

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.

Copy link
Contributor

@alykhantejani alykhantejani left a 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.

with self.assertRaises(TypeError):
F.rotate(x, 10)

img = Image.fromarray(x)

This comment was marked as off-topic.

self.center = center

@staticmethod
def get_params(degrees, resample, expand, center):

This comment was marked as off-topic.



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.

@alykhantejani
Copy link
Contributor

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.

@daavoo
Copy link
Contributor Author

daavoo commented Nov 8, 2017 via email

@daavoo
Copy link
Contributor Author

daavoo commented Nov 8, 2017

@alykhantejani done

Copy link
Contributor

@alykhantejani alykhantejani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @daavoo !

Copy link
Contributor

@alykhantejani alykhantejani left a 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

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.

This comment was marked as off-topic.

@alykhantejani alykhantejani merged commit 6497852 into pytorch:master Nov 9, 2017
@alykhantejani
Copy link
Contributor

Thanks @daavoo!

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