BatchVideoResize#

class torchaug.batch_transforms.BatchVideoResize(size, interpolation=InterpolationMode.BILINEAR, max_size=None, antialias=True, video_format='CTHW')[source]#

Resize the input video to the given size. The video is expected to have [B, …, H, W] shape, where … means an arbitrary number of dimensions.

Parameters:
  • size (int | list[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 (InterpolationMode, optional) – Desired interpolation enum defined by torchvision.transforms.InterpolationMode. InterpolationMode.NEAREST, InterpolationMode.NEAREST_EXACT, InterpolationMode.BILINEAR and InterpolationMode.BICUBIC are supported.

    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, then the image is resized again so that the longer edge is equal to max_size. As a result, size might be overruled, i.e. 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. If True, will apply antialiasing for bilinear or bicubic modes. Other mode aren’t affected.

    Default: True

  • video_format (str, optional) – Format of the video. Either CTHW or TCHW.

    Default: 'CTHW'

forward(videos)[source]#

Resize the batch of videos.

Parameters:

videos (Tensor) – The batch of videos to resize.

Return type:

Tensor

Returns:

The resized videos.