Skip to main content
TUTORIAL

Detect, Analyze, and Compare Faces with Amazon Rekognition

Introduction

Overview

In this tutorial, you will learn how to use the face recognition features in Amazon Rekognition using the AWS Management Console. Amazon Rekognition is a deep learning-based image and video analysis service.

As a developer, you might face the challenge of facial recognition and comparison if you are developing an employee verification system, or need to automate video editing or provide secondary authentication for other applications. To solve this, you could develop your own machine learning model, develop an API, and manage your own infrastructure. This option is expensive, requires advanced knowledge, and is time intensive.

An easier route is to use Amazon Rekognition, which can detect faces in an image or video, find facial landmarks such as the position of eyes, and detect emotions such as happy or sad in near-real time or in batches without management of infrastructure or modeling.

In this tutorial, you will use Amazon Rekognition to analyze an image and then compare it to other images to see if the faces are the same.

This tutorial is a demo of the functionality that is available when using the AWS CLI or the Rekognition API. For production or proof of concept implementations, we recommend using these programmatic interfaces rather than the Amazon Rekognition console.

Implementation

Beginner

10 minutes

Free Tier eligible

July 11, 2022

Enter the Amazon Rekognition console

1. Open the console

Open the AWS Management Console, so you can keep this step-by-step guide open. When the screen loads, enter your user name and password to get started. Then type Rekognition in the search bar and select Rekognition to open the service console.

Missing alt text value

Analyze faces

In this step, you will use the facial analysis feature in Amazon Rekognition to see the detailed JSON response you can receive from analyzing one image.

1. Select Facial analysis

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.

Missing alt text value

2. Save the first sample image

Open and save the first sample image for this tutorial here.

Portrait of happy multi-generation family sitting on sofa in living room at home

3. Upload sample image

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

Missing alt text value

4. Review the quick results

Notice that under the Results dropdown, you can click through and see quick results for each face that was detected.

Missing alt text value

5. Open the Response dropdown

Click on the Response dropdown to see the JSON results.

Missing alt text value

6. View the JSON results

Notice that under the emotions results, there are numerous detected emotions. Happy has a 99.98% confidence rating.

As a developer, detecting emotions in images and videos makes it possible to quickly catalog a digital library by emotion. Another use case for detecting emotions is to amplify ad targeting so users receive a personalized experience tailored to the current emotion.

Missing alt text value

Compare faces

In this step, you will use the face comparison feature to see the detailed JSON response from comparing two different images that don't match.

1. Select Face comparison

Select Face comparison in the panel navigation on the left.

Missing alt text value

2. Save second sample image

Open and save the second sample image for this tutorial here.

Missing alt text value

3. Upload the reference face image

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

Missing alt text value

4. Select first reference image

Click on the orange Upload button for the comparison face and select our first sample image we used in step 2.

Missing alt text value

5. Review the Results

Notice that in Results dropdown you can see that our reference wasn’t a match for any of the detected faces in our comparison faces image.

Missing alt text value