StyleGAN2: AI’s Imagination

Original article was published on Deep Learning on Medium

StyleGAN2: AI’s Imagination

Generative Adversarial Networks (GAN) are a relatively new concept in Machine Learning, introduced by Ian J. Goodfellow in 2014. GANs can be taught to generate realistic data (indistinguishable from authentic) such as images.

For example, generating artificial face images by learning from a dataset of real faces. In basic GAN setup, we have two neural networks, First the generator, generates new data instances, while the second network, the discriminator, decides whether the data is true or fake.

The quality of generated images are getting better over time. However, one of the main challenges is controlling the output in terms of controlling specific features such as pose, gender and hair style while generating face images.

For better understanding of of StyleGAN2’s capabilities and how its works, we are going to use use them to generate images, in different scenarios.

#1: Generate random images

Use the Generator to generate faces/cars starting from random points in the latent space. Here are some samples:

Figure 1: Random generated faces by StyleGAN2
Figure 2: Random generated faces by StyleGAN2
Figure 3: Random generated cars by StyleGAN2

#1: Style Mixing

Mixing two images using their corresponding W vectors to get a new images with mixed style! Just have a close look at the following example where the result image is mixed from the corresponding row and column sources.

Figure 4: Shows how style mixing can generate so many faces using existing ones

Now, observe the results when rows and columns are swapped.

Figure 5: Shows how style mixing can generate so many faces using existing ones

3- Interpolation

Having two images (and the corresponding latent vectors), we can move from one image to the other by interpolating the latent vector, and generate the intermediate images.

Here are the two original images:

Figure 6: Interpolation, Original Images

And here is the full Interpolation between the two images: