nus-3d.py 4.89 KB
Newer Older
zhangwenwei's avatar
zhangwenwei committed
1
2
# If point cloud range is changed, the models should also change their point
# cloud range accordingly
liyinhao's avatar
liyinhao committed
3
point_cloud_range = [-50, -50, -5, 50, 50, 3]
4
5
6
# Using calibration info convert the Lidar-coordinate point cloud range to the
# ego-coordinate point cloud range could bring a little promotion in nuScenes.
# point_cloud_range = [-50, -50.8, -5, 50, 49.2, 3]
zhangwenwei's avatar
zhangwenwei committed
7
# For nuScenes we usually do 10-class detection
liyinhao's avatar
liyinhao committed
8
9
10
11
class_names = [
    'car', 'truck', 'trailer', 'bus', 'construction_vehicle', 'bicycle',
    'motorcycle', 'pedestrian', 'traffic_cone', 'barrier'
]
12
metainfo = dict(classes=class_names)
liyinhao's avatar
liyinhao committed
13
14
dataset_type = 'NuScenesDataset'
data_root = 'data/nuscenes/'
zhangwenwei's avatar
zhangwenwei committed
15
16
# Input modality for nuScenes dataset, this is consistent with the submission
# format which requires the information in input_modality.
VVsssssk's avatar
VVsssssk committed
17
input_modality = dict(use_lidar=True, use_camera=False)
VVsssssk's avatar
VVsssssk committed
18
data_prefix = dict(pts='samples/LIDAR_TOP', img='', sweeps='sweeps/LIDAR_TOP')
19
20

file_client_args = dict(backend='disk')
zhangwenwei's avatar
zhangwenwei committed
21
22
23
# Uncomment the following if use ceph or other file clients.
# See https://mmcv.readthedocs.io/en/latest/api.html#mmcv.fileio.FileClient
# for more details.
zhangwenwei's avatar
zhangwenwei committed
24
25
26
27
28
29
# file_client_args = dict(
#     backend='petrel',
#     path_mapping=dict({
#         './data/nuscenes/': 's3://nuscenes/nuscenes/',
#         'data/nuscenes/': 's3://nuscenes/nuscenes/'
#     }))
30

liyinhao's avatar
liyinhao committed
31
train_pipeline = [
32
33
    dict(type='LoadPointsFromFile', coord_type='LIDAR', load_dim=5, use_dim=5),
    dict(type='LoadPointsFromMultiSweeps', sweeps_num=10),
liyinhao's avatar
liyinhao committed
34
35
    dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True),
    dict(
zhangwenwei's avatar
zhangwenwei committed
36
37
38
39
        type='GlobalRotScaleTrans',
        rot_range=[-0.3925, 0.3925],
        scale_ratio_range=[0.95, 1.05],
        translation_std=[0, 0, 0]),
wuyuefeng's avatar
wuyuefeng committed
40
    dict(type='RandomFlip3D', flip_ratio_bev_horizontal=0.5),
liyinhao's avatar
liyinhao committed
41
42
    dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range),
    dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range),
zhangwenwei's avatar
zhangwenwei committed
43
    dict(type='ObjectNameFilter', classes=class_names),
liyinhao's avatar
liyinhao committed
44
    dict(type='PointShuffle'),
VVsssssk's avatar
VVsssssk committed
45
46
47
    dict(
        type='Pack3DDetInputs',
        keys=['points', 'gt_bboxes_3d', 'gt_labels_3d'])
liyinhao's avatar
liyinhao committed
48
49
]
test_pipeline = [
50
51
    dict(type='LoadPointsFromFile', coord_type='LIDAR', load_dim=5, use_dim=5),
    dict(type='LoadPointsFromMultiSweeps', sweeps_num=10, test_mode=True),
liyinhao's avatar
liyinhao committed
52
    dict(
zhangwenwei's avatar
zhangwenwei committed
53
54
55
56
57
58
59
60
61
62
63
64
        type='MultiScaleFlipAug3D',
        img_scale=(1333, 800),
        pts_scale_ratio=1,
        flip=False,
        transforms=[
            dict(
                type='GlobalRotScaleTrans',
                rot_range=[0, 0],
                scale_ratio_range=[1., 1.],
                translation_std=[0, 0, 0]),
            dict(type='RandomFlip3D'),
            dict(
VVsssssk's avatar
VVsssssk committed
65
66
67
                type='PointsRangeFilter', point_cloud_range=point_cloud_range)
        ]),
    dict(type='Pack3DDetInputs', keys=['points'])
liyinhao's avatar
liyinhao committed
68
]
69
70
71
# 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 = [
72
73
    dict(type='LoadPointsFromFile', coord_type='LIDAR', load_dim=5, use_dim=5),
    dict(type='LoadPointsFromMultiSweeps', sweeps_num=10, test_mode=True),
VVsssssk's avatar
VVsssssk committed
74
    dict(type='Pack3DDetInputs', keys=['points'])
75
]
VVsssssk's avatar
VVsssssk committed
76
77
78
79
80
81
train_dataloader = dict(
    batch_size=4,
    num_workers=4,
    persistent_workers=True,
    sampler=dict(type='DefaultSampler', shuffle=True),
    dataset=dict(
liyinhao's avatar
liyinhao committed
82
83
        type=dataset_type,
        data_root=data_root,
VVsssssk's avatar
VVsssssk committed
84
        ann_file='nuscenes_infos_train.pkl',
liyinhao's avatar
liyinhao committed
85
        pipeline=train_pipeline,
VVsssssk's avatar
VVsssssk committed
86
        metainfo=metainfo,
zhangwenwei's avatar
zhangwenwei committed
87
        modality=input_modality,
wuyuefeng's avatar
Demo  
wuyuefeng committed
88
        test_mode=False,
VVsssssk's avatar
VVsssssk committed
89
        data_prefix=data_prefix,
wuyuefeng's avatar
Demo  
wuyuefeng committed
90
91
        # we use box_type_3d='LiDAR' in kitti and nuscenes dataset
        # and box_type_3d='Depth' in sunrgbd and scannet dataset.
VVsssssk's avatar
VVsssssk committed
92
93
94
95
96
97
98
99
        box_type_3d='LiDAR'))
test_dataloader = dict(
    batch_size=1,
    num_workers=1,
    persistent_workers=True,
    drop_last=False,
    sampler=dict(type='DefaultSampler', shuffle=False),
    dataset=dict(
liyinhao's avatar
liyinhao committed
100
101
        type=dataset_type,
        data_root=data_root,
VVsssssk's avatar
VVsssssk committed
102
        ann_file='nuscenes_infos_val.pkl',
liyinhao's avatar
liyinhao committed
103
        pipeline=test_pipeline,
VVsssssk's avatar
VVsssssk committed
104
        metainfo=metainfo,
zhangwenwei's avatar
zhangwenwei committed
105
        modality=input_modality,
VVsssssk's avatar
VVsssssk committed
106
        data_prefix=data_prefix,
wuyuefeng's avatar
Demo  
wuyuefeng committed
107
        test_mode=True,
VVsssssk's avatar
VVsssssk committed
108
109
110
111
112
113
114
115
        box_type_3d='LiDAR'))
val_dataloader = dict(
    batch_size=1,
    num_workers=1,
    persistent_workers=True,
    drop_last=False,
    sampler=dict(type='DefaultSampler', shuffle=False),
    dataset=dict(
liyinhao's avatar
liyinhao committed
116
117
        type=dataset_type,
        data_root=data_root,
VVsssssk's avatar
VVsssssk committed
118
        ann_file='nuscenes_infos_val.pkl',
liyinhao's avatar
liyinhao committed
119
        pipeline=test_pipeline,
VVsssssk's avatar
VVsssssk committed
120
        metainfo=metainfo,
zhangwenwei's avatar
zhangwenwei committed
121
        modality=input_modality,
wuyuefeng's avatar
Demo  
wuyuefeng committed
122
        test_mode=True,
VVsssssk's avatar
VVsssssk committed
123
        data_prefix=data_prefix,
wuyuefeng's avatar
Demo  
wuyuefeng committed
124
        box_type_3d='LiDAR'))
VVsssssk's avatar
VVsssssk committed
125
126
127
128
129
130
131

val_evaluator = dict(
    type='NuScenesMetric',
    data_root=data_root,
    ann_file=data_root + 'nuscenes_infos_val.pkl',
    metric='bbox')
test_evaluator = val_evaluator
132
133
134
135

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