Skip to content
class

RandomSizedCrop

extendsGeometricTransform[CropBox]
RandomSizedCrop(min_max_height: tuple[int, int], height: int, width: int, w2h_ratio: float = 1.0, interpolation: int | str | Interpolation = 1, p: float = 1.0)

Random-size crop then resize (Albumentations RandomSizedCrop).

Parameters

min_max_height(int, int)
Range of crop heights (pixels).
heightint
Output size after resizing.
widthint
Output size after resizing.
w2h_ratiofloat= 1.0
Crop width / height ratio.
interpolationint or str or Interpolation= 1
No description.
pfloat= 1.0
No description.

Examples

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

Used by 1

Constructors

1
dunder

__init__

→None
__init__(min_max_height: tuple[int, int], height: int, width: int, w2h_ratio: float = 1.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 RandomSizedCrop.

Parameters

Image tensor; its spatial size bounds both the sampled crop dimensions (clamped to fit) and the uniformly sampled (top, left) corner.

Returns

CropBox

Crop window (top, left, height, width). Height is drawn uniformly from min_max_height; width is round(height * w2h_ratio); both are clipped to the input dimensions before the corner is sampled.

Dunder methods

1