Progressive Growing of GANs for Improved Quality, Stability, and Variation
Progressive Growing of GANs for Improved Quality, Stability, and Variation
Tero Karras (NVIDIA), Timo Aila (NVIDIA), Samuli Laine (NVIDIA), Jaakko Lehtinen (NVIDIA and Aalto University)
Abstract:
We describe a new training methodology for generative adversarial networks. The key idea is to grow both the generator and discriminator progressively: starting from a low resolution, we add new layers that model increasingly fine details as training progresses. This both speeds the training up and greatly stabilizes it, allowing us to produce images of unprecedented quality, e.g., CelebA images at 10242. We also propose a simple way to increase the variation in generated images, and achieve a record inception score of 8.80 in unsupervised CIFAR10. Additionally, we describe several implementation details that are important for discouraging unhealthy competition between the generator and discriminator. Finally, we suggest a new metric for evaluating GAN results, both in terms of image quality and variation. As an additional contribution, we construct a higher-quality version of the CelebA dataset.
★★★ NEW: StyleGAN2-ADA-PyTorch is now available; see the full list of versions here ★★★
karras2018iclr-poster.pdf)karras2018iclr-slides.pptx)images/representative-images)videos/high-quality-video-clips)images/100k-generated-images)videos/one-hour-of-random-interpolations)networks/tensorflow-version)networks/tensorflow-version/example_import_script)datasets/celeba-hq-deltas)networks/tensorflow-version/example_training_runs)All the material, including source code, is made freely available for non-commercial use under the Creative Commons CC BY-NC 4.0 license. Feel free to use any of the material in your own work, as long as you give us appropriate credit by mentioning the title and author list of our paper.
There are two different versions of the source code. The TensorFlow version is newer and more polished, and we generally recommend it as a starting point if you are looking to experiment with our technique, build upon it, or apply it to novel datasets. The original Theano version, on the other hand, is what we used to produce all the results shown in our paper. We recommend using it if — and only if — you are looking to reproduce our exact results for benchmark datasets like CIFAR-10, MNIST-RGB, and CelebA.
The main differences are summarized in the following table:
| Feature | TensorFlow version | Original Theano version |
|---|---|---|
| Branch | master (this branch) | original-theano-version |
| Multi-GPU support | Yes | No |
| FP16 mixed-precision support | Yes | No |
| Performance | High | Low |
| Training time for CelebA-HQ | 2 days (8 GPUs) 2 weeks (1 GPU) |
1–2 months |
| Repro CelebA-HQ results | Yes – very close | Yes – identical |
| Repro LSUN results | Yes – very close | Yes – identical |
| Repro CIFAR-10 results | No | Yes – identical |
| Repro MNIST mode recovery | No | Yes – identical |
| Repro ablation study (Table 1) | No | Yes – identical |
| Dataset format | TFRecords | HDF5 |
| Backwards compatibility | Can import networks trained with Theano |
N/A |
| Code quality | Reasonable | Somewhat messy |
requirements-pip.txtAll pre-trained networks found on Google Drive, as well as ones produced by the training script, are stored as Python PKL files. They can be imported using the standard pickle mechanism as long as two conditions are met: (1) The directory containing the Progressive GAN code repository must be included in the PYTHONPATH environment variable, and (2) a tf.Session() object must have been created beforehand and set as default. Each PKL file contains 3 instances of tfutil.Network:
# Import official CelebA-HQ networks.
with open('karras2018iclr-celebahq-1024x1024.pkl', 'rb') as file:
G, D, Gs = pickle.load(file)
# G = Instantaneous snapshot of the generator, mainly useful for resuming a previous training run.
# D = Instantaneous snapshot of the discriminator, mainly useful for resuming a previous training run.
# Gs = Long-term average of the generator, yielding higher-quality results than the instantaneous snapshot.It is also possible to import networks that were produced using the Theano implementation, as long as they do not employ any features that are not natively supported by the TensorFlow version (minibatch discrimination, batch normalization, etc.). To enable Theano network import, however, you must use misc.load_pkl() in place of pickle.load():
# Import Theano versions of the official CelebA-HQ networks.
import misc
G, D, Gs = misc.load_pkl('200-celebahq-1024x1024/network-final.pkl')Once you have imported the networks, you can call Gs.run() to produce a set of images for given latent vectors, or Gs.get_output_for() to include the generator network in a larger TensorFlow expression. For further details, please consult the example script found on Google Drive. Instructions:
pip install -r requirements-pip.txtimport_example.py from networks/tensorflow-version/example_import_scriptkarras2018iclr-celebahq-1024x1024.pkl from networks/tensorflow-version and place it in the same directory as the script.python import_example.pyimg0.png–img9.png) that match the ones found in networks/tensorflow-version/example_import_script exactly.The Progressive GAN code repository contains a command-line tool for recreating bit-exact replicas of the datasets that we used in the paper. The tool also provides various utilities for operating on the datasets:
…The datasets are represented by directories containing the same image data in several resolutions to enable efficient streaming. There is a separate *.tfrecords file for each resolution, and if the dataset contains labels, they are stored in a separate file as well:
> python dataset_tool.py create_cifar10 datasets/cifar10 ~/downloads/cifar10
> ls -la datasets/cifar10
drwxr-xr-x 2 user user 7 Feb 21 10:07 .
drwxrwxr-x 10 user user 62 Apr 3 15:10 ..
-rw-r--r-- 1 user user 4900000 Feb 19 13:17 cifar10-r02.tfrecords
-rw-r--r-- 1 user user 12350000 Feb 19 13:17 cifar10-r03.tfrecords
-rw-r--r-- 1 user user 41150000 Feb 19 13:17 cifar10-r04.tfrecords
-rw-r--r-- 1 user user 156350000 Feb 19 13:17 cifar10-r05.tfrecords
-rw-r--r-- 1 user user 2000080 Feb 19 13:17 cifar10-rxx.labelsThe create_* commands take the standard version of a given dataset as input and produce the corresponding *.tfrecords files as output. Additionally, the create_celebahq command requires a set of data files representing deltas with respect to the original CelebA dataset. These deltas (27.6GB) can be downloaded from datasets/celeba-hq-deltas.
Note about module versions: Some of the dataset commands require specific versions of Python modules and system libraries (e.g. pillow, libjpeg), and they will give an error if the versions do not match. Please heed the error messages — there is no way to get the commands to work other than installi
No open issues yet, or sync has not completed.