forked from open-mmlab/mmpretrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resnet50-arcface_8xb32_inshop.py
71 lines (64 loc) · 1.81 KB
/
resnet50-arcface_8xb32_inshop.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
_base_ = [
'../_base_/datasets/inshop_bs32_448.py',
'../_base_/schedules/cub_bs64.py',
'../_base_/default_runtime.py',
]
pretrained = 'https://download.openmmlab.com/mmclassification/v0/resnet/resnet50_3rdparty-mill_in21k_20220331-faac000b.pth' # noqa
model = dict(
type='ImageToImageRetriever',
image_encoder=[
dict(
type='ResNet',
depth=50,
init_cfg=dict(
type='Pretrained', checkpoint=pretrained, prefix='backbone')),
dict(type='GlobalAveragePooling'),
],
head=dict(
type='ArcFaceClsHead',
num_classes=3997,
in_channels=2048,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
init_cfg=None),
prototype={{_base_.gallery_dataloader}})
# runtime settings
default_hooks = dict(
# log every 20 intervals
logger=dict(type='LoggerHook', interval=20),
# save last three checkpoints
checkpoint=dict(
type='CheckpointHook',
save_best='auto',
interval=1,
max_keep_ckpts=3,
rule='greater'))
# optimizer
optim_wrapper = dict(
optimizer=dict(
type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0005, nesterov=True))
# learning policy
param_scheduler = [
# warm up learning rate scheduler
dict(
type='LinearLR',
start_factor=0.01,
by_epoch=True,
begin=0,
end=5,
# update by iter
convert_to_iter_based=True),
# main learning rate scheduler
dict(
type='CosineAnnealingLR',
T_max=45,
by_epoch=True,
begin=5,
end=50,
)
]
train_cfg = dict(by_epoch=True, max_epochs=50, val_interval=1)
auto_scale_lr = dict(enable=True, base_batch_size=256)
custom_hooks = [
dict(type='PrepareProtoBeforeValLoopHook'),
dict(type='SyncBuffersHook')
]