semantickitti.py 7.36 KB
Newer Older
1
2
3
4
5
# For SemanticKitti we usually do 19-class segmentation.
# For labels_map we follow the uniform format of MMDetection & MMSegmentation
# i.e. we consider the unlabeled class as the last one, which is different
# from the original implementation of some methods e.g. Cylinder3D.
dataset_type = 'SemanticKittiDataset'
6
7
data_root = 'data/semantickitti/'
class_names = [
8
9
10
    'car', 'bicycle', 'motorcycle', 'truck', 'bus', 'person', 'bicyclist',
    'motorcyclist', 'road', 'parking', 'sidewalk', 'other-ground', 'building',
    'fence', 'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'
11
12
]
labels_map = {
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    0: 19,  # "unlabeled"
    1: 19,  # "outlier" mapped to "unlabeled" --------------mapped
    10: 0,  # "car"
    11: 1,  # "bicycle"
    13: 4,  # "bus" mapped to "other-vehicle" --------------mapped
    15: 2,  # "motorcycle"
    16: 4,  # "on-rails" mapped to "other-vehicle" ---------mapped
    18: 3,  # "truck"
    20: 4,  # "other-vehicle"
    30: 5,  # "person"
    31: 6,  # "bicyclist"
    32: 7,  # "motorcyclist"
    40: 8,  # "road"
    44: 9,  # "parking"
    48: 10,  # "sidewalk"
    49: 11,  # "other-ground"
    50: 12,  # "building"
    51: 13,  # "fence"
    52: 19,  # "other-structure" mapped to "unlabeled" ------mapped
    60: 8,  # "lane-marking" to "road" ---------------------mapped
    70: 14,  # "vegetation"
    71: 15,  # "trunk"
    72: 16,  # "terrain"
    80: 17,  # "pole"
    81: 18,  # "traffic-sign"
    99: 19,  # "other-object" to "unlabeled" ----------------mapped
    252: 0,  # "moving-car" to "car" ------------------------mapped
    253: 6,  # "moving-bicyclist" to "bicyclist" ------------mapped
    254: 5,  # "moving-person" to "person" ------------------mapped
    255: 7,  # "moving-motorcyclist" to "motorcyclist" ------mapped
    256: 4,  # "moving-on-rails" mapped to "other-vehic------mapped
    257: 4,  # "moving-bus" mapped to "other-vehicle" -------mapped
    258: 3,  # "moving-truck" to "truck" --------------------mapped
    259: 4  # "moving-other"-vehicle to "other-vehicle"-----mapped
47
48
49
}

metainfo = dict(
50
    classes=class_names, seg_label_mapping=labels_map, max_label=259)
51
52
53

input_modality = dict(use_lidar=True, use_camera=False)

54
55
56
57
58
59
# Example to use different file client
# Method 1: simply set the data root and let the file I/O module
# automatically infer from prefix (not support LMDB and Memcache yet)

# data_root = 's3://openmmlab/datasets/detection3d/semantickitti/'

Jingwei Zhang's avatar
Jingwei Zhang committed
60
# Method 2: Use backend_args, file_client_args in versions before 1.1.0
61
# backend_args = dict(
62
63
#     backend='petrel',
#     path_mapping=dict({
64
65
66
67
#         './data/': 's3://openmmlab/datasets/detection3d/',
#          'data/': 's3://openmmlab/datasets/detection3d/'
#      }))
backend_args = None
68
69
70
71
72
73
74

train_pipeline = [
    dict(
        type='LoadPointsFromFile',
        coord_type='LIDAR',
        load_dim=4,
        use_dim=4,
75
        backend_args=backend_args),
76
77
    dict(
        type='LoadAnnotations3D',
78
79
        with_bbox_3d=False,
        with_label_3d=False,
80
        with_seg_3d=True,
81
        seg_3d_dtype='np.int32',
82
        seg_offset=2**16,
83
84
        dataset_type='semantickitti',
        backend_args=backend_args),
85
    dict(type='PointSegClassMapping'),
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    dict(
        type='RandomFlip3D',
        sync_2d=False,
        flip_ratio_bev_horizontal=0.5,
        flip_ratio_bev_vertical=0.5),
    dict(
        type='GlobalRotScaleTrans',
        rot_range=[-0.78539816, 0.78539816],
        scale_ratio_range=[0.95, 1.05],
        translation_std=[0.1, 0.1, 0.1],
    ),
    dict(type='Pack3DDetInputs', keys=['points', 'pts_semantic_mask'])
]
test_pipeline = [
    dict(
        type='LoadPointsFromFile',
        coord_type='LIDAR',
        load_dim=4,
        use_dim=4,
105
        backend_args=backend_args),
106
107
    dict(
        type='LoadAnnotations3D',
108
109
        with_bbox_3d=False,
        with_label_3d=False,
110
        with_seg_3d=True,
111
        seg_3d_dtype='np.int32',
112
        seg_offset=2**16,
113
114
        dataset_type='semantickitti',
        backend_args=backend_args),
115
    dict(type='PointSegClassMapping'),
116
    dict(type='Pack3DDetInputs', keys=['points', 'pts_semantic_mask'])
117
118
119
120
]
# construct a pipeline for data and gt loading in show function
# please keep its loading function consistent with test_pipeline (e.g. client)
eval_pipeline = [
121
122
123
124
125
126
127
128
129
    dict(
        type='LoadPointsFromFile',
        coord_type='LIDAR',
        load_dim=4,
        use_dim=4,
        backend_args=backend_args),
    dict(type='Pack3DDetInputs', keys=['points'])
]
tta_pipeline = [
130
131
132
133
134
    dict(
        type='LoadPointsFromFile',
        coord_type='LIDAR',
        load_dim=4,
        use_dim=4,
135
        backend_args=backend_args),
136
137
    dict(
        type='LoadAnnotations3D',
138
139
        with_bbox_3d=False,
        with_label_3d=False,
140
        with_seg_3d=True,
141
        seg_3d_dtype='np.int32',
142
        seg_offset=2**16,
143
144
        dataset_type='semantickitti',
        backend_args=backend_args),
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    dict(type='PointSegClassMapping'),
    dict(
        type='TestTimeAug',
        transforms=[[
            dict(
                type='RandomFlip3D',
                sync_2d=False,
                flip_ratio_bev_horizontal=0.,
                flip_ratio_bev_vertical=0.),
            dict(
                type='RandomFlip3D',
                sync_2d=False,
                flip_ratio_bev_horizontal=0.,
                flip_ratio_bev_vertical=1.),
            dict(
                type='RandomFlip3D',
                sync_2d=False,
                flip_ratio_bev_horizontal=1.,
                flip_ratio_bev_vertical=0.),
            dict(
                type='RandomFlip3D',
                sync_2d=False,
                flip_ratio_bev_horizontal=1.,
                flip_ratio_bev_vertical=1.)
        ],
                    [
                        dict(
                            type='GlobalRotScaleTrans',
                            rot_range=[pcd_rotate_range, pcd_rotate_range],
                            scale_ratio_range=[
                                pcd_scale_factor, pcd_scale_factor
                            ],
                            translation_std=[0, 0, 0])
                        for pcd_rotate_range in [-0.78539816, 0.0, 0.78539816]
                        for pcd_scale_factor in [0.95, 1.0, 1.05]
                    ], [dict(type='Pack3DDetInputs', keys=['points'])]])
181
182
183
]

train_dataloader = dict(
184
    batch_size=2,
185
    num_workers=4,
186
    persistent_workers=True,
187
188
    sampler=dict(type='DefaultSampler', shuffle=True),
    dataset=dict(
189
190
191
192
193
194
195
196
        type=dataset_type,
        data_root=data_root,
        ann_file='semantickitti_infos_train.pkl',
        pipeline=train_pipeline,
        metainfo=metainfo,
        modality=input_modality,
        ignore_index=19,
        backend_args=backend_args))
197
198
199
200

test_dataloader = dict(
    batch_size=1,
    num_workers=1,
201
202
    persistent_workers=True,
    drop_last=False,
203
204
    sampler=dict(type='DefaultSampler', shuffle=False),
    dataset=dict(
205
206
207
208
209
210
211
212
213
        type=dataset_type,
        data_root=data_root,
        ann_file='semantickitti_infos_val.pkl',
        pipeline=test_pipeline,
        metainfo=metainfo,
        modality=input_modality,
        ignore_index=19,
        test_mode=True,
        backend_args=backend_args))
214
215
216
217
218

val_dataloader = test_dataloader

val_evaluator = dict(type='SegMetric')
test_evaluator = val_evaluator
219
220
221
222

vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
    type='Det3DLocalVisualizer', vis_backends=vis_backends, name='visualizer')
223
224

tta_model = dict(type='Seg3DTTAModel')