VideoWrapper#

class torchaug.transforms.VideoWrapper(transforms, inplace=False, video_format='CTHW')[source]#

Wrap transforms to handle video data.

If the frames should be augmented differently, the transform must handle the leading dimension differently. The video is expected to be in format [C, T, H, W] or [T, C, H, W].

Note

Iterates through transforms and their submodules:

  • If inplace attribute is found, it is set to True, inplace is handled at the wrapper level.

  • If video_format attribute is found, it is set to TCHW, video_format is handled at the wrapper level.

Note

If video_format is CTHW, a copy might occur even if inplace is set to True.

Note

If a transform makes a copy, the resulting tensor will not share the same underlying storage even if inplace is set to True.

Parameters:
  • transforms (Union[Sequence[Module], Module]) – A list of transform modules.

  • inplace (bool, optional) – Whether to perform the transforms inplace.

    Default: False

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

    Default: 'CTHW'

forward(video)[source]#

Apply transforms on the video.

Call Wrapper.forward().

Parameters:

video (Tensor) – The video to transform.

Return type:

Tensor

Returns:

The transformed video.