Data Utils#

class cdfvd.utils.data_utils.VideoData[source]#

Class to create dataloaders for video datasets

Parameters:
  • data_path – Path to the folder with video frames or videos.

  • image_folder – If True, the data is stored as images in folders.

  • resolution – Resolution of the returned videos.

  • sequence_length – Length of extracted video sequences.

  • sample_every_n_frames – Sample every n frames from the video.

  • batch_size – Batch size.

  • num_workers – Number of workers for the dataloader.

  • shuffle – If True, shuffle the data.

class cdfvd.utils.data_utils.VideoDataset[source]#

Generic dataset for videos files stored in folders. Videos of the same class are expected to be stored in a single folder. Multiple folders can exist in the provided directory. The class depends on torchvision.datasets.video_utils.VideoClips to load the videos. Returns BCTHW videos in the range [0, 1].

Parameters:
  • data_folder – Path to the folder with corresponding videos stored.

  • sequence_length – Length of extracted video sequences.

  • resolution – Resolution of the returned videos.

  • sample_every_n_frames – Sample every n frames from the video.

get_random_clip_from_video(idx: int) tuple[source]#

Sample a random clip starting index from the video.

Parameters:

idx (int) – Index of the video.

Return type:

tuple

class cdfvd.utils.data_utils.FrameDataset[source]#
Generic dataset for videos stored as images. The loading will iterates over all the folders and subfolders

in the provided directory. Each leaf folder is assumed to contain frames from a single video.

Parameters:
  • data_folder – path to the folder with video frames. The folder should contain folders with frames from each video.

  • sequence_length – length of extracted video sequences

  • resolution – resolution of the returned videos

  • sample_every_n_frames – sample every n frames from the video

load_video_frames(dataroot: str) list[source]#

Loads all the video frames under the dataroot and returns a list of all the video frames.

Parameters:

dataroot (str) – The root directory containing the video frames.

Returns:

A list of all the video frames.

Return type:

list

getTensor(index: int) Tensor[source]#

Returns a tensor of the video frames at the given index.

Parameters:

index (int) – The index of the video frames to return.

Returns:

A BCTHW tensor in the range [0, 1] of the video frames at the given index.

Return type:

Tensor