-
Notifications
You must be signed in to change notification settings - Fork 7.1k
A minor change for transforms.RandomCrop #462
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
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 for the PR!
Lint is complaining about two small details, could you fix that?
Also, I'm curious in which context you faced this problem. Usually, T.Resize(224)
resizes the image such that the minimum size is 224, while when we pass a tuple like T.Resize((224, 300))
, the image will have that exact size. So normally the user would know exactly what is the minimum length of his image. When did you face this error?
But I'm ok with merging this, because I'm planning about adding a max_size
option to T.Resize
, so this could be useful.
test/test_transforms.py
Outdated
@@ -1164,4 +1174,4 @@ def test_random_grayscale(self): | |||
|
|||
|
|||
if __name__ == '__main__': | |||
unittest.main() | |||
unittest.main() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchvision/transforms/transforms.py
Outdated
img = F.pad(img, (int((1 + self.size[1] - img.size[0]) / 2), 0)) | ||
# pad the height if needed | ||
if self.pad_if_needed and img.size[1] < self.size[0]: | ||
img = F.pad(img,(0, int((1 + self.size[0] - img.size[1]) / 2))) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
The context is texture analysis. |
I have updated the two linting errors. The Travis failure appears to not be related with my pull request. |
Yes, the failure looks spurious. Thanks! |
I just added an optional parameter that pads an image if needed so that small errors don't raise exceptions.
The option is by default turned off so that API behavior is exactly the same.
As far as I saw the test cases don't test for Exceptions so i did not add a test for the feature being off but I tested that locally.