Shortcuts

RepeatDataset

class mmengine.dataset.RepeatDataset(dataset, times, lazy_init=False)[source]

A wrapper of repeated dataset.

The length of repeated dataset will be times larger than the original dataset. This is useful when the data loading time is long but the dataset is small. Using RepeatDataset can reduce the data loading time between epochs.

Note

RepeatDataset should not inherit from BaseDataset since get_subset and get_subset_ could produce ambiguous meaning sub-dataset which conflicts with original dataset. If you want to use a sub-dataset of RepeatDataset, you should set indices arguments for wrapped dataset which inherit from BaseDataset.

Parameters:
  • dataset (BaseDataset or dict) – The dataset to be repeated.

  • times (int) – Repeat times.

  • lazy_init (bool) – Whether to load annotation during instantiation. Defaults to False.

full_init()[source]

Loop to full_init each dataset.

get_data_info(idx)[source]

Get annotation by index.

Parameters:

idx (int) – Global index of ConcatDataset.

Returns:

The idx-th annotation of the datasets.

Return type:

dict

get_subset(indices)[source]

Not supported in RepeatDataset for the ambiguous meaning of sub- dataset.

Parameters:

indices (List[int] | int) –

Return type:

BaseDataset

get_subset_(indices)[source]

Not supported in RepeatDataset for the ambiguous meaning of sub- dataset.

Parameters:

indices (List[int] | int) –

Return type:

None

property metainfo: dict

Get the meta information of the repeated dataset.

Returns:

The meta information of repeated dataset.

Return type:

dict