-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain-dcgan.py
66 lines (48 loc) · 2.22 KB
/
train-dcgan.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
#!/usr/bin/env python3
# Original Version: Taehoon Kim (http://carpedm20.github.io)
# + Source: https://github.com/carpedm20/DCGAN-tensorflow/blob/e30539fb5e20d5a0fed40935853da97e9e55eee8/main.py
# + License: MIT
# [2016-08-05] Modifications for Inpainting: Brandon Amos (http://bamos.github.io)
# + License: MIT
import os
import scipy.misc
import numpy as np
from model import DCGAN
from my_model import myDCGAN
from my_model_2 import myDCGAN_2
from my_model_3 import myDCGAN_3
from my_model_4 import myDCGAN_4
from my_model_5 import myDCGAN_5
from my_model_6 import myDCGAN_6
from my_model_5_1_save import myDCGAN_5_1_save
from my_model_7 import myDCGAN_7
from my_model_8 import myDCGAN_8
from my_model_9 import myDCGAN_9
from my_model_10 import myDCGAN_10
from utils import pp, visualize, to_json
import tensorflow as tf
flags = tf.app.flags
flags.DEFINE_integer("epoch", 50, "Epoch to train [25]")
flags.DEFINE_integer("save_iter", 100, "The number of iter of image to save")
flags.DEFINE_float("learning_rate", 0.0002, "Learning rate of for adam [0.0002]")
flags.DEFINE_float("beta1", 0.5, "Momentum term of adam [0.5]")
flags.DEFINE_float("train_size", np.inf, "The size of train images [np.inf]")
flags.DEFINE_integer("batch_size", 64, "The size of batch images [64]")
flags.DEFINE_integer("image_size", 64, "The size of image to use")
flags.DEFINE_string("maskType", "center","default")
flags.DEFINE_float("centerScale", 0.3, "The size of mask to use")
#数据集路径
flags.DEFINE_string("dataset", "F:\Python_Project\Dataset\celeba64sizes-20k", "Dataset directory.")
flags.DEFINE_string("checkpoint_dir", "checkpoint", "Directory name to save the checkpoints [checkpoint]")
flags.DEFINE_string("sample_dir", "samples", "Directory name to save the image samples [samples]")
FLAGS = flags.FLAGS
if not os.path.exists(FLAGS.checkpoint_dir):
os.makedirs(FLAGS.checkpoint_dir)
if not os.path.exists(FLAGS.sample_dir):
os.makedirs(FLAGS.sample_dir)
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
dcgan = myDCGAN_10(sess, image_size=FLAGS.image_size, batch_size=FLAGS.batch_size,
is_crop=False, checkpoint_dir=FLAGS.checkpoint_dir)
dcgan.train(FLAGS)