Skip to content
class

SmallestMaxSize

extends_MaxSizeResize
SmallestMaxSize(max_size: int, interpolation: int | str | Interpolation = 1, p: float = 1.0)

Scale so the shorter side equals max_size (Albumentations SmallestMaxSize).

Computes the scale factor max_size / min(H, W) and applies it to both axes — the aspect ratio is preserved and the longer side ends up at least as large as max_size. Image uses interpolation, masks use nearest, boxes / keypoints scale exactly.

Parameters

max_sizeint
Target length of the shorter side after resize.
interpolationint or str or Interpolation= 1
Image resampling mode (OpenCV codes accepted).
pfloat= 1.0
Probability of applying the transform.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.SmallestMaxSize(16, p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)
The aspect ratio is kept, so the shortest side lands on the
limit and the other one is longer.

Used by 2

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1