forked from open-mmlab/mmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glean_x16_2xb8_cat.py
117 lines (110 loc) · 3.21 KB
/
glean_x16_2xb8_cat.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
_base_ = '../_base_/models/base_glean.py'
experiment_name = 'glean_x16_2xb8_cat'
work_dir = f'./work_dirs/{experiment_name}'
save_dir = './work_dirs'
scale = 16
# model settings
model = dict(
type='SRGAN',
generator=dict(
type='GLEANStyleGANv2',
in_size=16,
out_size=256,
style_channels=512,
init_cfg=dict(
type='Pretrained',
checkpoint='http://download.openmmlab.com/mmediting/stylegan2/'
'official_weights/stylegan2-cat-config-f-official_20210327'
'_172444-15bc485b.pth',
prefix='generator_ema')),
discriminator=dict(
type='StyleGANv2Discriminator',
in_size=256,
init_cfg=dict(
type='Pretrained',
checkpoint='http://download.openmmlab.com/mmediting/stylegan2/'
'official_weights/stylegan2-cat-config-f-official_20210327'
'_172444-15bc485b.pth',
prefix='discriminator')),
pixel_loss=dict(type='MSELoss', loss_weight=1.0, reduction='mean'),
perceptual_loss=dict(
type='PerceptualLoss',
layer_weights={'21': 1.0},
vgg_type='vgg16',
perceptual_weight=1e-2,
style_weight=0,
norm_img=False,
criterion='mse',
pretrained='torchvision://vgg16'),
gan_loss=dict(
type='GANLoss',
gan_type='vanilla',
loss_weight=1e-2,
real_label_val=1.0,
fake_label_val=0),
train_cfg=dict(),
test_cfg=dict(),
data_preprocessor=dict(
type='EditDataPreprocessor',
mean=[127.5, 127.5, 127.5],
std=[127.5, 127.5, 127.5],
),
)
train_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb'),
dict(
type='Flip',
keys=['img', 'gt'],
flip_ratio=0.5,
direction='horizontal'),
dict(type='PackEditInputs')
]
test_pipeline = [
dict(
type='LoadImageFromFile',
key='img',
color_type='color',
channel_order='rgb'),
dict(
type='LoadImageFromFile',
key='gt',
color_type='color',
channel_order='rgb'),
dict(type='PackEditInputs')
]
# dataset settings
dataset_type = 'BasicImageDataset'
train_dataloader = dict(
num_workers=8,
batch_size=8,
persistent_workers=False,
sampler=dict(type='InfiniteSampler', shuffle=True),
dataset=dict(
type=dataset_type,
metainfo=dict(dataset_type='cat', task_name='sisr'),
data_root='data/cat_train',
data_prefix=dict(img='BIx16_down', gt='GT'),
ann_file='meta_info_LSUNcat_GT.txt',
pipeline=train_pipeline))
val_dataloader = dict(
num_workers=8,
persistent_workers=False,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
metainfo=dict(dataset_type='cat', task_name='sisr'),
data_root='data/cat_test',
data_prefix=dict(img='BIx16_down', gt='GT'),
ann_file='meta_info_Cat100_GT.txt',
pipeline=test_pipeline))
test_dataloader = val_dataloader