MendoPower commited on
Commit
60d92f2
·
verified ·
1 Parent(s): 302a739

Delete grounding_dino_swin-t_finetune_16xb2_1x_coco.py

Browse files
grounding_dino_swin-t_finetune_16xb2_1x_coco.py DELETED
@@ -1,204 +0,0 @@
1
- _base_ = [
2
- '../_base_/datasets/coco_detection.py',
3
- '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
4
- ]
5
- load_from = 'https://download.openmmlab.com/mmdetection/v3.0/grounding_dino/groundingdino_swint_ogc_mmdet-822d7e9d.pth' # noqa
6
- lang_model_name = 'bert-base-uncased'
7
-
8
- model = dict(
9
- type='GroundingDINO',
10
- num_queries=900,
11
- with_box_refine=True,
12
- as_two_stage=True,
13
- data_preprocessor=dict(
14
- type='DetDataPreprocessor',
15
- mean=[123.675, 116.28, 103.53],
16
- std=[58.395, 57.12, 57.375],
17
- bgr_to_rgb=True,
18
- pad_mask=False,
19
- ),
20
- language_model=dict(
21
- type='BertModel',
22
- name=lang_model_name,
23
- pad_to_max=False,
24
- use_sub_sentence_represent=True,
25
- special_tokens_list=['[CLS]', '[SEP]', '.', '?'],
26
- add_pooling_layer=False,
27
- ),
28
- backbone=dict(
29
- type='SwinTransformer',
30
- embed_dims=96,
31
- depths=[2, 2, 6, 2],
32
- num_heads=[3, 6, 12, 24],
33
- window_size=7,
34
- mlp_ratio=4,
35
- qkv_bias=True,
36
- qk_scale=None,
37
- drop_rate=0.,
38
- attn_drop_rate=0.,
39
- drop_path_rate=0.2,
40
- patch_norm=True,
41
- out_indices=(1, 2, 3),
42
- with_cp=True,
43
- convert_weights=False),
44
- neck=dict(
45
- type='ChannelMapper',
46
- in_channels=[192, 384, 768],
47
- kernel_size=1,
48
- out_channels=256,
49
- act_cfg=None,
50
- bias=True,
51
- norm_cfg=dict(type='GN', num_groups=32),
52
- num_outs=4),
53
- encoder=dict(
54
- num_layers=6,
55
- num_cp=6,
56
- # visual layer config
57
- layer_cfg=dict(
58
- self_attn_cfg=dict(embed_dims=256, num_levels=4, dropout=0.0),
59
- ffn_cfg=dict(
60
- embed_dims=256, feedforward_channels=2048, ffn_drop=0.0)),
61
- # text layer config
62
- text_layer_cfg=dict(
63
- self_attn_cfg=dict(num_heads=4, embed_dims=256, dropout=0.0),
64
- ffn_cfg=dict(
65
- embed_dims=256, feedforward_channels=1024, ffn_drop=0.0)),
66
- # fusion layer config
67
- fusion_layer_cfg=dict(
68
- v_dim=256,
69
- l_dim=256,
70
- embed_dim=1024,
71
- num_heads=4,
72
- init_values=1e-4),
73
- ),
74
- decoder=dict(
75
- num_layers=6,
76
- return_intermediate=True,
77
- layer_cfg=dict(
78
- # query self attention layer
79
- self_attn_cfg=dict(embed_dims=256, num_heads=8, dropout=0.0),
80
- # cross attention layer query to text
81
- cross_attn_text_cfg=dict(embed_dims=256, num_heads=8, dropout=0.0),
82
- # cross attention layer query to image
83
- cross_attn_cfg=dict(embed_dims=256, num_heads=8, dropout=0.0),
84
- ffn_cfg=dict(
85
- embed_dims=256, feedforward_channels=2048, ffn_drop=0.0)),
86
- post_norm_cfg=None),
87
- positional_encoding=dict(
88
- num_feats=128, normalize=True, offset=0.0, temperature=20),
89
- bbox_head=dict(
90
- type='GroundingDINOHead',
91
- num_classes=80,
92
- sync_cls_avg_factor=True,
93
- contrastive_cfg=dict(max_text_len=256, log_scale=0.0, bias=False),
94
- loss_cls=dict(
95
- type='FocalLoss',
96
- use_sigmoid=True,
97
- gamma=2.0,
98
- alpha=0.25,
99
- loss_weight=1.0), # 2.0 in DeformDETR
100
- loss_bbox=dict(type='L1Loss', loss_weight=5.0),
101
- loss_iou=dict(type='GIoULoss', loss_weight=2.0)),
102
- dn_cfg=dict( # TODO: Move to model.train_cfg ?
103
- label_noise_scale=0.5,
104
- box_noise_scale=1.0, # 0.4 for DN-DETR
105
- group_cfg=dict(dynamic=True, num_groups=None,
106
- num_dn_queries=100)), # TODO: half num_dn_queries
107
- # training and testing settings
108
- train_cfg=dict(
109
- assigner=dict(
110
- type='HungarianAssigner',
111
- match_costs=[
112
- dict(type='BinaryFocalLossCost', weight=2.0),
113
- dict(type='BBoxL1Cost', weight=5.0, box_format='xywh'),
114
- dict(type='IoUCost', iou_mode='giou', weight=2.0)
115
- ])),
116
- test_cfg=dict(max_per_img=300))
117
-
118
- # dataset settings
119
- train_pipeline = [
120
- dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
121
- dict(type='LoadAnnotations', with_bbox=True),
122
- dict(type='RandomFlip', prob=0.5),
123
- dict(
124
- type='RandomChoice',
125
- transforms=[
126
- [
127
- dict(
128
- type='RandomChoiceResize',
129
- scales=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
130
- (608, 1333), (640, 1333), (672, 1333), (704, 1333),
131
- (736, 1333), (768, 1333), (800, 1333)],
132
- keep_ratio=True)
133
- ],
134
- [
135
- dict(
136
- type='RandomChoiceResize',
137
- # The radio of all image in train dataset < 7
138
- # follow the original implement
139
- scales=[(400, 4200), (500, 4200), (600, 4200)],
140
- keep_ratio=True),
141
- dict(
142
- type='RandomCrop',
143
- crop_type='absolute_range',
144
- crop_size=(384, 600),
145
- allow_negative_crop=True),
146
- dict(
147
- type='RandomChoiceResize',
148
- scales=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
149
- (608, 1333), (640, 1333), (672, 1333), (704, 1333),
150
- (736, 1333), (768, 1333), (800, 1333)],
151
- keep_ratio=True)
152
- ]
153
- ]),
154
- dict(
155
- type='PackDetInputs',
156
- meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
157
- 'scale_factor', 'flip', 'flip_direction', 'text',
158
- 'custom_entities'))
159
- ]
160
-
161
- test_pipeline = [
162
- dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
163
- dict(type='FixScaleResize', scale=(800, 1333), keep_ratio=True),
164
- dict(type='LoadAnnotations', with_bbox=True),
165
- dict(
166
- type='PackDetInputs',
167
- meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
168
- 'scale_factor', 'text', 'custom_entities'))
169
- ]
170
-
171
- train_dataloader = dict(
172
- dataset=dict(
173
- filter_cfg=dict(filter_empty_gt=False),
174
- pipeline=train_pipeline,
175
- return_classes=True))
176
- val_dataloader = dict(
177
- dataset=dict(pipeline=test_pipeline, return_classes=True))
178
- test_dataloader = val_dataloader
179
-
180
- optim_wrapper = dict(
181
- _delete_=True,
182
- type='OptimWrapper',
183
- optimizer=dict(type='AdamW', lr=0.0001, weight_decay=0.0001),
184
- clip_grad=dict(max_norm=0.1, norm_type=2),
185
- paramwise_cfg=dict(custom_keys={
186
- 'absolute_pos_embed': dict(decay_mult=0.),
187
- 'backbone': dict(lr_mult=0.1)
188
- }))
189
- # learning policy
190
- max_epochs = 12
191
- param_scheduler = [
192
- dict(
193
- type='MultiStepLR',
194
- begin=0,
195
- end=max_epochs,
196
- by_epoch=True,
197
- milestones=[11],
198
- gamma=0.1)
199
- ]
200
-
201
- # NOTE: `auto_scale_lr` is for automatically scaling LR,
202
- # USER SHOULD NOT CHANGE ITS VALUES.
203
- # base_batch_size = (16 GPUs) x (2 samples per GPU)
204
- auto_scale_lr = dict(base_batch_size=32)