In December Synced reported on a hyperrealistic face generator developed by US chip giant NVIDIA. The GAN-based model performs so well that most people can’t distinguish the faces it generates from real photos. This week NVIDIA announced that it is open-sourcing the nifty tool, which it has dubbed “StyleGAN”.
The Flickr-Faces-HQ (FFHQ) dataset used for training in the StyleGAN paper contains 70,000 high-quality PNG images of human faces at 1024×1024 resolution (aligned and cropped).
Users can either train their own model or use the pretrained model to build their face generators. Linux and Windows are supported, with specific system requirements as follows:
Both Linux and Windows are supported, but we strongly recommend Linux for performance and compatibility reasons.
64-bit Python 3.6 installation. We recommend Anaconda3 with numpy 1.14.3 or newer.
TensorFlow 1.10.0 or newer with GPU support.
One or more high-end NVIDIA GPUs with at least 11GB of DRAM. We recommend NVIDIA DGX-1 with 8 Tesla V100 GPUs.
NVIDIA driver 391.35 or newer, CUDA toolkit 9.0 or newer, cuDNN 7.3.1 or newer.
The pre-trained models are stored as pickle(.pkl) files in Google Drive. To use the pre-trained network, users have the option of minimal examples at pretrained_example.py or more advanced examples from generate_figures.py.
Those who prefer to train the model themselves with a prepared dataset can complete the following steps:
- Edit train.py to specify the dataset and training configuration by uncommenting or editing specific lines.
- Run the training script with
- The results are written to a newly created directory
Training time varies depending on configurations and hardware. NVIDIA estimates training time for 1024×1024 resolution images using Tesla V100 GPU as follows:
All related project material is available on the StyleGan Github page, including the updated paper A Style-Based Generator Architecture for Generative Adversarial Networks, result videos, source code, dataset, and a shared folder containing additional material such as pre-trained models.
The hyperrealistic results do require marshalling some significant compute power, as the project Github page advises: “Please note that we have used 8 GPUs in all of our experiments. Training with fewer GPUs may not produce identical results – if you wish to compare against our technique, we strongly recommend using the same number of GPUs.” This sort of reminds us of NVIDIA Founder and CEO Jensen Huang’s hardware pitch-quip at the GTC 2018: “The more you buy, the more you save!”
Author: Mos Zhang | Editor: Michael Sarazen