Have you tried the famous face age challenge or the latest gender swap challenge? Or the snapchat face swap filter? If not I bet you must have seen it once while scrolling down your Instagram feed …right?
Ever wondered how they do it? What if you can make your own filter?
sounds interesting! Isn’t it?
Well today, I’ll tell you the secret behind it.
The basic architecture behind all these is a GAN.
Is this it to GAN applications?
No, Lets take a look at few cool applicatios of GANs :-
Create Anime characters
I have seen a craze of animes and its characters in this generation. Here this application is for you. How about your GAN model can automatically generate an anime character without hiring any artist. Look at these anime characters generated by a GAN. They don’t really exist..😮
Super Resolution GAN or srGAN
GANs can perform exceptionally well in transforming a low resolution image to a super resolution image.
GauGAN can be used to generate photorealistic image from a segmented image layout.
Text to image (StackGAN)
A StackGAN can convert a text description to an image based on the description.
It is another cool application of GAN which transfers the style of one image to another on a completely different domain. Look how efficiently DiscoGAN generated a shoe image using a handbag image style and vice versa.
It can generate an amazingly realistic images of celebs or people with control over varius aspects of the image. Look at the images below.
Disclaimer :- These people are not real. They do not exist. They are born by the StyleGAN model
There are infinite such appliations of GANs. So are you excited to know more about GANs?
I said a lot about its application but What is it?
So, lets take a deep dive into GANs. It’s gonna be gantastic 😉
Introduction to GAN
Let’s start with a very intuitive introduction to GANs.
You must have known about CNNs and its architectures or may have some experience with it too. So, GAN’s are basically a framework for estimating generative models.
Too many technical terms..Ah..
Okay I will try to make this section of the article free from such words. It will truely focus to develop an intuitive understanding about GANs.
Lets take an example of this story-
- There was a young thief who wanted to be the best counterfeiter in smuggling fake currency. He generated some fake currencies and went to a famous Mafia who specializes in detecting fake currencies. The young thief wasn’t much good at counterfeiting so the expert Mafia told him to to go back as his currency was a way far to look as real money.
- The thief went back and tried harder this time and generated a few good copies of currency. So, Mafia was a little impressed as he couldn’t detect some of the copies as fake. He told him to go back and make more of such copies. The thief was like I see what can fool him, I’ll make more of these and Mafia was like I need to be better at detecting fakes.
- He tried a bit harder this time and fooled the Mafia a bit more in detecting fakes.
Thus each time the thief was getting better at generating fakes and the Mafia was getting better at detecting fakes. They were playing a MiniMax game by mutually getting better at their own work.
Same goes with the GAN network. The little thief is the generator and the expert Mafia is the discriminator.
There are two models competing against each other and getting mutually better at their own work.
- The Generator generates synthetic images out of a latent space which is nothing but an image initialized with random pixel values.
- And the Discriminator distinguishes the image as real or fake.
Generator tries to fool the Discriminator by generating realistic looking fake images and discriminator tries to better recognize fake images. If the Discriminator couldn’t detect fake images, it means our generator model is generating very good real looking images but this can also mean our discriminator is not performing well. So discriminator is trained to detect fakes with better accuracy and generator takes the feedback from discriminator to generate more real looking images.
The reason they compete against each other in an adversarial manner is why this generative model is called Generative Adversarial Networks or simply GANs.
I hope you have got the intuition behind the GANs and how they operate in general.
Let’s have a look at the architecture of GAN.
Different Types of GANs
Deep Convolutional GANs (DCGANs)
This is an improvement of the basic architecture of GAN which we discussed above. These come under unsupervised training of GANs.
Conditional GANs or cGAN
These GANs produce much more controlled output by using Supervised training approach. It requires extra label information for training.
Pix2Pix is a type of conditional GAN which is used to perform image-to-image translation tasks. In simpler words, it is used in case of mapping of an image from one domain to another image from a different domain. Some examples of Pix2Pix GANs are Black & White image to Color image translation or Satellite images to Google Map images or vice versa and so on…
The approach used by CycleGANs to perform Image to Image Translation is quite similar to Pix2Pix GAN with the exception of the fact that unpaired images are used for training CycleGANs and thus it follows unsupervised approaach of learning.
Also, CycleGan consists of two generator and two discriminators. One generator takes an image from one domain as input and generate an output image for other domain while the second generator takes this generated image as input and generate an output image for first domain. Discriminators are used to detect how realistic these images are generated by the generators. A cycle adversarial loss is used to measure how different is the generated image by second generator to the original image from the source domain and vice versa.
Example of CycleGAN-
There are many more types of GANs which are beyond the scope of this article and A lot more are in research and being developed.
I wanted to make this article more practical with practical implementation of some GANs, but an initial introduction was a necessity.
If you like this article and are interested to learn more about GANs and learn its practical implementations do let me know by liking this post or leave comments down below. I would love to write more on GANs. Lets be gangsters of GANs 😎
Till then, have a gantastic day ahead 😉
(Excuse me for the cheesy jokes on GAN 😂)