VideoNormalize#

class torchaug.transforms.VideoNormalize(mean=None, std=None, cast_dtype=None, inplace=False, value_check=False, video_format='CTHW')[source]#

Normalize a tensor video with mean and standard deviation. Given mean: (mean[1],...,mean[n]) and std: (std[1],..,std[n]) for n channels, this transform will normalize each channel of the input torch.*Tensor i.e.,

output[channel] = (input[channel] - mean[channel]) / std[channel]

Videos should be in format […, T, C, H, W] or […, C, T, H, W] with … 0 or 1 leading dimension.

Parameters:
  • mean (Optional[Sequence[float]], optional) – Sequence of means for each channel.

    Default: None

  • std (Optional[Sequence[float]], optional) – Sequence of standard deviations for each channel.

    Default: None

  • video_format (str, optional) – Dimension order of the video. Can be TCHW or CTHW.

    Default: 'CTHW'

  • cast_dtype (Optional[dtype], optional) – If not None, scale and cast input to the dtype. Expected to be a float dtype.

    Default: None

  • inplace (bool, optional) – Bool to make this operation in-place.

    Default: False

  • value_check (bool, optional) – Bool to perform tensor value check. Might cause slow down on some devices because of synchronization.

    Default: False

forward(video)[source]#

Normalize a video.

Parameters:

video (Tensor) – The video to normalize.

Return type:

Tensor

Returns:

Normalized video.