-
Notifications
You must be signed in to change notification settings - Fork 2
/
point2rbox-yolof-hrsc.py
130 lines (122 loc) · 4.03 KB
/
point2rbox-yolof-hrsc.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
_base_ = [
'../_base_/datasets/hrsc.py', '../_base_/schedules/schedule_6x.py',
'../_base_/default_runtime.py'
]
model = dict(
type='Point2RBoxYOLOF',
crop_size=(800, 800),
prob_rot=0.95 * 0.7,
prob_flp=0.05 * 0.7,
sca_fact=1.0,
sca_range=(0.5, 1.5),
basic_pattern='data/basic_patterns/hrsc',
dense_cls=[],
use_setrc=True,
use_setsk=True,
data_preprocessor=dict(
type='mmdet.DetDataPreprocessor',
mean=[103.530, 116.280, 123.675],
std=[1.0, 1.0, 1.0],
bgr_to_rgb=False,
pad_size_divisor=32),
backbone=dict(
type='mmdet.ResNet',
depth=50,
num_stages=4,
strides=(1, 2, 2, 1), # DC5
dilations=(1, 1, 1, 2),
out_indices=(3, ),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
style='caffe',
init_cfg=dict(
type='Pretrained',
checkpoint='open-mmlab://detectron/resnet50_caffe')),
neck=dict(
type='mmdet.DilatedEncoder',
in_channels=2048,
out_channels=512,
block_mid_channels=128,
num_residual_blocks=4,
block_dilations=[2, 4, 6, 8]),
bbox_head=dict(
type='Point2RBoxYOLOFHead',
num_classes=1,
in_channels=512,
reg_decoded_bbox=True,
num_cls_convs=4,
num_reg_convs=8,
use_objectness=False,
agnostic_cls=[],
square_cls=[],
anchor_generator=dict(
type='mmdet.AnchorGenerator',
ratios=[1.0],
scales=[8],
strides=[16]),
bbox_coder=dict(
type='mmdet.DeltaXYWHBBoxCoder',
target_means=[.0, .0, .0, .0],
target_stds=[1., 1., 1., 1.],
add_ctr_clamp=True,
ctr_clamp=16),
loss_cls=dict(
type='mmdet.FocalLoss',
use_sigmoid=True,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_bbox=dict(type='mmdet.GIoULoss', loss_weight=1.0),
loss_angle=dict(type='mmdet.L1Loss', loss_weight=0.3),
loss_scale_ss=dict(type='mmdet.GIoULoss', loss_weight=0.02)),
# training and testing settings
train_cfg=dict(
assigner=dict(
type='Point2RBoxAssigner',
pos_ignore_thr=0.15,
neg_ignore_thr=0.7,
match_times=4),
allowed_border=-1,
pos_weight=-1,
debug=False),
test_cfg=dict(
nms_pre=2000,
min_bbox_size=0,
score_thr=0.05,
nms=dict(type='nms_rotated', iou_threshold=0.1),
max_per_img=2000))
# optimizer
optim_wrapper = dict(
optimizer=dict(
_delete_=True,
type='AdamW',
lr=0.00005,
betas=(0.9, 0.999),
weight_decay=0.05),
paramwise_cfg=dict(
norm_decay_mult=0., custom_keys={'backbone': dict(lr_mult=1. / 3)}))
train_pipeline = [
dict(type='mmdet.LoadImageFromFile', backend_args={{_base_.backend_args}}),
dict(type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'),
dict(type='mmdet.FixShapeResize', width=800, height=800, keep_ratio=True),
dict(type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')),
dict(type='RBox2Point'),
dict(
type='mmdet.RandomFlip',
prob=0.75,
direction=['horizontal', 'vertical', 'diagonal']),
dict(type='RandomRotate', prob=1, angle_range=180),
dict(type='mmdet.RandomShift', prob=0.5, max_shift_px=16),
dict(type='mmdet.PackDetInputs')
]
train_cfg = dict(type='EpochBasedTrainLoop', val_interval=12)
train_dataloader = dict(
batch_size=4, num_workers=4, dataset=dict(pipeline=train_pipeline))
val_dataloader = dict(batch_size=4, num_workers=4)
val_evaluator = dict(type='DOTAMetric', metric='mAP', iou_thrs=[0.25, 0.5])
# default_hooks = dict(logger=dict(type='LoggerHook', interval=30))
# NOTE: `auto_scale_lr` is for automatically scaling LR,
# USER SHOULD NOT CHANGE ITS VALUES.
# base_batch_size = (8 GPUs) x (8 samples per GPU)
auto_scale_lr = dict(base_batch_size=64)