-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathoneformer3d_1xb4_scannet200.py
302 lines (288 loc) · 10.7 KB
/
oneformer3d_1xb4_scannet200.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
_base_ = [
'mmdet3d::_base_/default_runtime.py',
'mmdet3d::_base_/datasets/scannet-seg.py'
]
custom_imports = dict(imports=['oneformer3d'])
# model settings
num_instance_classes = 198
num_semantic_classes = 200
model = dict(
type='ScanNet200OneFormer3D',
data_preprocessor=dict(type='Det3DDataPreprocessor_'),
voxel_size=0.02,
num_classes=num_instance_classes,
query_thr=0.5,
backbone=dict(
type='Res16UNet34C',
in_channels=3,
out_channels=96,
config=dict(
dilations=[1, 1, 1, 1],
conv1_kernel_size=5,
bn_momentum=0.02)),
decoder=dict(
type='ScanNetQueryDecoder',
num_layers=6,
num_instance_queries=0,
num_semantic_queries=0,
num_instance_classes=num_instance_classes,
num_semantic_classes=num_semantic_classes,
num_semantic_linears=1,
in_channels=96,
d_model=256,
num_heads=8,
hidden_dim=1024,
dropout=0.0,
activation_fn='gelu',
iter_pred=True,
attn_mask=True,
fix_attention=True,
objectness_flag=False),
criterion=dict(
type='ScanNetUnifiedCriterion',
num_semantic_classes=num_semantic_classes,
sem_criterion=dict(
type='ScanNetSemanticCriterion',
ignore_index=num_semantic_classes,
loss_weight=0.5),
inst_criterion=dict(
type='InstanceCriterion',
matcher=dict(
type='SparseMatcher',
costs=[
dict(type='QueryClassificationCost', weight=0.5),
dict(type='MaskBCECost', weight=1.0),
dict(type='MaskDiceCost', weight=1.0)],
topk=1),
loss_weight=[0.5, 1.0, 1.0, 0.5],
num_classes=num_instance_classes,
non_object_weight=0.1,
fix_dice_loss_weight=True,
iter_matcher=True,
fix_mean_loss=True)),
train_cfg=dict(),
test_cfg=dict(
topk_insts=600,
inst_score_thr=0.0,
pan_score_thr=0.5,
npoint_thr=100,
obj_normalization=True,
sp_score_thr=0.4,
nms=True,
matrix_nms_kernel='linear',
stuff_classes=[0, 1]))
# dataset settings
dataset_type = 'ScanNet200SegDataset_'
data_root = 'data/scannet200/'
data_prefix = dict(
pts='points',
pts_instance_mask='instance_mask',
pts_semantic_mask='semantic_mask',
sp_pts_mask='super_points')
# floor and chair are changed
class_names = [
'wall', 'floor', 'chair', 'table', 'door', 'couch', 'cabinet', 'shelf',
'desk', 'office chair', 'bed', 'pillow', 'sink', 'picture', 'window',
'toilet', 'bookshelf', 'monitor', 'curtain', 'book', 'armchair',
'coffee table', 'box', 'refrigerator', 'lamp', 'kitchen cabinet', 'towel',
'clothes', 'tv', 'nightstand', 'counter', 'dresser', 'stool', 'cushion',
'plant', 'ceiling', 'bathtub', 'end table', 'dining table', 'keyboard',
'bag', 'backpack', 'toilet paper', 'printer', 'tv stand', 'whiteboard',
'blanket', 'shower curtain', 'trash can', 'closet', 'stairs', 'microwave',
'stove', 'shoe', 'computer tower', 'bottle', 'bin', 'ottoman', 'bench',
'board', 'washing machine', 'mirror', 'copier', 'basket', 'sofa chair',
'file cabinet', 'fan', 'laptop', 'shower', 'paper', 'person',
'paper towel dispenser', 'oven', 'blinds', 'rack', 'plate', 'blackboard',
'piano', 'suitcase', 'rail', 'radiator', 'recycling bin', 'container',
'wardrobe', 'soap dispenser', 'telephone', 'bucket', 'clock', 'stand',
'light', 'laundry basket', 'pipe', 'clothes dryer', 'guitar',
'toilet paper holder', 'seat', 'speaker', 'column', 'bicycle', 'ladder',
'bathroom stall', 'shower wall', 'cup', 'jacket', 'storage bin',
'coffee maker', 'dishwasher', 'paper towel roll', 'machine', 'mat',
'windowsill', 'bar', 'toaster', 'bulletin board', 'ironing board',
'fireplace', 'soap dish', 'kitchen counter', 'doorframe',
'toilet paper dispenser', 'mini fridge', 'fire extinguisher', 'ball',
'hat', 'shower curtain rod', 'water cooler', 'paper cutter', 'tray',
'shower door', 'pillar', 'ledge', 'toaster oven', 'mouse',
'toilet seat cover dispenser', 'furniture', 'cart', 'storage container',
'scale', 'tissue box', 'light switch', 'crate', 'power outlet',
'decoration', 'sign', 'projector', 'closet door', 'vacuum cleaner',
'candle', 'plunger', 'stuffed animal', 'headphones', 'dish rack',
'broom', 'guitar case', 'range hood', 'dustpan', 'hair dryer',
'water bottle', 'handicap bar', 'purse', 'vent', 'shower floor',
'water pitcher', 'mailbox', 'bowl', 'paper bag', 'alarm clock',
'music stand', 'projector screen', 'divider', 'laundry detergent',
'bathroom counter', 'object', 'bathroom vanity', 'closet wall',
'laundry hamper', 'bathroom stall door', 'ceiling light', 'trash bin',
'dumbbell', 'stair rail', 'tube', 'bathroom cabinet', 'cd case',
'closet rod', 'coffee kettle', 'structure', 'shower head',
'keyboard piano', 'case of water bottles', 'coat rack',
'storage organizer', 'folded chair', 'fire alarm', 'power strip',
'calendar', 'poster', 'potted plant', 'luggage', 'mattress'
]
color_mean = (
0.47793125906962 * 255,
0.4303257521323044 * 255,
0.3749598901421883 * 255)
color_std = (
0.2834475483823543 * 255,
0.27566157565723015 * 255,
0.27018971370874995 * 255)
train_pipeline = [
dict(
type='LoadPointsFromFile',
coord_type='DEPTH',
shift_height=False,
use_color=True,
load_dim=6,
use_dim=[0, 1, 2, 3, 4, 5]),
dict(
type='LoadAnnotations3D_',
with_bbox_3d=False,
with_label_3d=False,
with_mask_3d=True,
with_seg_3d=True,
with_sp_mask_3d=True),
dict(type='SwapChairAndFloor'),
dict(type='PointSegClassMapping'),
dict(
type='RandomFlip3D',
sync_2d=False,
flip_ratio_bev_horizontal=0.5,
flip_ratio_bev_vertical=0.5),
dict(
type='GlobalRotScaleTrans',
rot_range=[-3.14, 3.14],
scale_ratio_range=[0.8, 1.2],
translation_std=[0.1, 0.1, 0.1],
shift_height=False),
dict(
type='NormalizePointsColor_',
color_mean=color_mean,
color_std=color_std),
dict(
type='AddSuperPointAnnotations',
num_classes=num_semantic_classes,
stuff_classes=[0, 1],
merge_non_stuff_cls=False),
dict(
type='ElasticTransfrom',
gran=[6, 20],
mag=[40, 160],
voxel_size=0.02,
p=0.5),
dict(
type='Pack3DDetInputs_',
keys=[
'points', 'gt_labels_3d', 'pts_semantic_mask', 'pts_instance_mask',
'sp_pts_mask', 'gt_sp_masks', 'elastic_coords'
])
]
test_pipeline = [
dict(
type='LoadPointsFromFile',
coord_type='DEPTH',
shift_height=False,
use_color=True,
load_dim=6,
use_dim=[0, 1, 2, 3, 4, 5]),
dict(
type='LoadAnnotations3D_',
with_bbox_3d=False,
with_label_3d=False,
with_mask_3d=True,
with_seg_3d=True,
with_sp_mask_3d=True),
dict(type='SwapChairAndFloor'),
dict(type='PointSegClassMapping'),
dict(
type='MultiScaleFlipAug3D',
img_scale=(1333, 800),
pts_scale_ratio=1,
flip=False,
transforms=[
dict(
type='NormalizePointsColor_',
color_mean=color_mean,
color_std=color_std),
dict(
type='AddSuperPointAnnotations',
num_classes=num_semantic_classes,
stuff_classes=[0, 1],
merge_non_stuff_cls=False),
]),
dict(type='Pack3DDetInputs_', keys=['points', 'sp_pts_mask'])
]
# run settings
train_dataloader = dict(
batch_size=4,
num_workers=6,
dataset=dict(
type=dataset_type,
ann_file='scannet200_oneformer3d_infos_train.pkl',
data_root=data_root,
data_prefix=data_prefix,
metainfo=dict(classes=class_names),
pipeline=train_pipeline,
ignore_index=num_semantic_classes,
scene_idxs=None,
test_mode=False))
val_dataloader = dict(
dataset=dict(
type=dataset_type,
ann_file='scannet200_oneformer3d_infos_val.pkl',
data_root=data_root,
data_prefix=data_prefix,
metainfo=dict(classes=class_names),
pipeline=test_pipeline,
ignore_index=num_semantic_classes,
test_mode=True))
test_dataloader = val_dataloader
label2cat = {i: name for i, name in enumerate(class_names + ['unlabeled'])}
metric_meta = dict(
label2cat=label2cat,
ignore_index=[num_semantic_classes],
classes=class_names + ['unlabeled'],
dataset_name='ScanNet200')
sem_mapping = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 44, 45, 46,
47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 84, 86, 87, 88, 89, 90,
93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 110, 112,
115, 116, 118, 120, 121, 122, 125, 128, 130, 131, 132, 134, 136, 138, 139,
140, 141, 145, 148, 154, 155, 156, 157, 159, 161, 163, 165, 166, 168, 169,
170, 177, 180, 185, 188, 191, 193, 195, 202, 208, 213, 214, 221, 229, 230,
232, 233, 242, 250, 261, 264, 276, 283, 286, 300, 304, 312, 323, 325, 331,
342, 356, 370, 392, 395, 399, 408, 417, 488, 540, 562, 570, 572, 581, 609,
748, 776, 1156, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172,
1173, 1174, 1175, 1176, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185,
1186, 1187, 1188, 1189, 1190, 1191
]
inst_mapping = sem_mapping[2:]
val_evaluator = dict(
type='UnifiedSegMetric',
stuff_class_inds=[0, 1],
thing_class_inds=list(range(2, num_semantic_classes)),
min_num_points=1,
id_offset=2**16,
sem_mapping=sem_mapping,
inst_mapping=inst_mapping,
metric_meta=metric_meta)
test_evaluator = val_evaluator
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(type='AdamW', lr=0.0001, weight_decay=0.05),
clip_grad=dict(max_norm=10, norm_type=2))
param_scheduler = dict(type='PolyLR', begin=0, end=512, power=0.9)
custom_hooks = [dict(type='EmptyCacheHook', after_iter=True)]
default_hooks = dict(
checkpoint=dict(
interval=1,
max_keep_ckpts=1,
save_best=['all_ap_50%', 'miou'],
rule='greater'))
load_from = 'work_dirs/tmp/mask3d_scannet200.pth'
train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=512, val_interval=16)
val_cfg = dict(type='ValLoop')
test_cfg = dict(type='TestLoop')