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
inplaceattribute is found, it is set toTrue,inplaceis handled at the wrapper level.If
video_formatattribute is found, it is set toTCHW,video_formatis handled at the wrapper level.
Note
If
video_formatisCTHW, a copy might occur even ifinplaceis set toTrue.Note
If a transform makes a copy, the resulting tensor will not share the same underlying storage even if
inplaceis set toTrue.- Parameters:
transforms (
Union[Sequence[Module],Module]) – A list of transform modules.inplace (
bool, optional) – Whether to perform the transforms inplace.Default:Falsesame_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:Truevideo_format (
str, optional) – Format of the video. EitherCTHWorTCHW.Default:'CTHW'- forward(videos)[source]#
Apply
transformson the batch of videos.Call
torchaug.transforms.Wrapper.forward().Note
If
same_on_framesisFalse, the batch and frames dimensions are merged.- Parameters:
videos (
Tensor) – The batch of videos to transform.- Return type:
Tensor- Returns:
The transformed videos.