AWS AI Services-2: Hands-on use cases for Amazon Rekognition

Cumhur Akkaya
10 min readNov 6, 2023

In my previous article, we talked in detail about Artificial Intelligence (AI) and AWS AI Services. In this article, we will learn detailed information about Amazon Rekognition. Then, we will implement practical use cases for Amazon Rekognition; “Facial Analysis”, “Face Comparison”, “Personal Protective Equipment (PPE) Detection”, “Detect Labels From Image”, “Celebrity Recognition”, and “Text in Image (detecting vehicle plate information)”. We will do them practically and step by step.

Topics we will cover:

1. What is Amazon Rekognition?
2. Features of Amazon Rekognition
3. Common use cases for using Amazon Rekognition

4. Hands-on use cases for Amazon Rekognition:
4. a. Facial Analysis
4. b. Face Comparison
4. c. Personal Protective Equipment (PPE) Detection
4. d. Detect Labels From Image
4. e. Celebrity Recognition
4. f. Text in Image (detecting vehicle plate information)

5. Using Amazon Recognize via AWS CLI
6. As a result
7. Next post: “AWS AI Services-3: Building a Facial Recognition App By Using Amazon Rekognition, Lambda, DynamoDB, API Gateway, and S3”.
8. References

If you like the article, I will be happy if you click the Medium Follow button to encourage me to write more, and not miss future articles.

Your clapping, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

In our previous article “AWS AI Services-1: What are Artificial Intelligence (AI) and AWS AI Services?”, we talked in detail about Artificial Intelligence (AI) and AWS AI Services.

1. What is Amazon Rekognition?

Amazon Rekognition makes it easy to add image and video analysis to your applications. We provide an image or video to the Amazon Rekognition API, it can identify labels (objects, concepts, people, scenes, and activities) and text, and detect inappropriate content, or provide highly accurate facial analysis, face comparison, and face search capabilities. Also, with Amazon Rekognition’s face recognition APIs, we can detect, analyze, and compare faces for a wide variety of use cases, including user verification, cataloging, people counting, and public safety (1).

2. Features of Amazon Rekognition

Figure 2
  • Face Liveness: It detects real users and deters bad actors using spoofs in seconds during facial verification, as shown in Figure 2.
Figure 3
  • Face compare and search: It determines the similarity of a face against another picture or from your private image repository, as shown in Figure 3.
Figure 4
  • Face detection and analysis; it detects faces appearing in images and videos and recognizes attributes such as open eyes, glasses, and facial hair for each, as shown in Figure 4.
Figure 5
  • Content moderation; it detects potentially unsafe, inappropriate, or unwanted content across images and videos, as shown in Figure 5.
Figure 6
  • Custom labels: It detects custom objects such as brand logos using automated machine learning (AutoML) to train your models with as few as 10 images, as shown in Figure 6.
Figure 7
  • Text detection: It extracts skewed and distorted text from images and videos of street signs, social media posts, and product packaging, as shown in Figure 7.
Figure 8
  • Labels: It detects objects, scenes, activities, landmarks, dominant colors, and image quality, as shown in Figure 8.
Figure 9
  • Video segment detection: It detects key segments in videos, such as black frames, start or end credits, slates, color bars, and shots, as shown in Figure 9.
Figure 10
  • Celebrity recognition: It identifies well-known people to catalog photos and footage for media, marketing, and advertising, as shown in Figure 10.

3. Common use cases for using Amazon Rekognition

  • Searchable image and video libraries: Amazon Rekognition makes images and stored videos searchable so you can discover labels (objects, concepts, and scenes) that appear within them (1).
  • Face Liveness Detection: A user is physically present in front of the camera and isn’t a bad actor spoofing the user’s face. Using Rekognition Face Liveness can help you detect spoof attacks presented to a camera, such as printed photos, digital photos/videos, or 3D masks. It also helps detect spoof attacks that bypass a camera, such as pre-recorded or deepfake videos injected directly into the video capture subsystem.
  • Face-based user verification: Amazon Rekognition enables your applications to confirm user identities by comparing their live image with a reference image.
  • Facial detection and analysis: Amazon Rekognition can detect and analyze different facial components and attributes, such as; emotional expressions (like happy, sad, or surprised), demographic information (like gender or age), face occlusion (when a face’s eyes, nose, and/or mouth are blocked by dark sunglasses, masks, hands, etc), and eye gaze direction (as defined by pitch and yaw).
  • Facial Search: With Amazon Rekognition, you can search images, stored videos, and streaming videos for faces that match those stored in a container known as a face collection.
  • Unsafe content detection: Amazon Rekognition can detect adult and violent content in images and in stored videos. Developers can use the returned metadata to filter inappropriate content based on their business needs. Examples include social and dating sites, photo-sharing platforms, blogs and forums, apps for children, e-commerce sites, entertainment, and online advertising services.
  • Celebrity recognition — Amazon Rekognition can recognize celebrities within supplied images and in videos. Amazon Rekognition can recognize thousands of celebrities across a number of categories, such as politics, sports, business, entertainment, and media.
  • Text detection — Amazon Rekognition Text in Image enables you to recognize and extract textual content from images. It detects text and numbers in different orientations, such as those commonly found in banners and posters. In image sharing and social media applications, you can use it to enable visual search based on an index of images that contain the same keywords. In media and entertainment applications, you can catalog videos based on relevant text on screen, such as ads, news, sports scores, and captions. Finally, in public safety applications, you can identify vehicles based on license plate numbers from images taken by street cameras.
  • Custom labels– With Amazon Rekognition Custom Labels, you can identify the labels (objects and concepts) and scenes in images that are specific to your business needs. For example, you can find your logo in social media posts, identify your products on store shelves, classify machine parts in an assembly line, distinguish healthy and infected plants, or detect animated characters in videos.
  • Detection of Personal Protective Equipment: Amazon Rekognition detects Personal Protective Equipment (PPE) such as face covers, head covers, and hand covers on persons in images.

4. AWS Rekognition Tutorials:

4. a. Facial Analysis

Open the AWS Management Console, then type Rekognition in the search bar and select Rekognition to open the service console. Then, Click on the “Try Demo” button in the Amazon Rekognition window that opens, as shown in Figure 11.

Figure 11

In order to start, select “Facial Analysis” in the panel navigation on the left. Then, I chose a sample image, Amazon Recognize analyzed the image and showed the results of the Facial Analysis in the “Results” section, as shown in Figure 12.

Figure 12

Also, we can use our own image by clicking the“Upload or drag and drop”section, as shown in Figure 13.

Figure 13

Amazon Recognize analyzed the image and showed the results of the Facial Analysis in the “Results” section, as shown in Figure 14.

Figure 14

4. b. Face comparison

In order to start, select “Face comparison” in the panel navigation on the left. Then, I chose a sample “reference image”, and then chose a sample comparison faces” to compare faces.

Amazon Recognize analyzed the image and showed the results of the Face comparison in the “Results” section, as shown in Figure 15.

Figure 15

Note: If you want, you can use our own images by clicking the“Upload or drag and drop”section.

4. c. Personal Protective Equipment (PPE) detection

It automatically detect Personal Protective Equipment (PPE) such as face covers, head covers, and hand covers on persons in images.

In order to start, select “PPE detection” in the panel navigation on the left. Then, I chose a sample image, Amazon Recognize analyzed the image and showed the results of the PPE detection Analysis in the “Results” section, as shown in Figure 16.

Figure 16

4. d. Detect Labels From Image

In order to start, select “Label Dedection” in the panel navigation on the left. Then, I chose a sample image, as shown in Figure 17.

Figure 17

Amazon Recognize analyzed the image and showed the results of the labels in the “Results” section, as shown in Figure 18.

Figure 18

Also, we can use our image by clicking the“Upload or drag and drop”section, as shown in Figure 19.

Figure 19

The Recognize analyzed the image and showed the results of the labels in the “Results” section, as shown in Figure 20.

Figure 20

4. e. Celebrity recognition

Rekognition automatically recognizes celebrities in images and provides confidence scores (His/her names).

In order to start, select “Celebrity recognition” in the panel navigation on the left. Then, I chose a sample image, Amazon Recognize analyzed the image and showed the results of the Celebrity recognition Analysis in the “Results” section, as shown in Figure 21.

Figure 21

Also, I used my own images by clicking the“Upload or drag and drop”section. Amazon Recognize analyzed the image and showed the results of the Celebrity recognition Analysis in the “Results” section, as shown in Figure 22.

Figure 22

4. f. Text in image (detecting vehicle plate information)

Rekognition automatically detects and extracts text in your images.

In order to start, select “Text in image” in the panel navigation on the left. This time, I used our own image by clicking the“Upload or drag and drop”section, as shown in Figure 23.

Figure 23

Then, Amazon Recognize analyzed the image and it identified and showed us the vehicle license plate information in the “Results” section, as shown in Figure 24.

Figure 24

5. Using Amazon Recognize via AWS CLI

* For this section Properly configure your AWS access credentials (aws configure).

The following is an example AWS CLI command that’s a shorthand version of the JSON that works on both Microsoft Windows and Linux. (2) We can have the label analysis of our image in the S3 bucket with the following command. We did the same process on the AWS console in the “4. d. Detect Labels From Image” item.

aws rekognition detect-labels --image "S3Object={Bucket=photo-collection,Name=photo.jpg}" --region region-name

For this, we need to change the names of the S3 bucket and image in the command, according to our values at AWS cloud, as shown in Figure 25–26.

aws rekognition detect-labels --image "S3Object={Bucket=cumhurportfolio,Name=robot.jpg}" --region us-east-1
Figure 25

Amazon Recognize analyzed the image and showed the results of the label analysis in the terminal, as shown in Figure 26.

Figure 26

For more information, see the link.

6. As a result

In this article, we learned detailed information about Amazon Rekognition. We implemented practical use cases for Amazon Rekognition; “Facial Analysis”, “Face Comparison”, “Personal Protective Equipment (PPE) Detection”, “Detect Labels From Image”, “Celebrity Recognition”, and “Text in Image (detecting vehicle plate information)”. We did them practically and step by step.

If you liked the article, I would be happy if you click on the Medium Following button to encourage me to write and not miss future articles.

Your clapping, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

For more info and questions, please contact me on Linkedin or Medium.

7. Next post

In the next post, “AWS AI Services-3: Building a Facial Recognition App By Using Amazon Rekognition, Lambda, DynamoDB, API Gateway, and S3”, as shown in Figure 20.

Figure 25 - “AWS AI Services-2: Building a Facial Recognition App By Using Amazon Rekognition, Lambda, DynamoDB, API Gateway, and S3”

Happy Clouding…

Don’t forget to follow my Medium account to be informed about new articles.

--

--

Cumhur Akkaya

✦ DevOps/Cloud Engineer, ✦ Believes in learning by doing, ✦ Dedication To Lifelong Learning, ✦ Tea and Coffee Drinker. ✦ Linkedin: linkedin.com/in/cumhurakkaya