9923170071 / 8108094992 info@dimensionless.in
The trending story of FaceApp and GANs

The trending story of FaceApp and GANs

Introduction

Have you been lately flooded with different posts on your social media profiles showing people with their current age on the left and their older self on the right? If yes and If you are wondering how people are doing it, then I may have an answer to your query here. There is a new app (only available on ios for now), FaceApp, which is behind this rising trend on social media. 

My initial guess was about that it must be one of the new image filter rolled out by Snapchat or Instagram but was clueless about the craze behind this trend. Since it’s similar to a 10-year challenge, rolled out by Facebook, earlier this year, there was no need for everyone to go crazy about this app. There are filters as well available which can make you look older. So why go bonkers over this new app?

If you look closely, results by FaceApp are much more realistic as compared to its image filter based counterparts in the Snapchat and Instagram. So what has FaceApp done which Snapchat and Instagram could not? We will try to answer this question in this blog. Before we proceed on to answer this question, let us understand what FaceApp is!

FaceApp used by celebs Arjun Kapoor and Deepika Padukone.
Courtesy: geekdashboard.com

What is FaceApp?

FaceApp is an IOS image processing app like many others on the app store which can process your images and bring changes to it. FaceApp was developed and released in 2016 by a small team of Russian developers. You can bring a selfie or use an ancient image from your phone and use a filter to use the app. The present free filters contain a smile that shows you old or young, sex bends, face hairs or the classic Walter White looks from the Breaking Bad TV series. The app gives its paying customers extra filters including maquilas, glasses and facial hair to their faces.

Changes include all the basic properties like contrast, brightness and sharpness to complex features like adding a smile, changing gender or showing an older/younger version of your self.

As previously said, all these features were available already on different apps as well but what makes the FaceApp really a winner is stark photo-realism. These images look more real and true rather than some blurry filter images. FaceApp with its surprisingly accurate image manipulation tricks has been able to gather a lot of attention because of which it has clocked over more than a million downloads in just 2 days. Rather than putting some creative or cartoonist filters over the images, FaceApp aims at manipulating the features present in the face in such a manner that it feels almost true to believe!

How is it different from Instagram filters?

So what is FaceApp doing differently? FaceApp rather than using image stacking or pixel manipulation uses Artificial Intelligence to bring the changes in the facial features. FaceApp makes use of the generative adversarial networks to create these images which are again too much realistic to be believed. Suppose you have a task of making a person smile in an image where he is not smiling at all. To make a person smile, extending the lips is not the only criteria. One needs to change all the facial features like eyes stretch, cheeks appearance in order to make the transformation realistic.

FaceApp has achieved this using GANs and this is exactly what is making this app stand out from the crowd. As far as we do not know of any other goods or studies of comparable performance in this field, FaceApp is far ahead in terms of the technology used. In the other section, let us dig deeper into the technique used by FaceApp

Underlying technology: GANs(Generative Adversarial Neural nets)

A Generative network is a type of AI machine learning (ML) method composed of two networks in a zero-sum game context that are in conflict with each other. GANs are usually unattended, teaching themselves how to imitate any specified information allocation.

There are two neural networks, the generator and the discriminator, that compose a GAN. The generator is a kind of neural system that creates fresh cases of an item, and the discriminator is a sort of neural network that determine its identity or whether it resides in a dataset.

During the teaching phase, both the models try to compete, their losses push each other towards improving behaviour and is called backpropagation. The generator’s objective is to generate reasonable performance while the discriminatory’s objective is to define the counterfeit. The generator generates high-quality results, and the discriminator is superior with the flagging components having a double feedback loop.

The first stage in the development of a GAN is for the required yield to be identified and the original learning data based on these parameters collect. This information are randomized and entered into the generator until the fundamental precision of the output is achieved.

Afterwards, the produced pictures and the real information points from the original concept are transmitted into the discriminator. The discriminator filters and gives the chance to reflect the validity of each image between 0 and 1 (1 corresponds to actual and 0 to falsify).

These values are then controlled manually and repeated until the required result is achieved. In a zero-sum game, both networks try to optimize a loss function.

Other use cases of GANs

  1. Generating realistic photographs
    This use case revolves around generating new human faces which are too realistic that you won’t ever believe that there exists no person in the entire world with that face. Realism and use of state of the art artificial neural networks have made it possible to generate fake faces at ease. Realism in these images is the one key factor which has stirred the world and has made the use of GANs really attractive! You can view the example here which generated random faces using the generative adversarial networks
  2. Image-to-Image Translation
    The image-to-image translation is the task of taking and transforming images from one domain to have the image style (or characteristics) from another.
  3. Text-to-Image Translation
    In recent times, translation from text to the image has been an active field of research. A network’s capacity to understand the significance of a phrase and to create a precise picture depicting the phrase demonstrates a model’s capacity to more like people. Generative Adversarial Networks (GANs) are used to produce high-quality text input pictures through popular text to image translation techniques.

Proceed with caution

Experts have warned to allow them access to your personal details and identity by a FaceApp ancient age filter. FaceApp also involves in its terms and conditions, which you give the approval to access your picture gallery, the right of modifying, reproducing and publishing any image you process via its AI. This implies your face might finally be marketed.

By accepting the terms, we allow FaceApp to use, adapt, post, and distribute your user content in any media format on a perpetual, irrevocable, free of charge. This implies that you can use your actual name, your username or “any similarity is given” without notification, much less payment, in any format. You can keep it as long as you want and you can’t prevent it, even after you delete an app.

Summary

In this blog, we looked at the new emerging FaceApp which has gathered eyeballs all around. Furthermore, we also spent some time in understanding an overview of the technology which is behind this trending application. Although the faceApp has come with a breakthrough in the GANs technology and have set up high standards for the other apps, concerns around the data security and data-policy is still a concern with FaceApp. 

Follow this link, if you are looking to learn data science online!

You can follow this link for our Big Data courseThis course will equip you with the exact skills required. Packed with content, this course teaches you all about AWS tools and prepares you for your next ‘Data Engineer’ role

Additionally, if you are having an interest in learning Data Science, click here to start the Online Data Science Course

Furthermore, if you want to read more about data science, read our Data Science Blogs

Face Recognition Using Python

Face Recognition Using Python

Introduction

AI is revolutionizing the world. Face recognition is one such spectrum of it. Almost most of us use face recognition systems. They are everywhere. One can find them  in devices like our mobile or platforms like Facebook or applications like Photo gallery apps or advanced security cameras.

In this blog, we are going to have our hands dirty with facial recognition in python and learn how can we train a model to learn faces from images! Before we start with the implementation, let us dive down a little into basics of face recognition theory

 

What is Face Recognition?

The issue is answered by a face identification scheme: does an image’s face match the image’s face? A face recognition scheme requires a face picture and predicts if the face corresponds to other pictures in the database supplied. Face-recognition schemes have been developed to compare and forecast possible face match irrespective of speech, face hair, and age.

Facial recognition is the process of identifying or verifying the identity of a person using their face. It captures, analyzes and compares patterns based on the person’s facial details.

  • The face detection process detects and points out human faces in images.
  • The face capture process transforms camera feed (a face) into a set of mathematical representation based on the person’s facial features.
  • The face match process verifies if two faces are of the same person.

Today it’s considered to be the most natural of all biometric measurements.

What are the Steps in Face Recognition?

Step 1: Detecting the Faces

Face detection is the first phase in our pipeline. We must put the images in a picture before trying to divide them. Methods such as HOG can be used to define the images in a specified picture. Histograph of Oriented Gradients The distribution (histogram) of gradient instructions is used as characteristics in the HOG function descriptor. Gradients (X and Y derivatives) are helpful in an image because the size of the gradient is wide around edges and angles, and we know that edges and corners are more informed about the shape of an object than flat regions. HOG is more like a manner to detect a picture of the picture, by identifying the corners by the comparison of the various sections of the picture

Step 2: Face Landmark Estimation

Moreover, we have to cope with issues such as faces in various directions. Such images look completely different from a computer and the similarity between them on their own can not be found. We can use an algorithm known as face-point assessment to do this. Vahid Kazemi and Josephine Sullivan have created an strategy in 2014. The fundamental concept is that we will have 68 particular points on every face (called sights). Once we understand where there are distinct face characteristics, we can scale the picture for a single person, spin it and shear it.

Step 3: Face Encoding

We need a way to obtain a few fundamental readings from each face at this point. Then we could evaluate the unfamiliar face in the same manner and discover the most close-known face. This can be done with profound teaching (CNNs). Incorporation of characteristics from prior measures must be created. We can once recognize this embedding for an unidentified face.

Step 4: Classifying Unknown Faces into Known Ones

In fact, this is a simpler phase. All we have to do is discover the individual who has the nearest measurement to our sample picture in our database of recognized individuals. We can do this using an algorithm for fundamental teaching machines. All we have to do is train a classifier to measure from a fresh sample picture and show which recognized individual is nearest to each other. It requires milliseconds to run this classifier. The classificator outcome is the person’s name!

 

Transfer Learning for Face Recognition

Transfer training is a computer training process in which a model created for a job is used again as the basis for a second job model. It is an approach popular in the field of in-depth learning, where prequalified models are used to start computer vision and natural language treatment work, given the huge computer and time resources required to develop neural network models on these problems. We use transfer learning in our blog as well. For face detection and recognition, we use pre-built designs. Training a face recognition model is a very costly job. You need a bunch of information and computing energy to train profound facial recognition teaching models.

For our assignment, we will currently use python’s facial recognition library. The book uses the profound teaching model educated by a threefold loss function. The Siamese network we call. “Siamese” implies linked or attached. Perhaps you heard of Siamese twins? Siamese networks may be formed by convolutionary structures and dense or layers of LSTM. We will use the Convolutionary Siamese Network since we will cope with pictures to identify the faces. You can understand the architecture by this image :

Conventional Siamese Network Architecture

This is the fundamental algorithm:

  1. we take two photographs (Figures 1 and 2). The last layer of the CNN generates a permanent shape matrix (picture embedding), the last part of which is the CNN. We get two embeddings as two pictures are feed. (h2 and h1). (h1).
  2. The absolute range is calculated between the vectors.
  3. Then a sigmoid function passes through measurements and the resemblance value is generated.
  4. The scores are nearer to 1 if the pictures are comparable or nearer to 0.

 

Implementation

Getting the libraries

The first step is to load all the libraries. We will be using the face_recognition library for detection and recognition in this case. This library provides out of the box methods to perform various tasks involved during a facial recognition process.

 

Generating the Encodings for the Knows Users

In this section, we are trying to convert images of the known users into a mathematical representation. This mathematical representation is a high dimensional vector. We can call this high dimensional vector as an embedding. Each image has it’s own 1 embedding. These embeddings are important to describe an image in a high dimensional space. 

The code below tries to identify a face in a given image. Once the model detects the face, it extracts out facial features and passes them to another model which converts these features into a mathematical representation known as embeddings. In the end, we collate all the images and their corresponding embedding in a list. 

This is a set of true values for us. All the users present in this list are the ones which we want to recognize correctly. Any user out of this set should be called out as an “unknown” by the model!

 

Matching New Users

In the previous section, we generated embeddings for known users. Now, we need to generate these embeddings for the new test users whom we want to predict through our model.

We have a written a predict face utility function which will take in the input path of the test image and will return the name of the recognized person!

 

Getting the Predictions

The previous utility function takes one image as input. Below code, basically iterates over multiple test images present in a folder. It passes it to the predict function and collects the predicted name. All the results are stored in a data frame!

 

Calculating Model Metrics

This is an extension to measure the metrics of the model. We are calculating accuracy, specificity, recall and F1 score of our face prediction model.

 

Summary

Security is now one of the areas that most use face recognition. Facial recognition is a very efficient instrument which enforcers can use the technology to identify criminals and software businesses to assist consumers to access the technology. It is possible to further develop this technology to be used in other ways, like ATMs, private records or other delicate equipment. This may outdated other safety steps, including passwords and buttons.

In the subways and in the other rail networks, innovators also seek to introduce facial identification. You want to use this technology to pay for your transport charge, using faces as credit cards. The facial recognition takes your picture, runs it through a scheme and charges the account you have earlier developed instead of getting to go to a stand and purchase a ticket. This can rationalize the method and dramatically optimize traffic flow. Here’s the future.

Follow this link, if you are looking to learn data science online!

You can follow this link for our Big Data courseThis course will equip you with the exact skills required. Packed with content, this course teaches you all about AWS tools and prepares you for your next ‘Data Engineer’ role

Additionally, if you are having an interest in learning Data Science, click here to start the Online Data Science Course

Furthermore, if you want to read more about data science, read our Data Science Blogs

Concept of Cluster Analysis in Data Science

A Comprehensive Guide to Data Mining: Techniques, Tools and Application

A Comprehensive Introduction to Data Wrangling and Its Importance