"src/turbomind/utils/cublasMMWrapper.h" did not exist on "9efcac38af58b7247e205c47efe090b4c6ec7574"
_temporal.py 971 Bytes
Newer Older
1
2
from typing import Any, Dict

3
import torch
4
from torchvision.transforms.v2 import functional as F, Transform
5
6
7


class UniformTemporalSubsample(Transform):
8
9
    """[BETA] Uniformly subsample ``num_samples`` indices from the temporal dimension of the video.

10
    .. v2betastatus:: UniformTemporalSubsample transform
11
12
13
14
15
16
17
18
19
20

    Videos are expected to be of shape ``[..., T, C, H, W]`` where ``T`` denotes the temporal dimension.

    When ``num_samples`` is larger than the size of temporal dimension of the video, it
    will sample frames based on nearest neighbor interpolation.

    Args:
        num_samples (int): The number of equispaced samples to be selected
    """

21
    _transformed_types = (torch.Tensor,)
22

23
    def __init__(self, num_samples: int):
24
25
26
        super().__init__()
        self.num_samples = num_samples

27
    def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
28
        return self._call_kernel(F.uniform_temporal_subsample, inpt, self.num_samples)