peal.data.transformations.RandomResizeCropPad

class peal.data.transformations.RandomResizeCropPad[source]

Bases: object

Random zoom augmentation that keeps the spatial size fixed.

The image is resized by a factor drawn uniformly from scale_range, then padded with 0.5 (zoom out) and center-cropped (zoom in) back to the original H x W.

Parameters:

scale_range (tuple of float, optional) – (min, max) of the uniform scale factor. Defaults to (0.8, 1.2).

Methods

__init__(scale_range=(0.8, 1.2))[source]

Store the scale range.

__call__(img)[source]

Zoom img in or out and restore its original size.

Parameters:

img (torch.Tensor) – Image of shape [..., H, W].

Returns:

Image of the same shape.

Return type:

torch.Tensor