semantickitti_dataset.py 3.11 KB
Newer Older
dingchang's avatar
dingchang committed
1
# Copyright (c) OpenMMLab. All rights reserved.
ZCMax's avatar
ZCMax committed
2
from typing import Callable, List, Optional, Union
3

4
5
import numpy as np

6
from mmdet3d.registry import DATASETS
ZCMax's avatar
ZCMax committed
7
from .seg3d_dataset import Seg3DDataset
8
9
10


@DATASETS.register_module()
ZCMax's avatar
ZCMax committed
11
class SemanticKITTIDataset(Seg3DDataset):
12
13
14
15
16
17
18
    r"""SemanticKITTI Dataset.

    This class serves as the API for experiments on the SemanticKITTI Dataset
    Please refer to <http://www.semantic-kitti.org/dataset.html>`_
    for data downloading

    Args:
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
        data_root (str, optional): Path of dataset root. Defaults to None.
        ann_file (str): Path of annotation file. Defaults to ''.
        metainfo (dict, optional): Meta information for dataset, such as class
            information. Defaults to None.
        data_prefix (dict): Prefix for training data. Defaults to
            dict(pts='points', img='', instance_mask='', semantic_mask='').
        pipeline (list[dict]): Pipeline used for data processing.
            Defaults to [].
        modality (dict): Modality to specify the sensor data used as input,
            it usually has following keys:

                - use_camera: bool
                - use_lidar: bool
            Defaults to dict(use_lidar=True, use_camera=False).
        ignore_index (int, optional): The label index to be ignored, e.g.
            unannotated points. If None is given, set to len(self.CLASSES) to
            be consistent with PointSegClassMapping function in pipeline.
36
            Defaults to None.
37
38
        scene_idxs (np.ndarray | str, optional): Precomputed index to load
            data. For scenes with many points, we may sample it several times.
39
            Defaults to None.
40
        test_mode (bool): Whether the dataset is in test mode.
41
42
            Defaults to False.
    """
ZCMax's avatar
ZCMax committed
43
44
45
46
47
    METAINFO = {
        'CLASSES': ('unlabeled', 'car', 'bicycle', 'motorcycle', 'truck',
                    'bus', 'person', 'bicyclist', 'motorcyclist', 'road',
                    'parking', 'sidewalk', 'other-ground', 'building', 'fence',
                    'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'),
48
        'seg_valid_class_ids':
ZCMax's avatar
ZCMax committed
49
        tuple(range(20)),
50
        'seg_all_class_ids':
ZCMax's avatar
ZCMax committed
51
52
        tuple(range(20))
    }
53
54

    def __init__(self,
ZCMax's avatar
ZCMax committed
55
56
57
58
59
60
61
                 data_root: Optional[str] = None,
                 ann_file: str = '',
                 metainfo: Optional[dict] = None,
                 data_prefix: dict = dict(
                     pts='points', img='', instance_mask='', semantic_mask=''),
                 pipeline: List[Union[dict, Callable]] = [],
                 modality: dict = dict(use_lidar=True, use_camera=False),
62
63
64
                 ignore_index: Optional[int] = None,
                 scene_idxs: Optional[Union[str, np.ndarray]] = None,
                 test_mode: bool = False,
ZCMax's avatar
ZCMax committed
65
66
                 **kwargs) -> None:

67
68
69
        super().__init__(
            data_root=data_root,
            ann_file=ann_file,
ZCMax's avatar
ZCMax committed
70
71
            metainfo=metainfo,
            data_prefix=data_prefix,
72
73
            pipeline=pipeline,
            modality=modality,
ZCMax's avatar
ZCMax committed
74
75
76
77
            ignore_index=ignore_index,
            scene_idxs=scene_idxs,
            test_mode=test_mode,
            **kwargs)