Skip to content

A highly commented Tensorflow implementation of DCGAN and WGAN for images.

License

Notifications You must be signed in to change notification settings

ReidWilliams/GANs

Repository files navigation

It's the GANs

A highly commented Tensorflow implementation of DCGAN and WGAN for images.

This repo builds on DCGAN but adds lots of comments. If you're learning Tensorflow, deep neural networks, or GANs, it may be a good learning resource. If you just want to apply GANs asap or you really want to experiment with different architectures or loss functions, you may want to check out the TFGAN library.

Getting Started

You'll need Python 3, Tensorflow, NumPy, Pillow, and SciPy. You'll also need a training dataset. You can try starting with the CelebA celebrity faces dataset.

All images in the training set need to be the same size and both width and height dimensions need to be a multiple of 32. Rather than doing cropping/resizing of the dataset in the model, I use ImageMagick. I have an ImageMagick cheat sheet here.

Once you have everything installed and a dataset:

$ python main.py --datadir /path/to/data

Details

The model can handle various training image sizes as long as both width and height are divisible by 32. It will automagically figure out image size when it loads the training images. As image sizes get larger, the model does not add additional convolutional layers, it just increases the number of units in the generator and discriminator fully connected layers. This may limit how large you can go. I've trained models on 576x256 pixel images on a 12GB GPU card (with a batch size of 16).

Three output directories are created for you: logs for logfiles for Tensorboard, output for samples of images from the generator, and checkpoints for Tensorflow session checkpoint files. If you kill main.py and restart, it will pick up where it left off using the checkpoint files.

If you want to use the Wasserstein GAN (WGAN) loss function instead of the default DCGAN loss:

$ python main.py --datadir /path/to/data --wgan

There are more command line options. Check out the source for main.py for details.

made with a GAN

About

A highly commented Tensorflow implementation of DCGAN and WGAN for images.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages