Defacify

- 10 mins

image

image source

Ever wondered how the FACE APP works? Or how with a simple Snapchat filters you are able to create Opposite Gender Images? Or how the snapchat Baby Filter works??

If the answer to all these questions is yes and you really want to know the technique behind it then Style GAN is the answer for you.

Since we have already covered Style GAN, it's architecture and the maths behind it. Let's deep dive further to play around with different facial images.

ARE YOU READY???

image

Let's Deep Dive

So now, Since we have already obtaned our output vectors from the generated images in the Style GAN Exordium blog. We can tweak that latent vector space for playing around with different facial images.

The whole process looks like this:-

We again take a set of random samples and generate facial images from it. Now we classify these images using pretrained classifier (VGG net) to obtain a set of attributes or feature vectors (like hair colour, smile, skin colour, gender etc.) and create a dataset from these attributes.

Markdowm Image

In the notebook you will find a pretrained classifier for this purpose. The original Style GAN contains a 512 dimensional feature vector (directions) space.

Markdowm Image

This a very large and complex feature vector space but what we are really interested in is How does the latent directions changes the resulting faces? So with all the dataset we have created we can map those feature attributes (classification attributes like hair colour, gender, skin colour, etc.) at this 512 dimensional feature vector space.

Markdowm Image

One important observation here is that all the respective attributes are quite seperable, that is if we draw a linear hyper plane we can surely classify these attributes in groups.

Markdowm Image

After finding out the hyperplane, if we take a normal to this hyper plane, we can note that by going in the direction of this normal we can pretty much generate aged or different gender images of a particular image.

Markdowm Image

Pretty Easy Right?? Let's try this with code. In this Google Colab notebook you will find a whole bunch of latent space vectors to train on

These are the vector space which I found useful. If you want to train your own latent direction, There is a code for that too...

Abhishek Parashar

Abhishek Parashar

I make sense with data while having Pizza, Coffee and Freaky shakes.

comments powered by Disqus
twitter facebook linkedin reddit rss