Skip to content

Commit

Permalink
revise dcgan's config
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoXing1996 committed Dec 13, 2022
1 parent 936cbac commit 56154e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
2 changes: 2 additions & 0 deletions configs/dcgan/dcgan_1xb128-300kiters_celeba-cropped-64.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
sample_model='orig',
image_shape=(3, 64, 64))
]
# save best checkpoints
default_hooks = dict(checkpoint=dict(save_best='swd/avg', rule='less'))

val_evaluator = dict(metrics=metrics)
test_evaluator = dict(metrics=metrics)
2 changes: 2 additions & 0 deletions configs/dcgan/dcgan_1xb128-5epoches_lsun-bedroom-64x64.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
sample_model='orig',
image_shape=(3, 64, 64))
]
# save best checkpoints
default_hooks = dict(checkpoint=dict(save_best='swd/avg', rule='less'))

val_evaluator = dict(metrics=metrics)
test_evaluator = dict(metrics=metrics)
40 changes: 20 additions & 20 deletions configs/dcgan/dcgan_Glr4e-4_Dlr1e-4_1xb128-5kiters_mnist-64x64.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,44 @@
]

# output single channel
model = dict(generator=dict(out_channels=1), discriminator=dict(in_channels=1))
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='img',
io_backend='disk',
color_type='grayscale'),
dict(type='LoadImageFromFile', key='img', color_type='grayscale'),
dict(type='Resize', scale=(64, 64)),
dict(type='PackEditInputs', meta_keys=[])
dict(type='PackEditInputs')
]

# 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))
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))
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))

default_hooks = dict(
checkpoint=dict(
interval=500,
save_best=['swd/avg', 'ms-ssim/avg'],
rule=['less', 'greater']))
batch_size=batch_size,
dataset=dict(data_root=data_root, pipeline=train_pipeline))

# VIS_HOOK
custom_hooks = [
dict(
type='GenVisualizationHook',
interval=10000,
interval=500,
fixed_input=True,
vis_kwargs_list=dict(type='GAN', name='fake_img'))
]

train_cfg = dict(max_iters=5000)
train_cfg = dict(max_iters=5000, val_interval=500)

# METRICS
metrics = [
Expand All @@ -55,10 +52,13 @@
dict(
type='SWD',
prefix='swd',
fake_nums=16384,
fake_nums=-1,
sample_model='orig',
image_shape=(3, 64, 64))
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)
Expand Down

0 comments on commit 56154e2

Please sign in to comment.