Tensorflow implementation of Least Squares Generative Adversarial Networks by Mao et al (LSGAN).
- Python 2.7+
- NumPy
- SciPy
- tqdm
- Tensorflow r1.0+
- lmdb (for processing LSUN dataset only)
-
Clone this repo, create
ckpt/
folder:git clone https://github.com/markdtw/least-squares-gan.git cd least-squares-gan mkdir ckpt
-
To train on LSUN, use the provided tools to download and extract. For example:
python download.py -c conference_room unzip conference_room_train_lmdb.zip python data.py export conference_room_train_lmdb --out_dir conference_room_train_images --flat
I replaced .webp from this line to .jpg
-
To train on CelebA, I use this file to download. Shout out to carpedm20.
-
Now you are good to go, first time training on LSUN will center-crop all the images to 224x224 and store them in a new folder.
Train on LSUN conference room with default settings:
python main.py --train
Train on CelebA with default settings:
python main.py --train --dataset=CelebA
Train from a previous checkpoint at epoch X:
python main.py --train --modelpath=ckpt/lsgan-LSUN<CelebA>-X
Check out tunable hyper-parameters:
python main.py
Results from epoch 45 is already nice and crispy.
- The model will save 40 generated pictures in
log/
folder every epoch. - Initialization is important! Default initialization with
tf.xavier_initializer
will lead to either D or G's gradient vanishing problem, instead I usetf.truncated_normal_initializer
which is identical to DCGAN original implementation to solve the problem. - Issues are more than welcome!