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

Add support for Transforms.Scale([w, h]) with specific width and height #133

Merged
merged 9 commits into from
Apr 6, 2017
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Transforms on PIL.Image

Rescales the input PIL.Image to the given 'size'.

If 'size' is a 2-element tuple, it will be the exactly size to scale.
If 'size' is a 2-element tuple or list, it will be the exactly size to scale.

If 'size' is a number, it will indicate the size of the smaller edge.
For example, if height > width, then image will be rescaled to (size \*
Expand Down
4 changes: 2 additions & 2 deletions torchvision/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __call__(self, tensor):

class Scale(object):
"""Rescales the input PIL.Image to the given 'size'.
If 'size' is a 2-element tuple, it will be the exactly size to scale.
If 'size' is a 2-element tuple or list, it will be the exactly size to scale.

This comment was marked as off-topic.

If 'size' is a number, it will indicate the size of the smaller edge.
For example, if height > width, then image will be
rescaled to (size * height / width, size)
Expand All @@ -124,7 +124,7 @@ class Scale(object):
"""

def __init__(self, size, interpolation=Image.BILINEAR):
assert isinstance(size, int) or (isinstance(size, tuple) and len(size) == 2)
assert isinstance(size, int) or ((isinstance(size, tuple) or isinstance(size, list)) and len(size) == 2)

This comment was marked as off-topic.

self.size = size
self.interpolation = interpolation

Expand Down