-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretformer_waymo_D1_2x_3class.py
302 lines (291 loc) · 8.99 KB
/
retformer_waymo_D1_2x_3class.py
1
2
3
4
5
6
7
8
9
10
11
12
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
plugin = True
plugin_dir = 'mmdet3d_plugin'
voxel_size = (0.32, 0.32, 6)
point_cloud_range = [-74.88, -74.88, -2, 74.88, 74.88, 4]
model = dict(
type='DynamicCenterPoint',
voxel_layer=dict(
voxel_size=voxel_size,
max_num_points=-1,
point_cloud_range=point_cloud_range,
max_voxels=(-1, -1)
),
voxel_encoder=dict(
type='DynamicVFECustom',
in_channels=5,
feat_channels=[64, 128],
with_distance=False,
voxel_size=voxel_size,
with_cluster_center=True,
with_voxel_center=True,
point_cloud_range=point_cloud_range,
norm_cfg=dict(type='naiveSyncBN1d', eps=1e-3, momentum=0.01)
),
middle_encoder=dict(
type='RetFormer',
embed_dim=128,
num_heads=4,
num_blocks=2,
activation="gelu",
window_shape=(9, 9, 1),
sparse_shape=(468, 468, 1),
output_shape=(468, 468),
pos_temperature=10000,
normalize_pos=False,
group_size=69,
),
backbone=dict(
type='SECONDCustom',
in_channels=128,
out_channels=[64, 128],
layer_nums=[3, 3],
layer_strides=[1, 2],
conv_cfg=dict(type='Conv2d', bias=False),
norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01),
residual=True,
),
neck=dict(
type='SECONDFPN',
norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01),
in_channels=[64, 128],
upsample_strides=[1, 2],
out_channels=[128, 128]
),
bbox_head=dict(
type='CenterHead',
in_channels=256,
tasks=[
dict(num_class=3, class_names=['car', 'pedestrian', 'cyclist']),
],
common_heads=dict(
reg=(2, 2), height=(1, 2), dim=(3, 2), rot=(2, 2), iou=(1, 2)
),
share_conv_channel=64,
bbox_coder=dict(
type='CenterPointBBoxCoder',
post_center_range=[-74.88, -74.88, -10.0, 74.88, 74.88, 10.0],
max_num=4096,
score_threshold=0.1,
out_size_factor=1,
voxel_size=voxel_size[:2],
pc_range=point_cloud_range[:2],
code_size=7),
separate_head=dict(
type='SeparateHead', init_bias=-2.19, final_kernel=3,
),
norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01),
loss_cls=dict(type='GaussianFocalLoss', reduction='mean'),
loss_bbox=dict(type='L1Loss', reduction='mean', loss_weight=2),
norm_bbox=True
),
# model training and testing settings
train_cfg=dict(
grid_size=[468, 468, 1],
voxel_size=voxel_size,
out_size_factor=1,
dense_reg=1,
gaussian_overlap=0.1,
max_objs=500,
min_radius=1,
point_cloud_range=point_cloud_range,
code_weights=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
iou_weight=1.0
),
test_cfg=dict(
post_center_limit_range=[-80, -80, -10, 80, 80, 10],
max_per_img=500,
max_pool_nms=False,
min_radius=[4, 12, 10, 1, 0.85, 0.175],
score_threshold=0.1,
pc_range=point_cloud_range[:2],
out_size_factor=1,
voxel_size=voxel_size[:2],
nms_type='rotate',
pre_max_size=4096,
post_max_size=500,
nms_thr=0.7,
iou_pow=2.0
)
)
# dataset settings
# D5 in the config name means the whole dataset is divided into 5 folds
# We only use one fold for efficient experiments
dataset_type = 'WaymoDatasetCustom'
data_root = 'data/waymo/kitti_format/'
file_client_args = dict(backend='disk')
class_names = ['Car', 'Pedestrian', 'Cyclist']
input_modality = dict(use_lidar=True, use_camera=False)
db_sampler = dict(
data_root=data_root,
info_path=data_root + 'waymo_dbinfos_train.pkl',
rate=1.0,
prepare=dict(
filter_by_difficulty=[-1],
filter_by_min_points=dict(Car=5, Pedestrian=10, Cyclist=10)),
classes=class_names,
sample_groups=dict(Car=15, Pedestrian=10, Cyclist=10),
points_loader=dict(
type='LoadPointsFromFileCustom',
coord_type='LIDAR',
load_dim=6,
tanh_dim=[3, 4],
use_dim=[0, 1, 2, 3, 4],
file_client_args=file_client_args))
train_pipeline = [
dict(
type='LoadPointsFromFileCustom',
coord_type='LIDAR',
load_dim=6,
use_dim=5,
tanh_dim=[3, 4],
file_client_args=file_client_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=True,
with_label_3d=True,
file_client_args=file_client_args),
dict(type='ObjectSample', db_sampler=db_sampler),
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]),
dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range),
dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range),
dict(type='PointShuffle'),
dict(type='DefaultFormatBundle3D', class_names=class_names),
dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d'])
]
test_pipeline = [
dict(
type='LoadPointsFromFileCustom',
coord_type='LIDAR',
load_dim=6,
use_dim=5,
tanh_dim=[3, 4],
file_client_args=file_client_args),
dict(
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(
type='PointsRangeFilter', point_cloud_range=point_cloud_range),
dict(
type='DefaultFormatBundle3D',
class_names=class_names,
with_label=False),
dict(type='Collect3D', keys=['points'])
])
]
# 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 = [
dict(
type='LoadPointsFromFileCustom',
coord_type='LIDAR',
load_dim=6,
use_dim=5,
tanh_dim=[3, 4],
file_client_args=file_client_args),
dict(
type='DefaultFormatBundle3D',
class_names=class_names,
with_label=False),
dict(type='Collect3D', keys=['points'])
]
# fp16 = dict(loss_scale=32.0)
data = dict(
samples_per_gpu=2,
workers_per_gpu=8,
train=dict(
type='RepeatDataset',
times=1,
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file=data_root + 'waymo_infos_train.pkl',
split='training',
pipeline=train_pipeline,
modality=input_modality,
classes=class_names,
test_mode=False,
# we use box_type_3d='LiDAR' in kitti and nuscenes dataset
# and box_type_3d='Depth' in sunrgbd and scannet dataset.
box_type_3d='LiDAR',
load_interval=1)),
val=dict(
type=dataset_type,
data_root=data_root,
ann_file=data_root + 'waymo_infos_val.pkl',
split='training',
pipeline=test_pipeline,
modality=input_modality,
classes=class_names,
test_mode=True,
box_type_3d='LiDAR'),
test=dict(
type=dataset_type,
data_root=data_root,
ann_file=data_root + 'waymo_infos_val.pkl',
split='training',
pipeline=test_pipeline,
modality=input_modality,
classes=class_names,
test_mode=True,
box_type_3d='LiDAR'))
evaluation = dict(interval=24, pipeline=eval_pipeline)
lr = 1e-5
optimizer = dict(
type='AdamW',
lr=lr,
betas=(0.9, 0.999), # the momentum is change during training
weight_decay=0.05,
paramwise_cfg=dict(custom_keys={'norm': dict(decay_mult=0.)}),
)
optimizer_config = dict(grad_clip=dict(max_norm=10, norm_type=2))
lr_config = dict(
policy='cyclic',
target_ratio=(100, 1e-3),
cyclic_times=1,
step_ratio_up=0.1,
)
momentum_config = None
runner = dict(type='EpochBasedRunner', max_epochs=24)
checkpoint_config = dict(interval=1)
# yapf:disable push
# By default we use textlogger hook and tensorboard
# For more loggers see
# https://mmcv.readthedocs.io/en/latest/api.html#mmcv.runner.LoggerHook
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
dict(type='TensorboardLoggerHook')
])
# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = None
load_from = None
resume_from = None
cudnn_benchmark = False
workflow = [('train', 1)]
seed = 0
deterministic = False
find_unused_parameters = True
# disable opencv multithreading to avoid system being overloaded
opencv_num_threads = 0
# set multi-process start method as `fork` to speed up the training
mp_start_method = 'fork'