-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Unified input for resized crop op #2396
Unified input for resized crop op #2396
Conversation
top (int): Vertical component of the top left corner of the crop box. | ||
left (int): Horizontal component of the top left corner of the crop box. | ||
height (int): Height of the crop box. | ||
width (int): Width of the crop box. | ||
size (sequence or int): Desired output size. Same semantics as ``resize``. | ||
interpolation (int, optional): Desired interpolation. Default is | ||
``PIL.Image.BILINEAR``. | ||
interpolation (int, optional): Desired interpolation. Default is ``PIL.Image.BILINEAR``. |
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.
Technically, this is not "optional" (Optional is for None).
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.
yeah, this is a potential issue with the documentation: it has a default value, so the user doesn't need to specify it, so it is in some sense optional, but I see your point.
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.
Seems like it is not the only usage like that. Maybe, we can leave it for now ?
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.
yeah, sounds good to me
Codecov Report
@@ Coverage Diff @@
## master #2396 +/- ##
==========================================
+ Coverage 70.65% 70.68% +0.02%
==========================================
Files 94 94
Lines 7897 7905 +8
Branches 1241 1245 +4
==========================================
+ Hits 5580 5588 +8
+ Misses 1934 1932 -2
- Partials 383 385 +2
Continue to review full report at Codecov.
|
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, looks good to me!
There are just one question that I think could deserve a comment in the code, otherwise looks good to merge!
@@ -532,7 +532,7 @@ def resize(img: Tensor, size: List[int], interpolation: int = 2) -> Tensor: | |||
elif len(size) < 2: | |||
size_w, size_h = size[0], size[0] | |||
else: | |||
size_w, size_h = size[0], size[1] | |||
size_w, size_h = size[1], size[0] # Convention (h, w) |
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 fix!
torchvision/transforms/transforms.py
Outdated
if 0 < w <= width and 0 < h <= height: | ||
i = random.randint(0, height - h) | ||
j = random.randint(0, width - w) | ||
if 0 < w < width and 0 < h < height: |
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.
was the <=
a bug before? Or is ti because random.randint
is inclusive on end
value and torch.randint
is exclusive on end value?
torchvision/transforms/transforms.py
Outdated
i = torch.randint(0, height - h, size=(1,)).item() | ||
j = torch.randint(0, width - w, size=(1,)).item() | ||
if 0 < w <= width and 0 < h <= height: | ||
i = torch.randint(0, max(height - h, 1), size=(1,)).item() |
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.
don't we need to add a +1
to account for the previous behavior, instead of making it max(..., 1)
?
Related to #2292
Description:
T.ResizedCrop
,F.resized_crop
wont pass due to Unified input for resize op #2394)Blocked by #2394