semantickitti_dataset.py 3.24 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
        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
24
25
26
27
28
            dict(pts='points',
                 img='',
                 pts_instance_mask='',
                 pts_semantic_mask='').
        pipeline (List[dict]): Pipeline used for data processing.
29
30
31
32
33
34
35
36
            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.
37
            unannotated points. If None is given, set to len(self.classes) to
38
            be consistent with PointSegClassMapping function in pipeline.
39
            Defaults to None.
40
        scene_idxs (np.ndarray or str, optional): Precomputed index to load
41
            data. For scenes with many points, we may sample it several times.
42
            Defaults to None.
43
        test_mode (bool): Whether the dataset is in test mode.
44
45
            Defaults to False.
    """
ZCMax's avatar
ZCMax committed
46
    METAINFO = {
47
        'classes': ('unlabeled', 'car', 'bicycle', 'motorcycle', 'truck',
ZCMax's avatar
ZCMax committed
48
49
50
                    'bus', 'person', 'bicyclist', 'motorcyclist', 'road',
                    'parking', 'sidewalk', 'other-ground', 'building', 'fence',
                    'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'),
51
        'seg_valid_class_ids':
ZCMax's avatar
ZCMax committed
52
        tuple(range(20)),
53
        'seg_all_class_ids':
ZCMax's avatar
ZCMax committed
54
55
        tuple(range(20))
    }
56
57

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

73
74
75
        super().__init__(
            data_root=data_root,
            ann_file=ann_file,
ZCMax's avatar
ZCMax committed
76
77
            metainfo=metainfo,
            data_prefix=data_prefix,
78
79
            pipeline=pipeline,
            modality=modality,
ZCMax's avatar
ZCMax committed
80
81
82
83
            ignore_index=ignore_index,
            scene_idxs=scene_idxs,
            test_mode=test_mode,
            **kwargs)