Skip to content
class

RandomResizedCrop

extendsGeometricTransform[CropBox]
RandomResizedCrop(height: int, width: int, scale: tuple[float, float] = (0.08, 1.0), ratio: tuple[float, float] = (3.0 / 4.0, 4.0 / 3.0), interpolation: int | str | Interpolation = 1, p: float = 1.0)

Crop a random area/aspect region then resize to height x width.

Albumentations RandomResizedCrop.

Parameters

pfloat= 1.0
Probability of applying the transform; otherwise the input passes through unchanged.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.RandomResizedCrop(16, 16, p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 16, 16)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(height: int, width: int, scale: tuple[float, float] = (0.08, 1.0), ratio: tuple[float, float] = (3.0 / 4.0, 4.0 / 3.0), interpolation: int | str | Interpolation = 1, p: float = 1.0)

Instance methods

1
fn

make_params

→CropBox
make_params(img: Tensor)

Sample per-call random parameters for RandomResizedCrop.

Parameters

Image tensor; its spatial size sets the source area and bounds the sampled crop window.

Returns

CropBox

Crop window (top, left, height, width) whose area fraction is uniform in scale and whose aspect ratio is log-uniform in ratio. Falls back to a centred, ratio-clamped crop after 10 failed area / aspect draws so the method always returns a valid window.

Dunder methods

1