question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

https://github.com/pytorch/vision/blob/d1e134c71b94a5975dcbf16927ed608dac54fdfe/torchvision/transforms/transforms.py#L239-L240

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:open
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasHugcommented, Feb 23, 2021

I agree that edge="long", max_size=max_size doesn’t make much sense, we could warn or error in this case. Regarding min_size, I would also agree that this parameter is not needed (on top of the redundancy, it might be impossible to satisfy both min_size and max_size).

@fmassa would you mind sharing your thoughts on:

  • introducing edge only
  • introducing max_size only
  • introducing both

My 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.

0reactions
NicolasHugcommented, Feb 23, 2021

From what I can tell, detectron2’s ResizeShortestEdge corresponds to torchvision’s current resize with the max_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 makes size act as a bounding box for the resized image, so it has a bit of a max_size flavour too.

I could not find similar things in classyvision or in PIL

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found