Recommendation
- Our GAN based work for facial attribute editing - AttGAN.
New
- 8 April 2019: We re-implement these GANs by Tensorflow 2! The old version is here: v1 or in the "v1" directory.
- PyTorch Version
Tensorflow 2 implementations of DCGAN, LSGAN, WGAN-GP and DRAGAN.
DCGAN | LSGAN | WGAN-GP | DRAGAN |
---|---|---|---|
DCGAN | LSGAN |
---|---|
WGAN-GP | DRAGAN |
WGAN-GP | DRAGAN |
---|---|
-
Environment
-
Python 3.6
-
TensorFlow 2.2, TensorFlow Addons 0.10.0
-
OpenCV, scikit-image, tqdm, oyaml
-
we recommend Anaconda or Miniconda, then you can create the TensorFlow 2.2 environment with commands below
conda create -n tensorflow-2.2 python=3.6 source activate tensorflow-2.2 conda install -c anaconda scikit-image conda install -c anaconda tqdm conda install -c conda-forge oyaml conda install -c anaconda tensorflow-gpu=2.2 pip install tensorflow-addons==0.10.0
-
-
Datasets
- Fashion-MNIST will be automatically downloaded
- CelebA should be prepared by yourself in ./data/img_align_celeba/*.jpg
- dataset link: Dropbox
- the above link might be inaccessible, the alternatives are (find "img_align_celeba.zip")
- the Anime dataset should be prepared by yourself in ./data/faces/*.jpg
- dataset link: https://pan.baidu.com/s/1eSifHcA, password: g5qa
- reference: https://zhuanlan.zhihu.com/p/24767059
-
Examples of training
-
Fashion-MNIST DCGAN
CUDA_VISIBLE_DEVICES=0 python train.py --dataset=fashion_mnist --epoch=25 --adversarial_loss_mode=gan
-
CelebA DRAGAN
CUDA_VISIBLE_DEVICES=0 python train.py --dataset=celeba --epoch=25 --adversarial_loss_mode=gan --gradient_penalty_mode=dragan
-
Anime WGAN-GP
CUDA_VISIBLE_DEVICES=0 python train.py --dataset=anime --epoch=200 --adversarial_loss_mode=wgan --gradient_penalty_mode=wgan-gp --n_d=5
-
see more training exampls in commands.sh
-
tensorboard for loss visualization
tensorboard --logdir ./output/fashion_mnist_gan/summaries --port 6006
-