vis4d.data.datasets.coco

COCO dataset.

Classes

COCO(data_root[, keys_to_load, split, ...])

COCO dataset class.

class COCO(data_root, keys_to_load=('images', 'boxes2d', 'boxes2d_classes', 'instance_masks'), split='train2017', remove_empty=False, use_pascal_voc_cats=False, cache_as_binary=False, cached_file_path=None, **kwargs)[source]

COCO dataset class.

Initialize the COCO dataset.

Parameters:
  • data_root (str) – Path to the root directory of the dataset.

  • keys_to_load (tuple[str, ...]) – Keys to load from the dataset.

  • split (split) – Which split to load. Default: “train2017”.

  • remove_empty (bool) – Whether to remove images with no annotations.

  • use_pascal_voc_cats (bool) – Whether to use Pascal VOC categories.

  • cache_as_binary (bool) – Whether to cache the dataset as binary. Default: False.

  • cached_file_path (str | None) – Path to a cached file. If cached file exist then it will load it instead of generating the data mapping. Default: None.

__getitem__(idx)[source]

Transform coco sample to vis4d input format.

Return type:

Dict[str, Any]

Returns:

DataDict[DataKeys, Union[torch.Tensor, Dict[Any]]]

__len__()[source]

Return length of dataset.

Return type:

int

__repr__()[source]

Concise representation of the dataset.

Return type:

str