BatchVideoWrapper#

class torchaug.batch_transforms.BatchVideoWrapper(transforms, inplace=False, same_on_frames=True, video_format='CTHW')[source]#

Wrap transforms to handle batched video data.

The transforms are expected to handle the leading dimension differently.

The batch of videos is expected to be in format [B, C, T, H, W] or [B, 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

  • same_on_frames (bool, optional) – If True, apply the same transform on all the frames, else it flattens the batch and temporal dimensions to apply different transformations to each frame.

    Default: True

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

    Default: 'CTHW'

forward(videos)[source]#

Apply transforms on the batch of videos.

Call torchaug.transforms.Wrapper.forward().

Note

If same_on_frames is False, the batch and frames dimensions are merged.

Parameters:

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

Returns:

The transformed videos.