towhee.models.utils.video_transforms.VideoTransforms

class towhee.models.utils.video_transforms.VideoTransforms(cfg)[source]

Bases: object

Transform video to video & audio tensors given an video path, corresponding to models by model name. The code is buiil on top of examples given by [Pytorchvideo](https://pytorchvideo.org/). The following model names are supported:

  • slow_r50

  • slowfast_r50

  • slowfast_r101

  • x3d_xs

  • x3d_s

  • x3d_m

Parameters:

cfg – configs including parameters

Returns:

A dictionary including tensors for video (and audio).

Example

>>> from towhee.models.utils.video_transforms import VideoTransforms
>>>
>>> model_name = "x3d_xs"
>>> cfg = video_configs[model_name]
>>> cfg.update(model_name=model_name)
>>> tsfm = VideoTransforms(cfg)
>>> output = tsfm(video)
>>> print(output.shape)
torch.Size([3, 4, 182, 182])

Methods

__call__(video: ndarray)[source]

Call self as a function.

__init__(cfg)[source]