Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] Format semantickitti label mapping #2323

Merged
merged 17 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 58 additions & 69 deletions configs/_base_/datasets/semantickitti.py
Original file line number Diff line number Diff line change
@@ -1,77 +1,51 @@
# dataset settings
dataset_type = 'SemanticKITTIDataset'
dataset_type = 'SemanticKittiDataset'
data_root = 'data/semantickitti/'
class_names = [
'unlabeled', 'car', 'bicycle', 'motorcycle', 'truck', 'bus', 'person',
'bicyclist', 'motorcyclist', 'road', 'parking', 'sidewalk', 'other-ground',
'building', 'fence', 'vegetation', 'trunck', 'terrian', 'pole',
'traffic-sign'
]
palette = [
[174, 199, 232],
[152, 223, 138],
[31, 119, 180],
[255, 187, 120],
[188, 189, 34],
[140, 86, 75],
[255, 152, 150],
[214, 39, 40],
[197, 176, 213],
[148, 103, 189],
[196, 156, 148],
[23, 190, 207],
[247, 182, 210],
[219, 219, 141],
[255, 127, 14],
[158, 218, 229],
[44, 160, 44],
[112, 128, 144],
[227, 119, 194],
[82, 84, 163],
'car', 'bicycle', 'motorcycle', 'truck', 'bus', 'person', 'bicyclist',
'motorcyclist', 'road', 'parking', 'sidewalk', 'other-ground', 'building',
'fence', 'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'
]

labels_map = {
0: 0, # "unlabeled"
1: 0, # "outlier" mapped to "unlabeled" --------------mapped
10: 1, # "car"
11: 2, # "bicycle"
13: 5, # "bus" mapped to "other-vehicle" --------------mapped
15: 3, # "motorcycle"
16: 5, # "on-rails" mapped to "other-vehicle" ---------mapped
18: 4, # "truck"
20: 5, # "other-vehicle"
30: 6, # "person"
31: 7, # "bicyclist"
32: 8, # "motorcyclist"
40: 9, # "road"
44: 10, # "parking"
48: 11, # "sidewalk"
49: 12, # "other-ground"
50: 13, # "building"
51: 14, # "fence"
52: 0, # "other-structure" mapped to "unlabeled" ------mapped
60: 9, # "lane-marking" to "road" ---------------------mapped
70: 15, # "vegetation"
71: 16, # "trunk"
72: 17, # "terrain"
80: 18, # "pole"
81: 19, # "traffic-sign"
99: 0, # "other-object" to "unlabeled" ----------------mapped
252: 1, # "moving-car" to "car" ------------------------mapped
253: 7, # "moving-bicyclist" to "bicyclist" ------------mapped
254: 6, # "moving-person" to "person" ------------------mapped
255: 8, # "moving-motorcyclist" to "motorcyclist" ------mapped
256: 5, # "moving-on-rails" mapped to "other-vehic------mapped
257: 5, # "moving-bus" mapped to "other-vehicle" -------mapped
258: 4, # "moving-truck" to "truck" --------------------mapped
259: 5 # "moving-other"-vehicle to "other-vehicle"-----mapped
0: 19, # "unlabeled"
sunjiahao1999 marked this conversation as resolved.
Show resolved Hide resolved
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
}

metainfo = dict(
classes=class_names,
palette=palette,
seg_label_mapping=labels_map,
max_label=259)
classes=class_names, seg_label_mapping=labels_map, max_label=259)

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

Expand All @@ -95,7 +69,10 @@
file_client_args=file_client_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=False,
with_label_3d=False,
with_seg_3d=True,
seg_3d_dtype='np.int32',
JingweiZhang12 marked this conversation as resolved.
Show resolved Hide resolved
seg_offset=2**16,
dataset_type='semantickitti'),
dict(type='PointSegClassMapping', ),
Expand All @@ -121,7 +98,10 @@
file_client_args=file_client_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=False,
with_label_3d=False,
with_seg_3d=True,
seg_3d_dtype='np.int32',
seg_offset=2**16,
dataset_type='semantickitti'),
dict(type='PointSegClassMapping', ),
Expand All @@ -138,15 +118,18 @@
file_client_args=file_client_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=False,
with_label_3d=False,
with_seg_3d=True,
seg_3d_dtype='np.int32',
seg_offset=2**16,
dataset_type='semantickitti'),
dict(type='PointSegClassMapping', ),
dict(type='Pack3DDetInputs', keys=['points', 'pts_semantic_mask'])
]

train_dataloader = dict(
batch_size=4,
batch_size=2,
num_workers=4,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
Expand All @@ -155,10 +138,11 @@
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='train_infos.pkl',
ann_file='semantickitti_infos_train.pkl',
pipeline=train_pipeline,
metainfo=metainfo,
modality=input_modality)),
modality=input_modality,
ignore_index=19)),
)

test_dataloader = dict(
Expand All @@ -171,10 +155,11 @@
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='valid_infos.pkl',
ann_file='semantickitti_infos_val.pkl',
pipeline=test_pipeline,
metainfo=metainfo,
modality=input_modality,
ignore_index=19,
test_mode=True,
)),
)
Expand All @@ -183,3 +168,7 @@

val_evaluator = dict(type='SegMetric')
test_evaluator = val_evaluator

vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
type='Det3DLocalVisualizer', vis_backends=vis_backends, name='visualizer')
4 changes: 2 additions & 2 deletions mmdet3d/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .scannet_dataset import (ScanNetDataset, ScanNetInstanceSegDataset,
ScanNetSegDataset)
from .seg3d_dataset import Seg3DDataset
from .semantickitti_dataset import SemanticKITTIDataset
from .semantickitti_dataset import SemanticKittiDataset
from .sunrgbd_dataset import SUNRGBDDataset
# yapf: disable
from .transforms import (AffineResize, BackgroundPointsFilter, GlobalAlignment,
Expand All @@ -33,7 +33,7 @@
'NormalizePointsColor', 'IndoorPatchPointSample', 'IndoorPointSample',
'PointSample', 'LoadAnnotations3D', 'GlobalAlignment', 'SUNRGBDDataset',
'ScanNetDataset', 'ScanNetSegDataset', 'ScanNetInstanceSegDataset',
'SemanticKITTIDataset', 'Det3DDataset', 'Seg3DDataset',
'SemanticKittiDataset', 'Det3DDataset', 'Seg3DDataset',
'LoadPointsFromMultiSweeps', 'WaymoDataset', 'BackgroundPointsFilter',
'VoxelBasedPointSampler', 'get_loading_pipeline', 'RandomDropPointsColor',
'RandomJitterPoints', 'ObjectNameFilter', 'AffineResize',
Expand Down
3 changes: 3 additions & 0 deletions mmdet3d/datasets/seg3d_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def parse_data_info(self, info: dict) -> dict:
self.data_prefix.get('pts', ''),
info['lidar_points']['lidar_path'])

info['num_pts_feats'] = info['lidar_points']['num_pts_feats']
info['lidar_path'] = info['lidar_points']['lidar_path']

if self.modality['use_camera']:
for cam_id, img_info in info['images'].items():
if 'img_path' in img_info:
Expand Down
26 changes: 16 additions & 10 deletions mmdet3d/datasets/semantickitti_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


@DATASETS.register_module()
class SemanticKITTIDataset(Seg3DDataset):
r"""SemanticKITTI Dataset.
class SemanticKittiDataset(Seg3DDataset):
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>`_
Expand Down Expand Up @@ -44,22 +44,28 @@ class SemanticKITTIDataset(Seg3DDataset):
Defaults to False.
"""
METAINFO = {
'classes': ('unlabeled', 'car', 'bicycle', 'motorcycle', 'truck',
'bus', 'person', 'bicyclist', 'motorcyclist', 'road',
'parking', 'sidewalk', 'other-ground', 'building', 'fence',
'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'),
'classes': ('car', 'bicycle', 'motorcycle', 'truck', 'bus', 'person',
'bicyclist', 'motorcyclist', 'road', 'parking', 'sidewalk',
'other-ground', 'building', 'fence', 'vegetation',
'trunck', 'terrian', 'pole', 'traffic-sign'),
'palette': [[100, 150, 245], [100, 230, 245], [30, 60, 150],
[80, 30, 180], [100, 80, 250], [155, 30, 30],
[255, 40, 200], [150, 30, 90], [255, 0, 255],
[255, 150, 255], [75, 0, 75], [175, 0, 75], [255, 200, 0],
[255, 120, 50], [0, 175, 0], [135, 60, 0], [150, 240, 80],
[255, 240, 150], [255, 0, 0]],
'seg_valid_class_ids':
tuple(range(20)),
tuple(range(19)),
'seg_all_class_ids':
tuple(range(20)),
tuple(range(19)),
}

def __init__(self,
data_root: Optional[str] = None,
ann_file: str = '',
metainfo: Optional[dict] = None,
data_prefix: dict = dict(
pts='points',
pts='',
img='',
pts_instance_mask='',
pts_semantic_mask=''),
Expand All @@ -83,7 +89,7 @@ def __init__(self,
**kwargs)

def get_seg_label_mapping(self, metainfo):
seg_label_mapping = np.zeros(metainfo['max_label'] + 1)
seg_label_mapping = np.zeros(metainfo['max_label'] + 1, dtype=np.int64)
for idx in metainfo['seg_label_mapping']:
seg_label_mapping[idx] = metainfo['seg_label_mapping'][idx]
return seg_label_mapping
Loading