5 Selecting Characteristics in Generated Images

 

This chapter covers

  • Building a conditional GAN to generate images with certain attributes (human faces with or without eyeglasses, for example)
  • Implementing Wasserstein distance and gradient penalty to improve image quality
  • Selecting vectors associated with different features so that the trained GAN model generates images with certain characteristics (male or female faces, for example)
  • Combining conditional GAN with vector selection to specify two attributes simultaneously (female faces without glasses or male faces with glasses, for example)

The Anime faces we generated with deep convolutional GAN (DCGAN) in Chapter 4 look realistic. However, you may have noticed that each generated image has different attributes such as hair color, eye color, and whether the head tilts toward left or right. You may be wondering if there is a way to tweak the model so that the generated images have certain characteristics (such as with black hair and tilting toward the left)?

It turns out you can.

5.1 The Eyeglasses Dataset

5.1.1 Download the eyeglasses dataset

5.1.2 Visualize images in the eyeglasses dataset

5.2 Conditional GAN with Wasserstein Distance

5.2.1 Wasserstein GAN with Gradient Penalty

5.2.2 Conditional GANs

5.3 Create a conditional GAN

5.3.1 A critic in conditional GAN

5.3.2 A generator in conditional GAN

5.3.3 Weight initialization and the gradient penalty function

5.4 Train the conditional GAN

5.4.1 Add labels to inputs

5.4.2 Train the Conditional GAN

5.5 Select characteristics in generated images

5.5.1 Select images with or without eyeglasses

5.5.2 Vector arithmetic in latent space

5.5.3 Select two characteristics simultaneously

5.6 Summary