Make the resize anchor edge variable if size is scalar
See original GitHub issue🚀 Feature
Make the resize anchor edge variable if size is scalar.
Motivation
Right now torchvision.transforms.Resize()
assumes that the smaller edge of the image should be resized to size if its an int
.
That can be cumbersome if the user wants for example an image that is not larger than x or wants a specific edge to be this size.
Pitch
I propose we add a edge
keyword argument which can be one of "short"
(default), "long"
, "vert"
, and "horz"
. Based on this we calculate the size.
cc @vfdev-5
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Size and anchors - Godot Docs
When horizontal (left, right) and/or vertical (top, bottom) anchors are changed to 1, the margin values become relative to the bottom-right corner of...
Read more >Control appearance and behavior of figure window - MATLAB
Figure properties control the appearance and behavior of a particular ... Position — Location and size of drawable area ... Resize — Resizable...
Read more >Tecplot 360 User's Manual
Click once in the active data region to anchor one corner of the zone. • Drag the diagonal corner until the zone is...
Read more >https://www.reaper.fm/sdk/walter/walter
named anchors on a line with <hr> will be used to construct table of contents ... right attach: scale the right edge of...
Read more >Image Filtering - OpenCV
output image of the same size and type as src. ksize, blurring kernel size. anchor, anchor point; default value Point(-1,-1) means that the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree that
edge="long", max_size=max_size
doesn’t make much sense, we could warn or error in this case. Regardingmin_size
, I would also agree that this parameter is not needed (on top of the redundancy, it might be impossible to satisfy bothmin_size
andmax_size
).@fmassa would you mind sharing your thoughts on:
edge
onlymax_size
onlyMy personal opinion is that they’re (mostly) orthogonal concepts and that usage wouldn’t be confusing as long as docs are properly informative. But I’m not familiar enough with the use-cases to really assess whether the added complexity is worth it.
From what I can tell, detectron2’s
ResizeShortestEdge
corresponds totorchvision
’s currentresize
with themax_size
parameter.Regarding the other transforms, they don’t allow
size
to be an int, which is what we’re concerned with (Detectron2.resize
accepts an int but it will output a square size x size image). In tensorflow,preserve_aspect_ratio=True
makessize
act as a bounding box for the resized image, so it has a bit of amax_size
flavour too.I could not find similar things in classyvision or in PIL