vis4d.data.data_pipe

DataPipe wraps datasets to share the prepossessing pipeline.

Classes

DataPipe(datasets[, preprocess_fn])

DataPipe class.

MultiSampleDataPipe(datasets, preprocess_fn)

MultiSampleDataPipe class.

class DataPipe(datasets, preprocess_fn=<function DataPipe.<lambda>>)[source]

DataPipe class.

This class wraps one or multiple instances of a PyTorch Dataset so that the preprocessing steps can be shared across those datasets. Composes dataset and the preprocessing pipeline.

Creates an instance of the class.

Parameters:
  • datasets (Dataset | Iterable[Dataset]) – Dataset(s) to be wrapped by this data pipeline.

  • preprocess_fn (Callable[[list[DictData]], list[DictData]]) – Preprocessing function of a single sample. It takes a list of samples and returns a list of samples. Defaults to identity function.

__getitem__(idx)[source]

Wrap getitem to apply augmentations.

Return type:

Union[Dict[str, Any], list[Dict[str, Any]]]

class MultiSampleDataPipe(datasets, preprocess_fn)[source]

MultiSampleDataPipe class.

This class wraps DataPipe to support augmentations that require multiple images (e.g., Mosaic and Mixup) by sampling additional indices for each image. NUM_SAMPLES needs to be defined as a class attribute for transforms that require multi-sample augmentation.

Creates an instance of the class.

Parameters:
  • datasets (Dataset | Iterable[Dataset]) – Dataset(s) to be wrapped by this data pipeline.

  • preprocess_fn (list[list[TFunctor]]) – Preprocessing functions of a single sample. Different than DataPipe, this is a list of lists of transformation functions. The inner list is for transforms that needs to share the same sampled indices (e.g., GenMosaicParameters and MosaicImages), and the outer list is for different transforms.

__getitem__(idx)[source]

Wrap getitem to apply augmentations.

Return type:

Union[Dict[str, Any], list[Dict[str, Any]]]