-
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Choose either 'long' or 'short' options for the resize anchor edge if the size variable is scalar #8358
Comments
Thanks for the feature request @sidijju . In order to get There's been discussion of adding an
The first 3 are already implemented, the last one isn't. Any thoughts @pmeier @vfdev-5 ? |
Thanks for the reply @NicolasHug! I agree that setting I think the proposal for a |
Thanks for your feedback @sidijju . I'm happy to review a PR from you if you'd like to try to submit one. Our contributing guide is here: https://github.com/pytorch/vision/blob/main/CONTRIBUTING.md For this specific change you'd only need to update |
馃殌 The feature
Choose either 'long' or 'short' options for the resize anchor edge if the size variable is scalar
Motivation, pitch
torchvision.transforms.Resize()
does not provide a clean interface for resizing images based off the longer edge.Consider the following use case - a user wants to resize a set of images such that the dimensions are constrained by
size
, e.g. the longer edge of the images is always equal tosize
. Consider two images of size[1000, 500]
and[500, 1000]
. We want to resize both such that the maximum dimension is 500, e.g. resize the first image to[500, 250]
and the second to[250, 500]
.The naive method approach would be to set
size = 500
. As noted in the docs,But in both our cases, the smaller edge of the image is already 500 so this essentially does nothing.
Setting
max_size = 500
also doesn't solve the issue since the current implementation specifically doesn't allowmax_size == size
in the code. While we could select a value forsize
that is less thanmax_size
, there's no clear way to pick a value ofsize
that would result in the desired effect.Right now there's no clean way to resize images based solely off the size of the longer edge. Adding the ability to pick the resize anchor edge would allow this.
Alternatives
No response
Additional context
A similar comment was made in #2868, but it seems like the discussion about the longer edge was lost in the final implementation
The text was updated successfully, but these errors were encountered: