AWS, Cloud Computing

4 Mins Read

Selfie Based Face Identity Verification using Amazon Rekognition


In-person Verifying and validating a person’s identity is a slow, time-consuming process and costlier. Our day-to-day activities are modernized or handled electronically instead of through traditional in-person systems. Nobody wants their actions to be outdated or slow when time is seen as money in the modern world. As speaking into it, this blog will discuss the quick, accurate Selfie based face identity verification system leveraging deep learning and artificial intelligence through Amazon Rekognition.


Every citizen is identified/verified by a unique identity provided by the government. It differs from country to country and has various types of the identification system. Generally, we are well organized in India, and we have been provided a 12-digit unique identification number provided by the Government of India not only limited to Aadhaar but also other types of identity cards like Driving Licenses, Voter ID, Passports, etc.

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Identity Verification System

Businesses commonly use an Identity verification system, institutions, or e-commerce companies anywhere transaction is made, banking, social media, etc. To ensure the user provided information validly matches the identity of that person or user.

Amazon Rekognition has a pre-trained facial way of identity system that leverages Artificial Intelligence to recognize and understand facial data quickly, accurately, and cheaply. This replaces human workflow by building an intelligent system that verifies a person’s identity in a fraction of second.

Input to CompareFaces API

CompareFaces API takes two required arguments one is the source, and another is a target.

Source: Identity with face present in it (Required)

Target: Facial Image (Required)

Threshold: By default, the similarity threshold is set to 80. This means it returns only the face of the response greater than 80% of similarity. (Optional)

QualityFilter: It filter outs the input image based on filter type [ AUTO, LOW, MEDIUM, HIGH]. By default, it’s NONE. If you choose AUTO, then Amazon Rekognition will automatically choose the filter.

If the mentioned filter is not matched, then Amazon Rekognition won’t compare the faces.

Note: Input of source and target can be passed as base64 image byte or an s3 object. If the source image has multiple faces, it takes one largest face and compares it with each face detected in the target image.

On a given facial photo and identity where the user’s face is presented to Amazon Rekognition compareface API, the facial pattern of the Selfie or face is automatically recognized first and then compared with the face present in the Identity—for example, given an image of license identity with image present in it as source and target as facial image as shown below.

Note: If there are multiple faces in the source image, then the rekognition takes the largest images. And if using CLI, you will have to give input image in PNG or JPEG format.

Response of CompareFaces API

The API responds with an array of face matches arranged in decreasing order of similarity score. It also gives a bounding box of the key facial landmarks, information on pixels like radiance, contrast, intensity, etc., and a confidence level for each face match. A similarity score indicates how closely the faces resemble one another.

The primary response will have a Similarity score, face landmark bounding box coordinates, confidence score, landmark of different types such as [ left eye, right eye, left mouth, right mouth, nose], pose of roll, yaw, pitch, and for representing quality it has brightness and sharpness.

Note: Here confidence score is different from the similarity score. The Confidence score expresses the amount of confidence that the enclosing box includes a face, whereas the similarity score says how close the face matches.

Sample Input and output response

Input from Management Console:



Fig 1: In the above figure you can see the Source I uploaded is my PAN (Permanent Account Number); for Target, I had my Selfie to the API.

Even though the quality of 1st image face is poor, Amazon Rekognition has found a similarity score of 99.8 %.

Output Response :

Reference Code

If you want to try this via API cal using AWS lambda, there is a simple direct reference code below. For now, I have uploaded the image to my S3 bucket.


Fig 2 – In the above figure, you can see the execution results of the Lambda Code


We could see how Amazon Rekognition helps quickly design and create a selfie identity verification system.  We have understood the different input configurations and output responses as well. Since Amazon Rekognition is a fully managed AWS service, without any worries, this feature can be designed and deployed at any scale.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Amazon Rekognition and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.


1. What is CompareFaces API?

ANS: – A CompareFaces API that measures the two faces in the image are of the same person. This helps to verify a person’s identity against the person’s photo in real-time.

2. What happens if I have multiple faces in Source Image?

ANS: – You can have multiple images in the source image, but the image with the largest face will be taken as a source by CompareFaces.

3. How many faces can be compared in the target image?

ANS: – It can compare a face in the source image up to 15 faces in the target image.


Ganesh Raj V works as a Sr. Research Associate at CloudThat. He is a highly analytical, creative, and passionate individual experienced in Data Science, Machine Learning algorithms, and Cloud Computing. In a quest to learn and work with recent technologies, he strives hard to stay updated on advanced technologies along efficiently solving problems analytically.



    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!