forked from open-mmlab/mmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcgan_Glr4e-4_Dlr1e-4_1xb128-5kiters_mnist-64x64.py
69 lines (59 loc) · 1.84 KB
/
dcgan_Glr4e-4_Dlr1e-4_1xb128-5kiters_mnist-64x64.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
_base_ = [
'../_base_/models/dcgan/base_dcgan_64x64.py',
'../_base_/datasets/unconditional_imgs_64x64.py',
'../_base_/gen_default_runtime.py'
]
# output single channel
model = dict(
data_preprocessor=dict(mean=[127.5], std=[127.5]),
generator=dict(out_channels=1),
discriminator=dict(in_channels=1))
# define dataset
# modify train_pipeline to load gray scale images
train_pipeline = [
dict(type='LoadImageFromFile', key='gt', color_type='grayscale'),
dict(type='Resize', keys='gt', scale=(64, 64)),
dict(type='PackInputs')
]
# set ``batch_size``` and ``data_root```
batch_size = 128
data_root = 'data/mnist_64/train'
train_dataloader = dict(
batch_size=batch_size,
dataset=dict(data_root=data_root, pipeline=train_pipeline))
val_dataloader = dict(
batch_size=batch_size,
dataset=dict(data_root=data_root, pipeline=train_pipeline))
test_dataloader = dict(
batch_size=batch_size,
dataset=dict(data_root=data_root, pipeline=train_pipeline))
# VIS_HOOK
custom_hooks = [
dict(
type='VisualizationHook',
interval=500,
fixed_input=True,
vis_kwargs_list=dict(type='GAN', name='fake_img'))
]
train_cfg = dict(max_iters=5000, val_interval=500)
# METRICS
metrics = [
dict(
type='MS_SSIM', prefix='ms-ssim', fake_nums=10000,
sample_model='orig'),
dict(
type='SWD',
prefix='swd',
fake_nums=-1,
sample_model='orig',
image_shape=(1, 64, 64))
]
# save best checkpoints
default_hooks = dict(
checkpoint=dict(interval=500, save_best='swd/avg', rule='less'))
val_evaluator = dict(metrics=metrics)
test_evaluator = dict(metrics=metrics)
optim_wrapper = dict(
generator=dict(optimizer=dict(type='Adam', lr=0.0004, betas=(0.5, 0.999))),
discriminator=dict(
optimizer=dict(type='Adam', lr=0.0001, betas=(0.5, 0.999))))