forked from open-mmlab/mmsegmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
san-vit-b16_coco-stuff164k-640x640.py
82 lines (76 loc) · 2.46 KB
/
san-vit-b16_coco-stuff164k-640x640.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
_base_ = [
'../_base_/models/san_vit-b16.py', '../_base_/datasets/coco-stuff164k.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]
crop_size = (640, 640)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(
type='RandomChoiceResize',
scales=[int(640 * x * 0.1) for x in range(5, 16)],
resize_type='ResizeShortestEdge',
max_size=2560),
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=1.0),
dict(type='PhotoMetricDistortion'),
dict(type='RandomFlip', prob=0.5),
dict(type='PackSegInputs')
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='ResizeShortestEdge', scale=crop_size, max_size=2560),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs')
]
# By default, models are trained on 4 GPUs with 8 images per GPU
train_dataloader = dict(batch_size=8, dataset=dict(pipeline=train_pipeline))
val_dataloader = dict(batch_size=1, dataset=dict(pipeline=test_pipeline))
test_dataloader = val_dataloader
pretrained = 'https://download.openmmlab.com/mmsegmentation/v0.5/san/clip_vit-base-patch16-224_3rdparty-d08f8887.pth' # noqa
data_preprocessor = dict(
mean=[122.7709, 116.7460, 104.0937],
std=[68.5005, 66.6322, 70.3232],
size_divisor=640,
test_cfg=dict(size_divisor=32))
model = dict(
pretrained=pretrained,
text_encoder=dict(dataset_name='coco-stuff164k'),
decode_head=dict(num_classes=171))
# training schedule for 60k
train_cfg = dict(
type='IterBasedTrainLoop',
max_iters=60000,
val_interval=500,
val_begin=55000)
default_hooks = dict(
checkpoint=dict(
type='CheckpointHook',
by_epoch=False,
interval=10000,
save_best='mIoU'))
# AdamW optimizer, no weight decay for position embedding & layer norm
# in backbone
optim_wrapper = dict(
_delete_=True,
type='AmpOptimWrapper',
optimizer=dict(
type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.0001),
paramwise_cfg=dict(
custom_keys={
'img_encoder': dict(lr_mult=0.1, decay_mult=1.0),
'pos_embed': dict(decay_mult=0.),
'cls_token': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)
}),
loss_scale='dynamic',
clip_grad=dict(max_norm=0.01, norm_type=2))
param_scheduler = [
dict(
type='PolyLR',
eta_min=0.0,
power=1.0,
begin=0,
end=60000,
by_epoch=False,
)
]