RandomResizedCrop¶
- class torchaug.transforms.RandomResizedCrop(size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=InterpolationMode.BILINEAR, antialias=True, num_chunks=1, permute_chunks=False, batch_transform=False)[source]¶
Crop a random portion of the input and resize it to a given size.
If the input is a
torch.Tensoror aTATensor(e.g.Image,Video,BoundingBoxesetc.) it can have arbitrary number of leading batch dimensions. For example, the image can have[..., C, H, W]shape. A bounding box can have[..., 4]shape.A crop of the original input is made: the crop has a random area (H * W) and a random aspect ratio. This crop is finally resized to the given size. This is popularly used to train the Inception networks.
- Parameters:
size (
Union[int,Sequence[int]]) –expected output size of the crop, for each edge. If size is an int instead of sequence like (h, w), a square output size
(size, size)is made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).Note
In torchscript mode size as single int is not supported, use a sequence of length 1:
[size, ].scale (
Tuple[float,float], optional) – Specifies the lower and upper bounds for the random area of the crop, before resizing. The scale is defined with respect to the area of the original image. Default:(0.08, 1.0)ratio (
Tuple[float,float], optional) – lower and upper bounds for the random aspect ratio of the crop, before resizing. Default:(3.0 / 4.0, 4.0 / 3.0)interpolation (
Union[InterpolationMode,int], optional) – Desired interpolation enum defined bytorchvision.transforms.InterpolationMode. OnlyInterpolationMode.NEAREST,InterpolationMode.NEAREST_EXACT,InterpolationMode.BILINEARandInterpolationMode.BICUBICare supported. Default:InterpolationMode.BILINEARantialias (
bool, optional) – Whether to apply antialiasing. Default:Truenum_chunks (
int, optional) – number of chunks to split the batched input into. Default:1permute_chunks (
bool, optional) – whether to permute the chunks. Default:Falsebatch_transform (
bool, optional) – whether to apply the transform in batch mode. Default:False