Resize

class torchaug.transforms.Resize(size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=True)[source]

Resize the input to the given size.

If the input is a torch.Tensor or a TATensor (e.g. Image, Video, BoundingBoxes etc.) 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.

Parameters:
  • size (Union[int, Sequence[int]]) –

    Desired output size. If size is a sequence like (h, w), output size will be matched to this. If size is an int, smaller edge of the image will be matched to this number. i.e, if height > width, then image will be rescaled to (size * height / width, size).

    Note

    In torchscript mode size as single int is not supported, use a sequence of length 1: [size, ].

  • interpolation (Union[InterpolationMode, int], optional) – Desired interpolation enum defined by torchvision.transforms.InterpolationMode. If input is Tensor, only InterpolationMode.NEAREST, InterpolationMode.NEAREST_EXACT, InterpolationMode.BILINEAR and InterpolationMode.BICUBIC are supported. The corresponding Pillow integer constants, e.g. PIL.Image.BILINEAR are accepted as well. Default: InterpolationMode.BILINEAR

  • max_size (Optional[int], optional) – The maximum allowed for the longer edge of the resized image. If the longer edge of the image is greater than max_size after being resized according to size, size will be overruled so that the longer edge is equal to max_size. As a result, the smaller edge may be shorter than size. This is only supported if size is an int (or a sequence of length 1 in torchscript mode). Default: None

  • antialias (bool, optional) – Whether to apply antialiasing. Default: True