-
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
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 |
Hey @NicolasHug! Quick question for you regarding the development of this feature - would it be acceptable to make the new v2 Resize no longer compatible with the v1 Resize (by removing the _v1_transform_cls attribute from v2.Resize)? Some of the current unit tests check for v1 compatibility, and this is running into issues since the v1 Resize doesn't accept Right now, I've implemented a workaround that sets |
Hi @sidijju , I'm not 100% sure what the best solution is right now though, do you mind opening a PR so I can take a better look? It's totally OK if the PR isn't completely ready just yet (you can e.g. set it as "draft") |
@NicolasHug Just made a PR! |
Using the current implementation (if using the workaround with |
Closed by #8459, thank you @sidijju ! Thanks for the feedback @MyNameIsFu , this will be available soon in the next version (0.19) |
🚀 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: