forked from open-mmlab/mmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrgan_x4c64b16_1xb16-1000k_div2k.py
67 lines (59 loc) · 1.85 KB
/
srgan_x4c64b16_1xb16-1000k_div2k.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
_base_ = './msrresnet_x4c64b16_1xb16-1000k_div2k.py'
experiment_name = 'srgan_x4c64b16_1xb16-1000k_div2k'
work_dir = f'./work_dirs/{experiment_name}'
scale = 4
# load_from = 'https://download.openmmlab.com/mmediting/restorers/srresnet_srgan/msrresnet_x4c64b16_1x16_300k_div2k_20200521-61556be5.pth' # noqa
# DistributedDataParallel
model_wrapper_cfg = dict(type='MMSeparateDistributedDataParallel')
# model settings
model = dict(
type='SRGAN',
generator=dict(
type='MSRResNet',
in_channels=3,
out_channels=3,
mid_channels=64,
num_blocks=16,
upscale_factor=scale),
discriminator=dict(type='ModifiedVGG', in_channels=3, mid_channels=64),
pixel_loss=dict(type='L1Loss', loss_weight=1e-2, reduction='mean'),
perceptual_loss=dict(
type='PerceptualLoss',
layer_weights={'34': 1.0},
vgg_type='vgg19',
perceptual_weight=1.0,
style_weight=0,
norm_img=False),
gan_loss=dict(
type='GANLoss',
gan_type='vanilla',
loss_weight=5e-3,
real_label_val=1.0,
fake_label_val=0),
train_cfg=dict(),
test_cfg=dict(),
data_preprocessor=dict(
type='DataPreprocessor',
mean=[0., 0., 0.],
std=[255., 255., 255.],
))
# optimizer
optim_wrapper = dict(
_delete_=True,
constructor='MultiOptimWrapperConstructor',
generator=dict(
type='OptimWrapper',
optimizer=dict(type='Adam', lr=1e-4, betas=(0.9, 0.999))),
discriminator=dict(
type='OptimWrapper',
optimizer=dict(type='Adam', lr=1e-4, betas=(0.9, 0.999))),
)
# learning policy
param_scheduler = dict(
_delete_=True,
type='MultiStepLR',
by_epoch=False,
milestones=[50000, 100000, 200000, 300000],
gamma=0.5)
train_cfg = dict(
type='IterBasedTrainLoop', max_iters=400_000, val_interval=5000)