-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
basicvsr_2xb4_reds4.py
119 lines (104 loc) · 3.48 KB
/
basicvsr_2xb4_reds4.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
_base_ = [
'../_base_/default_runtime.py',
'../_base_/datasets/basicvsr_test_config.py'
]
experiment_name = 'basicvsr_2xb4_reds4'
work_dir = f'./work_dirs/{experiment_name}'
save_dir = './work_dirs'
scale = 4
# model settings
model = dict(
type='BasicVSR',
generator=dict(
type='BasicVSRNet',
mid_channels=64,
num_blocks=30,
spynet_pretrained='https://download.openmmlab.com/mmediting/restorers/'
'basicvsr/spynet_20210409-c6c1bd09.pth'),
pixel_loss=dict(type='CharbonnierLoss', loss_weight=1.0, reduction='mean'),
train_cfg=dict(fix_iter=5000),
data_preprocessor=dict(
type='DataPreprocessor',
mean=[0., 0., 0.],
std=[255., 255., 255.],
))
train_pipeline = [
dict(type='GenerateSegmentIndices', interval_list=[1]),
dict(type='LoadImageFromFile', key='img', channel_order='rgb'),
dict(type='LoadImageFromFile', key='gt', channel_order='rgb'),
dict(type='SetValues', dictionary=dict(scale=scale)),
dict(type='PairedRandomCrop', gt_patch_size=256),
dict(
type='Flip',
keys=['img', 'gt'],
flip_ratio=0.5,
direction='horizontal'),
dict(
type='Flip', keys=['img', 'gt'], flip_ratio=0.5, direction='vertical'),
dict(type='RandomTransposeHW', keys=['img', 'gt'], transpose_ratio=0.5),
dict(type='PackInputs')
]
val_pipeline = [
dict(type='GenerateSegmentIndices', interval_list=[1]),
dict(type='LoadImageFromFile', key='img', channel_order='rgb'),
dict(type='LoadImageFromFile', key='gt', channel_order='rgb'),
dict(type='PackInputs')
]
demo_pipeline = [
dict(type='GenerateSegmentIndices', interval_list=[1]),
dict(type='LoadImageFromFile', key='img', channel_order='rgb'),
dict(type='PackInputs')
]
data_root = 'data/REDS'
train_dataloader = dict(
num_workers=6,
batch_size=4,
persistent_workers=False,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type='BasicFramesDataset',
metainfo=dict(dataset_type='reds_reds4', task_name='vsr'),
data_root=data_root,
data_prefix=dict(img='train_sharp_bicubic/X4', gt='train_sharp'),
ann_file='meta_info_reds4_train.txt',
depth=1,
num_input_frames=15,
pipeline=train_pipeline))
val_dataloader = dict(
num_workers=1,
batch_size=1,
persistent_workers=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='BasicFramesDataset',
metainfo=dict(dataset_type='reds_reds4', task_name='vsr'),
data_root=data_root,
data_prefix=dict(img='train_sharp_bicubic/X4', gt='train_sharp'),
ann_file='meta_info_reds4_val.txt',
depth=1,
num_input_frames=100,
fixed_seq_len=100,
pipeline=val_pipeline))
val_evaluator = dict(
type='Evaluator', metrics=[
dict(type='PSNR'),
dict(type='SSIM'),
])
train_cfg = dict(
type='IterBasedTrainLoop', max_iters=300_000, val_interval=5000)
val_cfg = dict(type='MultiValLoop')
# optimizer
optim_wrapper = dict(
constructor='DefaultOptimWrapperConstructor',
type='OptimWrapper',
optimizer=dict(type='Adam', lr=2e-4, betas=(0.9, 0.99)),
paramwise_cfg=dict(custom_keys={'spynet': dict(lr_mult=0.125)}))
default_hooks = dict(checkpoint=dict(out_dir=save_dir))
# learning policy
param_scheduler = dict(
type='CosineRestartLR',
by_epoch=False,
periods=[300000],
restart_weights=[1],
eta_min=1e-7)
find_unused_parameters = True