Detect, Analyze and Compare faces using Amazon Rekognition
Tags: ai, amazonrekognition, aws
Published: 2024-01-29 02:56:03

### Introduction
In this blog post, I will be showing a demo on the AWS management console on how to the face recognition features in Amazon Rekognition. I will analyze an image with Amazon Rekognition and then compare it to other images to check if the faces are the same.

### What is Amazon Rekognition?
[Amazon Rekognition](https://aws.amazon.com/rekognition/) is a deep learning-based image and video analysis service. If you are implementing an employee verification system, need to automate video editing, or provide secondary authentication for other applications, you may encounter the difficulty of facial recognition and comparison. You could fix this by creating your own machine learning model, an API, and managing your own infrastructure. This approach is costly, time-consuming, and needs specialized understanding.

An easier method is to utilize Amazon Rekognition, which can recognize faces in images or videos, discover facial landmarks like as eye location, and detect emotions such as joy or sadness in near-real time or in batches without infrastructure or modeling maintenance.

**Open the AWS Management Console, then type Rekognition in the search bar.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2a81w34bay1ot6jfz37o.png)

### Analyze Faces

To start, select Facial analysis in the panel navigation on the left. This feature allows you to analyze faces in an image and receive a JSON response.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39291pg1wqxuxp5kuafr.png)

- Open and save the first sample image for this tutorial [here](https://d1.awsstatic.com/tmt/detect-analyze-faces-rekognition/detect-analyze-faces-rekognition-sample1.14b4e29a5f7a246639b1694612931acf9a45e752.jpg).

**NOTE:** For the reasons of copyright, we will be using images from the AWS sample and not random images online.

- Click the Upload button and select the sample image you just saved.

- To the right side of the facial analysis, you can see the quick result for each face detected.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bc8xoeeqa4pgnwvh8hle.png)

### Compare Faces

In this stage, you'll utilize the face comparison feature to get the detailed JSON result from comparing two unrelated photographs.

Select  Face Comparison on the left panel.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5n3b7orn60xt31313sp1.png)

- Open and save the second sample image for this tutorial [here](https://d1.awsstatic.com/tmt/detect-analyze-faces-rekognition/detect-analyze-faces-rekognition-sample2.cc4e9e93d30d13eea75da8faed36ac66f6fce129.jpg).

- Click on the Upload button for the reference face and select the image you just saved.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bh50oz0ikmk0jrtgis0x.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/of3m85q9e7xjziovug3s.png)

- To view the JSON results, select the Response dropdown menu. It is worth noting that the "Similarity" score for each of the identified faces is never more than 1.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecawryucnc8uwb0avnvh.png)

### Compare Faces Again

In this phase, you'll use the face comparison feature to get the detailed JSON result from comparing two photographs that match.

- Open and save the third and final sample image for this tutorial [here](https://d1.awsstatic.com/tmt/detect-analyze-faces-rekognition/detect-analyze-faces-rekognition-sample3.5b5c31997920aba8eff612d6f2a8829eefdb20ea.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddysrwy75380k6a25s4f.png)

- Take note that the reference face that matched our other photo had a 99% similarity score and determined that none of the other faces was a match.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czxl2etjlqzkktz69qqk.png)

- Click on the Response dropdown to see the details of each comparison.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psu5xr5cl6diifyiikrq.png)