TF-GAN is a lightweight library for training and evaluating Generative Adversarial Networks (GANs). GANs have been in a wide range of tasks including image translation, superresolution, and data augmentation. This directory contains fully-working examples. Each subdirectory contains a different working example. The sub-sections below describe each of the problems, and include some sample outputs. Be sure to follow the instructions for how to run the examples.
-
Add the examples directory to your PYTHONPATH environment variable with
export PYTHONPATH=${TFGAN_REPO}/tensorflow_gan/examples:${PYTHONPATH}
Be sure to use the location where you cloned this repository.
-
Add this repository to your PYTHONPATH environment variable so that it can be used for
tensorflow_gan
instead of any older libraries you might have installed.export PYTHONPATH=${TFGAN_REPO}:${PYTHONPATH}
-
Install the necessary dependencies, which depend on which example you want to run. At a minimum, you will need:
tensorflow
tensorflow_probability
tensorflow_datasets
You can usually install these with:
pip install --upgrade $PACKAGE --user
-
Follow the instructions in the particular example directory's
README.md
.
- If you get an error like
ImportError: No module named xxx
, you might not have set thePYTHONPATH
properly. See step #1 above. - If you get an error for something basic like
ImportError: No module named absl
, you might not have installed all the imports you need.
- Email joelshor@google.com to propose the idea.
- Add a
README.md
to your new subdirectory. Be sure to include a "How to run" section. - Add a subdirectory with output ex "images" or "audio".
- Add a line and high-level summary to this file.
- Submit it and profit.
- MNIST
- MNIST Estimator
- CIFAR10
- CIFAR10 on Cloud TPU
- CycleGAN
- StarGAN
- StarGAN Estimator
- Progressive GAN
- Self-Attention GAN
Authors: Joel Shor, Yoel Drori
An unconditional GAN, a conditional GAN, and an InfoGAN, all trained on MNIST digits. We use a classifier trained on MNIST digit classification for evaluation.
Author: Joel Shor
Two examples. Both are unconditional GANs trained on MNIST using the
tfgan.estimator.GANEstimator
,
which reduces code complexity and abstracts away the training details.
The first uses the tf.Estimator
"blessed" method using train_and_evaluate
.
The second example uses custom estimator calls.
Author: Joel Shor
We train a DCGAN generator to produce CIFAR10 images. The unconditional case maps noise to CIFAR10 images. The conditional case maps noise and image class to CIFAR10 images. We use the Inception Score to evaluate the images.
Authors: Tom Brown, Joel Shor, David Westbrook
This colaboratory notebook
introduces you to using
TF-GAN's TPUGANEstimator
to train GANs on Google's cloud TPU. This
infrastructure gives you unprecedented compute power and batch size. In less
than five minutes, you can train an unconditional GAN on CIFAR10.
Author: Shuo Chen and Cassandra Xia
Based on the paper "Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks", this example converts one set of images into another set in an unpaired way.
Author: Wesley Qian
A StarGAN implementation for multi-domain image translation. We run StarGAN on the CelebA dataset.
Author: Wesley Qian
An Estimator implementation of the example above using
tfgan.estimator.StarGANEstimator
.
Author: Shuo Chen
An implementation of the technique described in Progressive Growing of GANs for Improved Quality, Stability, and Variation. We run the network on the CIFAR10 dataset.
Author: Yoel Drori, Augustus Odena, Joel Shor
An implementation of Self-Attention Generative Adversarial Networks. The generator produces downsampled ImageNet images. It can be trained on GPU or cloud TPU.