sushruthb commited on
Commit
ec3bc7e
·
verified ·
1 Parent(s): 4e223bf

Upload 2 files

Browse files

Added missing model files.

SweMPer-layout.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99496dd9cdf8a340221cdee68d7fb4690964f9908b54c3d5c8415779cd0d193e
3
+ size 5852360569
co_dino_5scale_vit_large_coco.py ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dataset_type = 'CocoDataset'
2
+ data_root = 'data/coco/'
3
+ img_norm_cfg = dict(
4
+ mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
5
+ train_pipeline = [
6
+ dict(type='LoadImageFromFile'),
7
+ dict(type='LoadAnnotations', with_bbox=True),
8
+ dict(type='RandomFlip', flip_ratio=0.5),
9
+ dict(
10
+ type='AutoAugment',
11
+ policies=[[{
12
+ 'type':
13
+ 'Resize',
14
+ 'img_scale': [(480, 1200), (512, 1200), (544, 1200), (576, 1200),
15
+ (608, 1200), (640, 1200), (672, 1200), (704, 1200),
16
+ (736, 1200), (768, 1200), (800, 1200), (832, 1200),
17
+ (864, 1200)],
18
+ 'multiscale_mode':
19
+ 'value',
20
+ 'keep_ratio':
21
+ True
22
+ }],
23
+ [{
24
+ 'type': 'Resize',
25
+ 'img_scale': [(400, 4200), (500, 4200), (600, 4200)],
26
+ 'multiscale_mode': 'value',
27
+ 'keep_ratio': True
28
+ }, {
29
+ 'type':
30
+ 'Resize',
31
+ 'img_scale': [(480, 1200), (512, 1200), (544, 1200),
32
+ (576, 1200), (608, 1200), (640, 1200),
33
+ (672, 1200), (704, 1200), (736, 1200),
34
+ (768, 1200), (800, 1200), (832, 1200),
35
+ (864, 1200)],
36
+ 'multiscale_mode':
37
+ 'value',
38
+ 'override':
39
+ True,
40
+ 'keep_ratio':
41
+ True
42
+ }]]),
43
+ dict(
44
+ type='Normalize',
45
+ mean=[123.675, 116.28, 103.53],
46
+ std=[58.395, 57.12, 57.375],
47
+ to_rgb=True),
48
+ dict(type='Pad', size_divisor=32),
49
+ dict(type='DefaultFormatBundle'),
50
+ dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
51
+ ]
52
+ test_pipeline = [
53
+ dict(type='LoadImageFromFile'),
54
+ dict(
55
+ type='MultiScaleFlipAug',
56
+ img_scale=(1200, 800),
57
+ flip=False,
58
+ transforms=[
59
+ dict(type='Resize', keep_ratio=True),
60
+ dict(type='RandomFlip'),
61
+ dict(
62
+ type='Normalize',
63
+ mean=[123.675, 116.28, 103.53],
64
+ std=[58.395, 57.12, 57.375],
65
+ to_rgb=True),
66
+ dict(type='Pad', size_divisor=32),
67
+ dict(type='ImageToTensor', keys=['img']),
68
+ dict(type='Collect', keys=['img'])
69
+ ])
70
+ ]
71
+ data = dict(
72
+ samples_per_gpu=1,
73
+ workers_per_gpu=1,
74
+ train=dict(
75
+ type='CocoDataset',
76
+ img_prefix=
77
+ './layout-model-training/Layout-detection-26/train/',
78
+ ann_file=
79
+ './layout-model-training/Layout-detection-26/train/updated_annotations.json',
80
+ filter_empty_gt=True,
81
+ pipeline=[
82
+ dict(type='LoadImageFromFile'),
83
+ dict(type='LoadAnnotations', with_bbox=True),
84
+ dict(type='RandomFlip', flip_ratio=0.5),
85
+ dict(
86
+ type='AutoAugment',
87
+ policies=[[{
88
+ 'type':
89
+ 'Resize',
90
+ 'img_scale': [(480, 1200), (512, 1200), (544, 1200),
91
+ (576, 1200), (608, 1200), (640, 1200),
92
+ (672, 1200), (704, 1200), (736, 1200),
93
+ (768, 1200), (800, 1200), (832, 1200),
94
+ (864, 1200)],
95
+ 'multiscale_mode':
96
+ 'value',
97
+ 'keep_ratio':
98
+ True
99
+ }],
100
+ [{
101
+ 'type': 'Resize',
102
+ 'img_scale': [(400, 4200), (500, 4200),
103
+ (600, 4200)],
104
+ 'multiscale_mode': 'value',
105
+ 'keep_ratio': True
106
+ }, {
107
+ 'type':
108
+ 'Resize',
109
+ 'img_scale': [(480, 1200), (512, 1200),
110
+ (544, 1200), (576, 1200),
111
+ (608, 1200), (640, 1200),
112
+ (672, 1200), (704, 1200),
113
+ (736, 1200), (768, 1200),
114
+ (800, 1200), (832, 1200),
115
+ (864, 1200)],
116
+ 'multiscale_mode':
117
+ 'value',
118
+ 'override':
119
+ True,
120
+ 'keep_ratio':
121
+ True
122
+ }]]),
123
+ dict(
124
+ type='Normalize',
125
+ mean=[123.675, 116.28, 103.53],
126
+ std=[58.395, 57.12, 57.375],
127
+ to_rgb=True),
128
+ dict(type='Pad', size_divisor=32),
129
+ dict(type='DefaultFormatBundle'),
130
+ dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
131
+ ]),
132
+ val=dict(
133
+ type='CocoDataset',
134
+ img_prefix=
135
+ './layout-model-training/Layout-detection-26/test/',
136
+ ann_file=
137
+ './layout-model-training/Layout-detection-26/test/updated_annotations.json',
138
+ pipeline=[
139
+ dict(type='LoadImageFromFile'),
140
+ dict(
141
+ type='MultiScaleFlipAug',
142
+ img_scale=(1200, 800),
143
+ flip=False,
144
+ transforms=[
145
+ dict(type='Resize', keep_ratio=True),
146
+ dict(type='RandomFlip'),
147
+ dict(
148
+ type='Normalize',
149
+ mean=[123.675, 116.28, 103.53],
150
+ std=[58.395, 57.12, 57.375],
151
+ to_rgb=True),
152
+ dict(type='Pad', size_divisor=32),
153
+ dict(type='ImageToTensor', keys=['img']),
154
+ dict(type='Collect', keys=['img'])
155
+ ])
156
+ ]),
157
+ test=dict(
158
+ type='CocoDataset',
159
+ img_prefix=
160
+ './swemper_layout_train/layout-model-training/Layout-detection-26/test/',
161
+ ann_file=
162
+ './swemper_layout_train/layout-model-training/Layout-detection-26/test/updated_annotations.json',
163
+ pipeline=[
164
+ dict(type='LoadImageFromFile'),
165
+ dict(
166
+ type='MultiScaleFlipAug',
167
+ img_scale=(1200, 800),
168
+ flip=False,
169
+ transforms=[
170
+ dict(type='Resize', keep_ratio=True),
171
+ dict(type='RandomFlip'),
172
+ dict(
173
+ type='Normalize',
174
+ mean=[123.675, 116.28, 103.53],
175
+ std=[58.395, 57.12, 57.375],
176
+ to_rgb=True),
177
+ dict(type='Pad', size_divisor=32),
178
+ dict(type='ImageToTensor', keys=['img']),
179
+ dict(type='Collect', keys=['img'])
180
+ ])
181
+ ]))
182
+ evaluation = dict(interval=1, metric='bbox')
183
+ checkpoint_config = dict(interval=1)
184
+ log_config = dict(interval=50, hooks=[dict(type='TextLoggerHook')])
185
+ custom_hooks = [dict(type='ExpMomentumEMAHook', momentum=0.0001, priority=49)]
186
+ dist_params = dict(backend='nccl')
187
+ log_level = 'INFO'
188
+ load_from = '/home/sush/Co-DETR/work_dir/pln_l40s_latest/best_bbox_mAP_iter_44000.pth'
189
+ resume_from = None
190
+ workflow = [('train', 1)]
191
+ opencv_num_threads = 0
192
+ mp_start_method = 'fork'
193
+ auto_scale_lr = dict(enable=False, base_batch_size=16)
194
+ train_ann = './layout-model-training/Layout-detection-26/train/updated_annotations.json'
195
+ val_ann = './layout-model-training/Layout-detection-26/test/updated_annotations.json'
196
+ test_ann = './layout-model-training/Layout-detection-26/test/updated_annotations.json'
197
+ classes = ('advertisement', 'author', 'header_or_footer', 'image', 'list',
198
+ 'page_no', 'table', 'text', 'title')
199
+ metainfo = dict(
200
+ classes=('advertisement', 'author', 'header_or_footer', 'image', 'list',
201
+ 'page_no', 'table', 'text', 'title'))
202
+ pretrained = None
203
+ window_block_indexes = [
204
+ 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, 26
205
+ ]
206
+ residual_block_indexes = []
207
+ num_dec_layer = 6
208
+ lambda_2 = 2.0
209
+ model = dict(
210
+ type='CoDETR',
211
+ backbone=dict(
212
+ type='ViT',
213
+ img_size=1200,
214
+ pretrain_img_size=512,
215
+ patch_size=16,
216
+ embed_dim=1024,
217
+ depth=24,
218
+ num_heads=16,
219
+ mlp_ratio=2.6666666666666665,
220
+ drop_path_rate=0.4,
221
+ window_size=24,
222
+ window_block_indexes=[
223
+ 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24,
224
+ 25, 26
225
+ ],
226
+ residual_block_indexes=[],
227
+ qkv_bias=True,
228
+ use_act_checkpoint=True,
229
+ init_cfg=None),
230
+ neck=dict(
231
+ type='SFP',
232
+ in_channels=[1024],
233
+ out_channels=256,
234
+ num_outs=5,
235
+ use_p2=True,
236
+ use_act_checkpoint=False),
237
+ rpn_head=dict(
238
+ type='RPNHead',
239
+ in_channels=256,
240
+ feat_channels=256,
241
+ anchor_generator=dict(
242
+ type='AnchorGenerator',
243
+ octave_base_scale=4,
244
+ scales_per_octave=3,
245
+ ratios=[0.5, 1.0, 2.0, 3.0, 4.0, 5.0],
246
+ strides=[4, 8, 16, 32, 64, 128]),
247
+ bbox_coder=dict(
248
+ type='DeltaXYWHBBoxCoder',
249
+ target_means=[0.0, 0.0, 0.0, 0.0],
250
+ target_stds=[1.0, 1.0, 1.0, 1.0]),
251
+ loss_cls=dict(
252
+ type='CrossEntropyLoss', use_sigmoid=True, loss_weight=12.0),
253
+ loss_bbox=dict(type='L1Loss', loss_weight=12.0)),
254
+ query_head=dict(
255
+ type='CoDINOHead',
256
+ num_query=1500,
257
+ num_classes=9,
258
+ num_feature_levels=5,
259
+ in_channels=2048,
260
+ sync_cls_avg_factor=True,
261
+ as_two_stage=True,
262
+ with_box_refine=True,
263
+ mixed_selection=True,
264
+ dn_cfg=dict(
265
+ type='CdnQueryGenerator',
266
+ noise_scale=dict(label=0.5, box=0.4),
267
+ group_cfg=dict(dynamic=True, num_groups=None, num_dn_queries=300)),
268
+ transformer=dict(
269
+ type='CoDinoTransformer',
270
+ with_pos_coord=True,
271
+ with_coord_feat=False,
272
+ num_co_heads=2,
273
+ num_feature_levels=5,
274
+ encoder=dict(
275
+ type='DetrTransformerEncoder',
276
+ num_layers=6,
277
+ with_cp=6,
278
+ transformerlayers=dict(
279
+ type='BaseTransformerLayer',
280
+ attn_cfgs=dict(
281
+ type='MultiScaleDeformableAttention',
282
+ embed_dims=256,
283
+ num_levels=5,
284
+ dropout=0.0),
285
+ feedforward_channels=2048,
286
+ ffn_dropout=0.0,
287
+ operation_order=('self_attn', 'norm', 'ffn', 'norm'))),
288
+ decoder=dict(
289
+ type='DinoTransformerDecoder',
290
+ num_layers=6,
291
+ return_intermediate=True,
292
+ transformerlayers=dict(
293
+ type='DetrTransformerDecoderLayer',
294
+ attn_cfgs=[
295
+ dict(
296
+ type='MultiheadAttention',
297
+ embed_dims=256,
298
+ num_heads=8,
299
+ dropout=0.0),
300
+ dict(
301
+ type='MultiScaleDeformableAttention',
302
+ embed_dims=256,
303
+ num_levels=5,
304
+ dropout=0.0)
305
+ ],
306
+ feedforward_channels=2048,
307
+ ffn_dropout=0.0,
308
+ operation_order=('self_attn', 'norm', 'cross_attn', 'norm',
309
+ 'ffn', 'norm')))),
310
+ positional_encoding=dict(
311
+ type='SinePositionalEncoding',
312
+ num_feats=128,
313
+ temperature=20,
314
+ normalize=True),
315
+ loss_cls=dict(
316
+ type='QualityFocalLoss',
317
+ use_sigmoid=True,
318
+ beta=2.0,
319
+ loss_weight=1.0),
320
+ loss_bbox=dict(type='L1Loss', loss_weight=5.0),
321
+ loss_iou=dict(type='GIoULoss', loss_weight=2.0)),
322
+ roi_head=[
323
+ dict(
324
+ type='CoStandardRoIHead',
325
+ bbox_roi_extractor=dict(
326
+ type='SingleRoIExtractor',
327
+ roi_layer=dict(
328
+ type='RoIAlign', output_size=7, sampling_ratio=0),
329
+ out_channels=256,
330
+ featmap_strides=[4, 8, 16, 32, 64],
331
+ finest_scale=56),
332
+ bbox_head=dict(
333
+ type='ConvFCBBoxHead',
334
+ num_shared_convs=4,
335
+ num_shared_fcs=1,
336
+ in_channels=256,
337
+ conv_out_channels=256,
338
+ fc_out_channels=1024,
339
+ roi_feat_size=7,
340
+ num_classes=9,
341
+ bbox_coder=dict(
342
+ type='DeltaXYWHBBoxCoder',
343
+ target_means=[0.0, 0.0, 0.0, 0.0],
344
+ target_stds=[0.05, 0.05, 0.1, 0.1]),
345
+ reg_class_agnostic=True,
346
+ reg_decoded_bbox=True,
347
+ norm_cfg=dict(type='GN', num_groups=32),
348
+ loss_cls=dict(
349
+ type='CrossEntropyLoss',
350
+ use_sigmoid=False,
351
+ loss_weight=12.0),
352
+ loss_bbox=dict(type='GIoULoss', loss_weight=120.0)))
353
+ ],
354
+ bbox_head=[
355
+ dict(
356
+ type='CoATSSHead',
357
+ num_classes=9,
358
+ in_channels=256,
359
+ stacked_convs=1,
360
+ feat_channels=256,
361
+ anchor_generator=dict(
362
+ type='AnchorGenerator',
363
+ ratios=[1.0],
364
+ octave_base_scale=8,
365
+ scales_per_octave=1,
366
+ strides=[4, 8, 16, 32, 64, 128]),
367
+ bbox_coder=dict(
368
+ type='DeltaXYWHBBoxCoder',
369
+ target_means=[0.0, 0.0, 0.0, 0.0],
370
+ target_stds=[0.1, 0.1, 0.2, 0.2]),
371
+ loss_cls=dict(
372
+ type='FocalLoss',
373
+ use_sigmoid=True,
374
+ gamma=2.0,
375
+ alpha=0.25,
376
+ loss_weight=12.0),
377
+ loss_bbox=dict(type='GIoULoss', loss_weight=24.0),
378
+ loss_centerness=dict(
379
+ type='CrossEntropyLoss', use_sigmoid=True, loss_weight=12.0))
380
+ ],
381
+ train_cfg=[
382
+ dict(
383
+ assigner=dict(
384
+ type='HungarianAssigner',
385
+ cls_cost=dict(type='FocalLossCost', weight=2.0),
386
+ reg_cost=dict(
387
+ type='BBoxL1Cost', weight=5.0, box_format='xywh'),
388
+ iou_cost=dict(type='IoUCost', iou_mode='giou', weight=2.0))),
389
+ dict(
390
+ rpn=dict(
391
+ assigner=dict(
392
+ type='MaxIoUAssigner',
393
+ pos_iou_thr=0.7,
394
+ neg_iou_thr=0.3,
395
+ min_pos_iou=0.3,
396
+ match_low_quality=True,
397
+ ignore_iof_thr=-1),
398
+ sampler=dict(
399
+ type='RandomSampler',
400
+ num=256,
401
+ pos_fraction=0.5,
402
+ neg_pos_ub=-1,
403
+ add_gt_as_proposals=False),
404
+ allowed_border=-1,
405
+ pos_weight=-1,
406
+ debug=False),
407
+ rpn_proposal=dict(
408
+ nms_pre=4000,
409
+ max_per_img=1000,
410
+ nms=dict(type='nms', iou_threshold=0.7),
411
+ min_bbox_size=0),
412
+ rcnn=dict(
413
+ assigner=dict(
414
+ type='MaxIoUAssigner',
415
+ pos_iou_thr=0.5,
416
+ neg_iou_thr=0.5,
417
+ min_pos_iou=0.5,
418
+ match_low_quality=False,
419
+ ignore_iof_thr=-1),
420
+ sampler=dict(
421
+ type='RandomSampler',
422
+ num=512,
423
+ pos_fraction=0.25,
424
+ neg_pos_ub=-1,
425
+ add_gt_as_proposals=True),
426
+ pos_weight=-1,
427
+ debug=False)),
428
+ dict(
429
+ assigner=dict(type='ATSSAssigner', topk=9),
430
+ allowed_border=-1,
431
+ pos_weight=-1,
432
+ debug=False)
433
+ ],
434
+ test_cfg=[
435
+ dict(max_per_img=1000, nms=dict(type='soft_nms', iou_threshold=0.8)),
436
+ dict(
437
+ rpn=dict(
438
+ nms_pre=8000,
439
+ max_per_img=2000,
440
+ nms=dict(type='nms', iou_threshold=0.9),
441
+ min_bbox_size=0),
442
+ rcnn=dict(
443
+ score_thr=0.0,
444
+ mask_thr_binary=0.5,
445
+ nms=dict(type='soft_nms', iou_threshold=0.5),
446
+ max_per_img=1000)),
447
+ dict(
448
+ nms_pre=1000,
449
+ min_bbox_size=0,
450
+ score_thr=0.0,
451
+ nms=dict(type='soft_nms', iou_threshold=0.6),
452
+ max_per_img=100)
453
+ ])
454
+ lr_config = dict(
455
+ policy='step',
456
+ warmup='linear',
457
+ warmup_iters=800,
458
+ warmup_ratio=0.01,
459
+ step=[21, 27])
460
+ runner = dict(type='EpochBasedRunner', max_epochs=30)
461
+ optimizer_config = dict(grad_clip=dict(max_norm=0.1, norm_type=2))
462
+ optimizer = dict(
463
+ type='AdamW',
464
+ lr=5e-05,
465
+ weight_decay=0.01,
466
+ constructor='LayerDecayOptimizerConstructor',
467
+ paramwise_cfg=dict(num_layers=24, layer_decay_rate=0.8))
468
+ work_dir = 'work_dir/TL_v1/'
469
+ auto_resume = False
470
+ gpu_ids = range(0, 3)