Face Generation Using Generative Adversarial Networks (GAN)

Milind Raj
Nerd For Tech
Published in
3 min readFeb 7, 2021

--

Generative Adversarial Network is the most interesting idea in the last ten years in machine learning ~ Yann LeCun

Introduction

With the burgeoning of AI industry, there are many types of Neural Networks based architectures emerging in deep learning domain, besides the most popular Convolutional Neural Networks (CNN), Recurrent Neural Network (RNN) which generally uses a single neural network, there is something new which was founded in 2014 by Ian J. Goodfellow and co-authors, know as Generative Adversarial Networks (GAN), and is catching up in the AI industry, as it works by using two neural networks. GANs are used for many funny as well as useful tasks, they are used for generating something fake which could look as close to original such as generating fake human faces, fake videos, they are not limited to that, but they can also be used to create a fake video of a person delivering speech. Doesn’t that sounds magical ? So, lets dive into the world of fake humans.

GANs are Dangerous ?

What are Generative Adversarial Networks and how they work?

GANs are generative models which are used to generate fake things such as images, audio and videos. GANs contain two neural networks the Generator and the Discriminator. Generator generates new random data patterns whereas the discriminator checks classifies the data pattern generated by discriminator as real (belonging to the original training set) or fake.

Why the name adversarial came, is there any conflict in between any two things here? Yes, the name adversarial came because the two networks generator and discriminator works in a conflicting or opposite manner. Main aim of generator is to fool discriminator, but how? GANs works as follows, firstly the generator generates some fake data pattern and send it to the discriminator to check whether its real or fake, the main motive of generator is create fake data patterns so meticulously, such that the discriminator classifies it as real.

How GANs generate fake faces?

The following steps are followed by a GAN used for face generation :

  1. Generator takes an array of random numbers having size equal to seed size and generates an image.
  2. The generated images with equal number of real face images (which are used for training) are passed to the discriminator for their classification as real or fake.
  3. Discriminator now passes its result as a loss again to the generator to make itself more accurate in producing fake images.
  4. This process keeps iterating for a desired number of times, hence generator keeps on improving its output so as to fool the discriminator.

Both, the discriminator and generator doesn’t run simultaneously.

To create your world of fake images, see some of the sample faces that I have generated you may visit my Github.

A gif of all the faces generated by generator after every 50 iterations of improving

Keep Generating!

--

--

Milind Raj
Nerd For Tech

Computer Science student at IIIT Bhopal | AI Enthusiast