Skip to content
class

ResizeShortestEdge

extends_MaxSizeResize
ResizeShortestEdge(min_size: int, max_size: int, interpolation: str | Interpolation | int = Interpolation.BILINEAR, p: float = 1.0)

Reference detection resize: shortest side to min_size, capped.

Applies the single scale factor

s=min⁡ ⁣(min_sizemin⁡(H,W),  max_sizemax⁡(H,W))s = \min\!\left( \frac{\text{min\_size}}{\min(H, W)},\; \frac{\text{max\_size}}{\max(H, W)} \right)

so the shorter side reaches min_size unless that would push the longer side past max_size, in which case the longer side is what binds. This is what GeneralizedRCNNTransform does, and it is not expressible as SmallestMaxSize followed by LongestMaxSize — the latter rescales unconditionally and would undo the first stage.

Parameters

min_sizeint
Target length of the shorter side.
max_sizeint
Hard cap on the longer side.
interpolationint or str or Interpolation= 1
Image resampling mode.
pfloat= 1.0
Probability of applying the transform.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ResizeShortestEdge(min_size=16, max_size=32)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)
The shortest side goes to min_size unless that would push the
longest past max_size, in which case the longest one is what
binds — which is the rule a detector's batching depends on.

Used by 2

Constructors

1
dunder

__init__

→None
__init__(min_size: int, max_size: int, interpolation: str | Interpolation | int = Interpolation.BILINEAR, p: float = 1.0)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1