forked from open-mmlab/mmdetection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fcos_r50_fpn_8x4_sample1e-3_mstrain_v3det_2x.py
116 lines (108 loc) · 3.27 KB
/
fcos_r50_fpn_8x4_sample1e-3_mstrain_v3det_2x.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
_base_ = [
'../_base_/datasets/v3det.py', '../_base_/schedules/schedule_2x.py',
'../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FCOS',
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,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50')),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
start_level=1,
add_extra_convs='on_output', # use P5
num_outs=5,
relu_before_extra_convs=True),
bbox_head=dict(
type='FCOSHead',
num_classes=13204,
in_channels=256,
stacked_convs=4,
feat_channels=256,
strides=[8, 16, 32, 64, 128],
cls_predictor_cfg=dict(type='NormedLinear', tempearture=50, bias=True),
loss_cls=dict(
type='FocalCustomLoss',
use_sigmoid=True,
num_classes=13204,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_bbox=dict(type='IoULoss', loss_weight=1.0),
loss_centerness=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0)),
# model training and testing settings
train_cfg=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.4,
min_pos_iou=0,
ignore_iof_thr=-1,
perm_repeat_gt_cfg=dict(iou_thr=0.7, perm_range=0.01)),
allowed_border=-1,
pos_weight=-1,
debug=False),
test_cfg=dict(
nms_pre=1000,
min_bbox_size=0,
score_thr=0.0001,
nms=dict(type='nms', iou_threshold=0.6),
max_per_img=300))
# dataset settings
backend_args = None
train_dataloader = dict(batch_size=2, num_workers=8)
# training schedule for 2x
max_iter = 68760 * 2 * 2
train_cfg = dict(
_delete_=True,
type='IterBasedTrainLoop',
max_iters=max_iter,
val_interval=max_iter)
# learning rate
param_scheduler = [
dict(
type='LinearLR',
start_factor=1.0 / 2048,
by_epoch=False,
begin=0,
end=5000 * 2),
dict(
type='MultiStepLR',
begin=0,
end=max_iter,
by_epoch=False,
milestones=[45840 * 2 * 2, 63030 * 2 * 2],
gamma=0.1)
]
# optimizer
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(
_delete_=True, type='AdamW', lr=1e-4 * 0.25, weight_decay=0.1),
clip_grad=dict(max_norm=35, norm_type=2))
# Default setting for scaling LR automatically
# - `enable` means enable scaling LR automatically
# or not by default.
# - `base_batch_size` = (8 GPUs) x (2 samples per GPU).
auto_scale_lr = dict(enable=False, base_batch_size=32)
default_hooks = dict(
checkpoint=dict(type='CheckpointHook', by_epoch=False, interval=5730 * 2))
log_processor = dict(type='LogProcessor', window_size=50, by_epoch=False)
find_unused_parameters = True