Shortcuts

pytorchvideo.data.hmdb51

class pytorchvideo.data.hmdb51.Hmdb51LabeledVideoPaths(paths_and_labels, path_prefix='')[source]
Pre-processor for Hmbd51 dataset mentioned here -

https://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/

This dataset consists of classwise folds with each class consisting of 3

folds (splits).

The videos directory is of the format,

video_dir_path/class_x/<somevideo_name>.avi … video_dir_path/class_y/<somevideo_name>.avi

The splits/fold directory is of the format,

folds_dir_path/class_x_test_split_1.txt folds_dir_path/class_x_test_split_2.txt folds_dir_path/class_x_test_split_3.txt … folds_dir_path/class_y_test_split_1.txt folds_dir_path/class_y_test_split_2.txt folds_dir_path/class_y_test_split_3.txt

And each text file in the splits directory class_x_test_split_<1 or 2 or 3>.txt

<a video as in video_dir_path/class_x> <0 or 1 or 2> where 0,1,2 corresponds to unused, train split respectively.

Each video has name of format

<some_name>_<tag1>_<tag2>_<tag_3>_<tag4>_<tag5>_<some_id>.avi

For more details on tags -

https://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/

classmethod from_dir(data_path, split_id=1, split_type='train')[source]

Factory function that creates Hmdb51LabeledVideoPaths object form a splits/folds directory.

Parameters
  • data_path (str) – The path to the splits/folds directory of HMDB51.

  • split_id (int) – Fold id to be loaded. Belongs to [1,2,3]

  • split_type (str) – Split/Fold type to be loaded. It belongs to one of the following, - “train” - “test” - “unused” (This is a small set of videos that are neither of part of test or train fold.)

Return type

pytorchvideo.data.hmdb51.Hmdb51LabeledVideoPaths

classmethod from_csvs(file_paths, split_type='train')[source]

Factory function that creates Hmdb51LabeledVideoPaths object form a list of split files of .txt type

Parameters
  • file_paths (List[Union[pathlib.Path, str]]) – The path to the splits/folds directory of HMDB51.

  • split_type (str) – Split/Fold type to be loaded. - “train” - “test” - “unused”

Return type

pytorchvideo.data.hmdb51.Hmdb51LabeledVideoPaths

__init__(paths_and_labels, path_prefix='')[source]
Parameters
  • [ (paths_and_labels) – a list of tuples containing the video path and integer label.

  • paths_and_labels (List[Tuple[str, Optional[dict]]]) –

Return type

None

__getitem__(index)[source]
Parameters

index (int) – the path and label index.

Returns

The path and label tuple for the given index.

Return type

Tuple[str, dict]

__len__()[source]
Returns

The number of video paths and label pairs.

Return type

int

pytorchvideo.data.hmdb51.Hmdb51(data_path, clip_sampler, video_sampler=<class 'torch.utils.data.sampler.RandomSampler'>, transform=None, video_path_prefix='', split_id=1, split_type='train', decode_audio=True, decoder='pyav')[source]

A helper function to create EncodedVideoDataset object for HMDB51 dataset

Parameters
  • data_path (pathlib.Path) – Path to the data. The path type defines how the

  • should be read (data) –

    • For a file path, the file is read and each line is parsed into a

      video path and label.

    • For a directory, the directory structure defines the classes

      (i.e. each subdirectory is a class).

  • the LabeledVideoPaths class documentation for specific formatting (See) –

  • and examples. (details) –

  • clip_sampler (ClipSampler) – Defines how clips should be sampled from each video. See the clip sampling documentation for more information.

  • video_sampler (Type[torch.utils.data.Sampler]) – Sampler for the internal video container. This defines the order videos are decoded and, if necessary, the distributed split.

  • transform (Callable) –

    This callable is evaluated on the clip output before the clip is returned. It can be used for user defined preprocessing and augmentations to the clips. The clip output is a dictionary with the following format:

    {

    ‘video’: <video_tensor>, ‘label’: <index_label>, ‘index’: <clip_index>

    }

    If transform is None, the raw clip output in the above format is returned unmodified.

  • video_path_prefix (str) – Path to root directory with the videos that are loaded in EncodedVideoDataset. All the video paths before loading are prefixed with this path.

  • decoder (str) – Defines which backend should be used to decode videos.

  • split_id (int) –

  • split_type (str) –

Return type

pytorchvideo.data.encoded_video_dataset.EncodedVideoDataset