Home

Awesome

GANs Implementations in Keras

Keras implementation of:

The DCGAN code was inspired by Jeremy Howard's course

Requirements:

You will need Keras 1.2.2 with a Tensorflow backend.
To install dependencies, run pip install -r requirements.txt
For command line parameters explanations:

python3 main.py -h

DCGAN

Deep Convolutional GANs was one of the first modifications made to the original GAN architecture to avoid mode collapsing. Theses improvements include:

<div align="center"><img width="180" src ="https://github.com/germain-hug/GANs/raw/master/results/dcgan.png" /></div> <br />
python3 main.py --type DCGAN --no-train --model weights/DCGAN.h5 # Running pretrained model
python3 main.py --type DCGAN # Retraining

WGAN

Following up on the DCGAN architecture, the Wasserstein GAN aims at leveraging another distance metric between distribution to train G and D. More specifically, WGANs use the EM distance, which has the nice property of being continuous and differentiable for feed-forward networks. In practice, computing the EM distance is intractable, but we can approximate it by clipping the discriminator weights. The insures that D learns a K-Lipschitz function to compute the EM distance. Additionally, we:

<div align="center"><img width="240" src ="https://github.com/germain-hug/GANs/raw/master/results/wgan.png" /></div>
python3 main.py --type WGAN --no-train --model weights/WGAN.h5 # Running pretrained model
python3 main.py --type WGAN # Retraining

cGAN

Conditional GANs are a variant to classic GANs, that allow one to condition both G and D on an auxiliary input y. We do so simply feeding y through an additional input layer to both G and D. In practice we have it go through an initial FC layer. This allows us to have two variables when generating new images:

<div align="center"><img src ="https://github.com/germain-hug/GANs/raw/master/results/cgan.png" /></div>
python3 main.py --type CGAN --no-train --model weights/CGAN.h5 # Running pretrained model
python3 main.py --type CGAN # Retraining

InfoGAN

The motivation behind the InfoGAN architecture is to learn a smaller dimensional, "disentangled" representation of the images to be generated. To do so, we introduce a latent code c, that is concatenated with the noise vector z. When training, we then want to maximize the mutual information between the latent code c and the generated image G(z,c). In practice, we:

<div align="center"><img src ="https://github.com/germain-hug/GANs/raw/master/results/infogan.png" /></div>
python3 main.py --type InfoGAN --no-train --model weights/InfoGAN_D.h5 # Running pretrained model
python3 main.py --type InfoGAN # Retraining