vis4d.data.resample

Resample index to recover the original dataset length.

Classes

ResampleDataset(dataset)

Dataset wrapper to recover the filtered samples through resampling.

class ResampleDataset(dataset)[source]

Dataset wrapper to recover the filtered samples through resampling.

In MMEngine and Detectron2, the dataset might return None when the sample has no valid annotations. They will resample the index and try to get the valid training data. The length of dataset will be different depends on whether filtering the empty samples first.

This dataset wrapper resamples the index to recover the original dataset length (before filter empty frames) to align with the other codebases’ implementation.

https://github.com/open-mmlab/mmengine/blob/main/mmengine/dataset/base_dataset.py#L411 https://github.com/facebookresearch/detectron2/blob/main/detectron2/data/common.py#L96

Creates an instance of the class.

__getitem__(idx)[source]

Get original dataset idx according to the given index.

Resample index to recover the original dataset length.

Parameters:

idx (int) – The index of original dataset length.

Returns:

Data of the corresponding index.

Return type:

DictDataOrList

__len__()[source]

Return the length of dataset.

Returns:

Length of dataset.

Return type:

int