-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Conversation
if self.size is a int then scale the image with the shorter side, otherwise if self.size is a list then scale the image to self.size directly
Looks good! A few comments:
|
Ok, I will refine the code and send a PR again. |
Could you also add what I tried to do here? #136 |
I will try it today. |
Thanks. I already tested the code in my PC. It's working fine. |
@yanghuanflc @fmassa can you please get this PR merged. It is super useful and I wish to build on top of it to support numpy arrays as well. |
@yanghuanflc will you have the time to fix the comments above? If not, I'll look into completing it later today. |
Sorry for the delay, I'm busying with some events these days, I will fix it right now and send a PR again. |
Add assert of size and doc for README
Please review it again |
This looks good. One last thing, could you please add another test case in here? After that it's good to be merged. |
Actually, the linter is complaining again. Here are the messages:
|
Fix linter problem
Linter problem fixed, please review it again, sorry for all the inconvenience. |
Add test for Scale
Add test for Scale |
Add both tuple and list support for Scale.size
I also add 2-element list support for Scale.size with document modified. |
torchvision/transforms.py
Outdated
@@ -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.
This comment was marked as off-topic.
Sorry, something went wrong.
torchvision/transforms.py
Outdated
@@ -115,29 +115,34 @@ def __call__(self, tensor): | |||
|
|||
class Scale(object): | |||
"""Rescales the input PIL.Image to the given 'size'. | |||
'size' will be the size of the smaller edge. | |||
If 'size' is a 2-element tuple or list, it will be the exactly size to scale. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
I added some last comments, after that it's good to go! |
…ale.size Add order of Scale.size in document and test case for list type of Scale.size
All comments fixed and add test case for both tuple and list type of Scale.size |
Thanks! |
if self.size is a int then scale the image with the shorter side,
otherwise if self.size is a list then scale the image to self.size
directly