Amazon Rekognition – Image analysis as a Service

Amazon Rekognition: the new Image Analysis tool powered by Deep Learning

Amazon itself has been powered by Machine Learning technologies for almost two decades. AWS started releasing part of that powerful technology as a service, starting from Amazon Machine Learning, two years ago.
Just a few weeks ago, AWS announced the new P2 instance types (up to 16 GPUs) and a Deep Learning AMI. Less than a week ago, Amazon also announced their investment in MXNet, as their preferred Deep Learning framework.
During the first re:Invent 2016 Keynote, Andy Jassy announced a whole new set of services based on Deep Learning: Rekognition, Polly, and Lex.
Here is a recap of the main functionalities offered by Amazon Rekognition.

What is Amazon Rekognition?

Given the explosive growth of images in the past few years, the ability to search, verify, and organize millions of images will unlock a whole new set of possibilities. This is especially true because the technology is offered to everyone as a simple set of APIs. In 2017 alone, we expect that 1.2 trillion images will be taken.
Amazon Rekognition is a fully managed service that will allow you to extract information from images to make your application smarter and your customers’ experience better. Rekognition comes with built-in object and scene detection and facial analysis capabilities.
Also, because Amazon Rekognition is powered by deep learning, the underlying models will keep improving in accuracy over time, offering a better service in a transparent way.
A few more interesting details about Amazon Rekognition:

  • It allows both real-time and batch processing.
  • It’s already available in three AWS Regions (US East, US West, and EU West).
  • It includes a free tier of 5,000 images per month for the first 12 months of usage.
  • It’s already well integrated with S3, Lex, and Polly.
  • It does NOT store your images or any sensitive information contained in them, but only a vector representation of the images you upload, which is then used for indexing, search, etc.

The AWS Console looks nice and intuitive:
Amazon Rekognition Console Demo

Amazon Rekognition API Overview

So, what can you do with Amazon Rekognition?
The two main features allow you to detect objects and faces in any given picture.
Specifically, object and scene detection will provide a set of labels and concepts found in the image. On the other hand, facial analysis allows you to find, compare, and search faces.
Let’s recap each API.

DetectLabels

This API takes individual images as input and returns an ordered list of labels and a corresponding numeric confidence index.
As shown in the screenshot above, this API will return a given number of labels starting from the most certain (or confident). The JSON output will look something like the following:

{
    "Labels": [
        {
            "Confidence": 91.47468566894531,
            "Name": "City"
        },
        {
            "Confidence": 91.47468566894531,
            "Name": "Downtown"
        },
        {
            "Confidence": 91.47468566894531,
            "Name": "Metropolis"
        },
        {
            "Confidence": 91.47468566894531,
            "Name": "Urban"
        },
        {
            "Confidence": 56.20014190673828,
            "Name": "Building"
        }
    ]
}

In this case, the first four labels have a pretty high level of confidence – over 90% – while the fifth is only 56%. As I mentioned above, the list of labels is ordered by confidence and, in most cases, you can simply ignore labels below an arbitrary threshold.
Typical use cases for this API are smart search applications and automatic tagging. For example, you may want to implement dynamic search indexing with AWS Lambda and Elasticsearch, which generate newly indexed items each time a new file is loaded into S3.

DetectFaces

This API takes individual images as input and will detect the presence and location of faces. In addition to the face bounding box and landmarks, the API will also return a set of quality attributes about each face, such as detected emotions, gender, glasses, open or closed eyes, mustache, beard, smiling, etc.
Amazon Rekognition Face Detection
This API will return a JSON similar to the following:

{
    "FaceDetails": [
        {
            "Beard": {
                "Confidence": 97.11119842529297,
                "Value": false
            },
            "BoundingBox": {...},
            "Confidence": 99.8899917602539,
            "Emotions": [
                {
                    "Confidence": 93.29251861572266,
                    "Type": "HAPPY"
                },
                {
                    "Confidence": 28.57428741455078,
                    "Type": "CALM"
                },
                {
                    "Confidence": 1.4989674091339111,
                    "Type": "ANGRY"
                }
            ],
            "Eyeglasses": {
                "Confidence": 99.99998474121094,
                "Value": true
            },
            "EyesOpen": {
                "Confidence": 96.2729721069336,
                "Value": true
            },
            "Gender": {
                "Confidence": 100,
                "Value": "Female"
            },
            "Landmarks": [
                {
                    "Type": "eyeLeft",
                    "X": 0.23941855132579803,
                    "Y": 0.2918034493923187
                },
                {
                    "Type": "eyeRight",
                    "X": 0.3292391300201416,
                    "Y": 0.27594369649887085
                },
                {
                    "Type": "nose",
                    "X": 0.29817715287208557,
                    "Y": 0.3470197319984436
                },
                ...
            ],
            "MouthOpen": {
                "Confidence": 72.5211181640625,
                "Value": true
            },
            "Mustache": {
                "Confidence": 77.63107299804688,
                "Value": false
            },
            "Pose": {
                "Pitch": 8.250975608825684,
                "Roll": -8.29802131652832,
                "Yaw": 14.244261741638184
            },
            "Quality": {
                "Brightness": 46.077880859375,
                "Sharpness": 100
            },
            "Smile": {
                "Confidence": 99.47274780273438,
                "Value": true
            },
            "Sunglasses": {
                "Confidence": 97.63555145263672,
                "Value": true
            }
        }
    ]
}

Typical use cases for this API are photo recommendations based on facial attributes and sentiment analysis of in-store customers.

CompareFaces

This API is probably the most interesting, as it allows you to upload two images. The source image will contain one reference face, which will be compared to every face found in the second target image. For each target face, a Similarity Index will be computed.
Interestingly, the face comparison problem can be much harder for humans than for machines, unless you only consider your family and close friends. Outside a person’s close circle of friends or ethic group, comparing faces becomes more difficult.
Amazon’s deep learning model, on the other hand, has been trained on a huge dataset of images that contains faces of different qualities, sizes, distortion conditions, and ethnic groups, which gives it an impressive 98% average accuracy.
Amazon Rekognition Face Comparison
The API will return a JSON similar to the following:

{
    "FaceMatches": [
        {
            "Face": {
                "BoundingBox": {...},
                "Confidence": 99.99597930908203
            },
            "Similarity": 92
        },
        {
            "Face": {
                "BoundingBox": {...},
                "Confidence": 99.97322845458984
            },
            "Similarity": 0
        },
        {
            "Face": {
                "BoundingBox": {...},
                "Confidence": 99.94225311279297
            },
            "Similarity": 0
        }
    ],
    "SourceImageFace": {
        "BoundingBox": {...},
        "Confidence": 99.93081665039062
    }
}

Typical use cases for this API are face-based verification (i.e. seamless access for hotel rooms, online exam identification, etc.) and person localization for public safety.

IndexFaces, SearchFacesByImage, and SearchFacedByID

This set of APIs allows you to build a searchable collection of faces and then query this index either by image or by ID.
Once you have uploaded a large set of images, AWS will extract facial information and build a searchable index. You can query this index by uploading a face image, and Amazon Rekognition will return all of the original images where the given face was found. Also, you can query the index by ID, which is the unique identifier associated with the vector representation of a face. You may want to use such an index to map between these IDs and the input images since Amazon Rekognition will NOT store any image you upload and you will probably need to map IDs back to the original face image.
Please note that you won’t need to call IndexFaces and DetectFaces separately, as you can directly obtain the same facial features by invoking IndexFaces with a special parameter.

Conclusion

Amazon Rekognition looks great. It is a fully managed and highly scalable service that offers advanced image analysis functionalities in a secure and low-cost fashion.
Earlier this year, I wrote about the Google Vision API, and I am definitely looking forward to performing some benchmarks. However, it already looks like Amazon’s solution comes with more advanced features from day one.
Let us know what you think of Amazon Rekognition and how you’re going to use it in production. Also, stay tuned for more exciting announcements during today’s second Keynote at AWS re:Invent 2016.

Written by

Alex is a Software Engineer with a great passion for music and web technologies. He's experienced in web development and software design, with a particular focus on frontend and UX.

Related Posts

— November 28, 2018

Two New EC2 Instance Types Announced at AWS re:Invent 2018 – Monday Night Live

Let’s look at what benefits these two new EC2 instance types offer and how these two new instances could be of benefit to you. Both of the new instance types are built on the AWS Nitro System. The AWS Nitro System improves the performance of processing in virtualized environments by...

Read more
  • AWS
  • EC2
  • re:Invent 2018
— November 21, 2018

Google Cloud Certification: Preparation and Prerequisites

Google Cloud Platform (GCP) has evolved from being a niche player to a serious competitor to Amazon Web Services and Microsoft Azure. In 2018, research firm Gartner placed Google in the Leaders quadrant in its Magic Quadrant for Cloud Infrastructure as a Service for the first time. In t...

Read more
  • AWS
  • Azure
  • Google Cloud
Khash Nakhostin
— November 13, 2018

Understanding AWS VPC Egress Filtering Methods

Security in AWS is governed by a shared responsibility model where both vendor and subscriber have various operational responsibilities. AWS assumes responsibility for the underlying infrastructure, hardware, virtualization layer, facilities, and staff while the subscriber organization ...

Read more
  • Aviatrix
  • AWS
  • VPC
— November 10, 2018

S3 FTP: Build a Reliable and Inexpensive FTP Server Using Amazon’s S3

Is it possible to create an S3 FTP file backup/transfer solution, minimizing associated file storage and capacity planning administration headache?FTP (File Transfer Protocol) is a fast and convenient way to transfer large files over the Internet. You might, at some point, have conf...

Read more
  • Amazon S3
  • AWS
— October 18, 2018

Microservices Architecture: Advantages and Drawbacks

Microservices are a way of breaking large software projects into loosely coupled modules, which communicate with each other through simple Application Programming Interfaces (APIs).Microservices have become increasingly popular over the past few years. The modular architectural style,...

Read more
  • AWS
  • Microservices
— October 2, 2018

What Are Best Practices for Tagging AWS Resources?

There are many use cases for tags, but what are the best practices for tagging AWS resources? In order for your organization to effectively manage resources (and your monthly AWS bill), you need to implement and adopt a thoughtful tagging strategy that makes sense for your business. The...

Read more
  • AWS
  • cost optimization
— September 26, 2018

How to Optimize Amazon S3 Performance

Amazon S3 is the most common storage options for many organizations, being object storage it is used for a wide variety of data types, from the smallest objects to huge datasets. All in all, Amazon S3 is a great service to store a wide scope of data types in a highly available and resil...

Read more
  • Amazon S3
  • AWS
— September 18, 2018

How to Optimize Cloud Costs with Spot Instances: New on Cloud Academy

One of the main promises of cloud computing is access to nearly endless capacity. However, it doesn’t come cheap. With the introduction of Spot Instances for Amazon Web Services’ Elastic Compute Cloud (AWS EC2) in 2009, spot instances have been a way for major cloud providers to sell sp...

Read more
  • AWS
  • Azure
  • Google Cloud
— August 23, 2018

What are the Benefits of Machine Learning in the Cloud?

A Comparison of Machine Learning Services on AWS, Azure, and Google CloudArtificial intelligence and machine learning are steadily making their way into enterprise applications in areas such as customer support, fraud detection, and business intelligence. There is every reason to beli...

Read more
  • AWS
  • Azure
  • Google Cloud
  • Machine Learning
— August 17, 2018

How to Use AWS CLI

The AWS Command Line Interface (CLI) is for managing your AWS services from a terminal session on your own client, allowing you to control and configure multiple AWS services.So you’ve been using AWS for awhile and finally feel comfortable clicking your way through all the services....

Read more
  • AWS
Albert Qian
— August 9, 2018

AWS Summit Chicago: New AWS Features Announced

Thousands of cloud practitioners descended on Chicago’s McCormick Place West last week to hear the latest updates around Amazon Web Services (AWS). While a typical hot and humid summer made its presence known outside, attendees inside basked in the comfort of air conditioning to hone th...

Read more
  • AWS
  • AWS Summits
— August 8, 2018

From Monolith to Serverless – The Evolving Cloudscape of Compute

Containers can help fragment monoliths into logical, easier to use workloads. The AWS Summit New York was held on July 17 and Cloud Academy sponsored my trip to the event. As someone who covers enterprise cloud technologies and services, the recent Amazon Web Services event was an insig...

Read more
  • AWS
  • AWS Summits
  • Containers
  • DevOps
  • serverless