Skip to content

Commit

Permalink
Refactor GFL & LD & LAD model
Browse files Browse the repository at this point in the history
  • Loading branch information
zytx121 authored and ZwwWayne committed Jul 19, 2022
1 parent 9731c4f commit 1f35b0f
Show file tree
Hide file tree
Showing 18 changed files with 753 additions and 439 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@

# dataset settings
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomChoiceResize',
scale=[(1333, 640), (1333, 800)],
resize_cfg=dict(type='Resize', keep_ratio=True)),
keep_ratio=True),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))

# training schedule for 2x
train_cfg = dict(max_epochs=24)
max_epochs = 24
train_cfg = dict(max_epochs=max_epochs)

# learning rate
param_scheduler = [
dict(type='ConstantLR', factor=1.0 / 3, by_epoch=False, begin=0, end=500),
dict(
type='MultiStepLR',
begin=0,
end=24,
end=max_epochs,
by_epoch=True,
milestones=[16, 22],
gamma=0.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@

# dataset settings
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomChoiceResize',
scale=[(1333, 640), (1333, 800)],
resize_cfg=dict(type='Resize', keep_ratio=True)),
keep_ratio=True),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))

# training schedule for 2x
train_cfg = dict(max_epochs=24)
max_epochs = 24
train_cfg = dict(max_epochs=max_epochs)

# learning rate
param_scheduler = [
dict(type='ConstantLR', factor=1.0 / 3, by_epoch=False, begin=0, end=500),
dict(
type='MultiStepLR',
begin=0,
end=24,
end=max_epochs,
by_epoch=True,
milestones=[16, 22],
gamma=0.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@

# dataset settings
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomChoiceResize',
scale=[(1333, 640), (1333, 800)],
resize_cfg=dict(type='Resize', keep_ratio=True)),
keep_ratio=True),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))

# training schedule for 2x
train_cfg = dict(max_epochs=24)
max_epochs = 24
train_cfg = dict(max_epochs=max_epochs)

# learning rate
param_scheduler = [
dict(type='ConstantLR', factor=1.0 / 3, by_epoch=False, begin=0, end=500),
dict(
type='MultiStepLR',
begin=0,
end=24,
end=max_epochs,
by_epoch=True,
milestones=[16, 22],
gamma=0.1)
Expand Down
11 changes: 10 additions & 1 deletion configs/gfl/gfl_r50_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
]
model = dict(
type='GFL',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
bgr_to_rgb=True,
pad_size_divisor=32),
backbone=dict(
type='ResNet',
depth=50,
Expand Down Expand Up @@ -53,5 +59,8 @@
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.6),
max_per_img=100))

# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001))
36 changes: 22 additions & 14 deletions configs/gfl/gfl_r50_fpn_mstrain_2x_coco.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
_base_ = './gfl_r50_fpn_1x_coco.py'
max_epochs = 24

# learning policy
lr_config = dict(step=[16, 22])
runner = dict(type='EpochBasedRunner', max_epochs=24)
param_scheduler = [
dict(
type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500),
dict(
type='MultiStepLR',
begin=0,
end=max_epochs,
by_epoch=True,
milestones=[16, 22],
gamma=0.1)
]
train_cfg = dict(max_epochs=max_epochs)

# multi-scale training
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Resize',
img_scale=[(1333, 480), (1333, 800)],
multiscale_mode='range',
type='RandomResize', scale=[(1333, 480), (1333, 800)],
keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
data = dict(train=dict(pipeline=train_pipeline))
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
35 changes: 21 additions & 14 deletions configs/ld/ld_r101_gflv1_r101dcn_fpn_coco_2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@
add_extra_convs='on_output',
num_outs=5))

lr_config = dict(step=[16, 22])
runner = dict(type='EpochBasedRunner', max_epochs=24)
max_epochs = 24
param_scheduler = [
dict(
type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500),
dict(
type='MultiStepLR',
begin=0,
end=max_epochs,
by_epoch=True,
milestones=[16, 22],
gamma=0.1)
]
train_cfg = dict(max_epochs=max_epochs)

# multi-scale training
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Resize',
img_scale=[(1333, 480), (1333, 800)],
multiscale_mode='range',
type='RandomResize', scale=[(1333, 480), (1333, 800)],
keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
data = dict(train=dict(pipeline=train_pipeline))
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
10 changes: 9 additions & 1 deletion configs/ld/ld_r18_gflv1_r101_fpn_coco_1x.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
teacher_ckpt = 'https://download.openmmlab.com/mmdetection/v2.0/gfl/gfl_r101_fpn_mstrain_2x_coco/gfl_r101_fpn_mstrain_2x_coco_20200629_200126-dd12f847.pth' # noqa
model = dict(
type='KnowledgeDistillationSingleStageDetector',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
bgr_to_rgb=True,
pad_size_divisor=32),
teacher_config='configs/gfl/gfl_r101_fpn_mstrain_2x_coco.py',
teacher_ckpt=teacher_ckpt,
backbone=dict(
Expand Down Expand Up @@ -59,4 +65,6 @@
nms=dict(type='nms', iou_threshold=0.6),
max_per_img=100))

optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001))
9 changes: 5 additions & 4 deletions configs/paa/paa_r50_fpn_mstrain_3x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
train_cfg = dict(max_epochs=max_epochs)

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomResize',
scale=[(1333, 640), (1333, 800)],
resize_cfg=dict(type='Resize', keep_ratio=True)),
type='RandomResize', scale=[(1333, 640), (1333, 800)],
keep_ratio=True),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
Expand Down
9 changes: 5 additions & 4 deletions configs/tood/tood_r50_fpn_mstrain_2x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

# multi-scale training
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomResize',
scale=[(1333, 480), (1333, 800)],
resize_cfg=dict(type='Resize', keep_ratio=True)),
type='RandomResize', scale=[(1333, 480), (1333, 800)],
keep_ratio=True),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
Expand Down
Loading

0 comments on commit 1f35b0f

Please sign in to comment.