Voiced by Amazon Polly |
Overview
Facial recognition technology has made significant strides in accuracy and precision, with services like Amazon Rekognition that maintain collections of known users. By comparing detected faces against these user collections, the service enhances identification accuracy and minimizes the occurrence of false positives or false negatives. This approach streamlines the organization and management of facial data, particularly when dealing with extensive datasets, ensuring structured and easily accessible user information.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Introduction
Amazon Rekognition is a cloud-based service provided by Amazon Web Services (AWS) that offers advanced facial recognition capabilities. It leverages artificial intelligence and deep learning technologies to analyze images and videos for the presence of faces and to extract valuable information from them. User collections simplify handling vast facial data by providing an organized framework. Amazon Rekognition allows users to search a collection for a specific face or identify individuals by comparing a detected face against the faces stored in a collection.
Understanding Collections and User
A Collection in Amazon Rekognition is a database where you can store the faces in an image. It’s used for recognizing and searching for faces within a specific group or set of individual faces. The maximum number of faces that can be stored in a collection is 20 million.
A User can be created in the collection by passing the collection name to the API request. Users are used for person-specific recognition and authentication. When a detected face is matched to a user’s face in a collection, it verifies the identity of that individual.
Why do we use User instead of Collection?
While indexing the image with multiple faces, the IndexFaces API should be called first. The API returns the unique faceIDs for those faces in that image, and those faceIDs will be stored in the collection automatically. By default, the IndexFace API returns unique faceIDs each time for each face. So, there is a problem that comes here in this collection is to identify the faces of the individual people with the faceIDs.
To overcome the above issue, we can create the User in the same collection and store the faceIDs of the same person directly to the User by calling CreateUser API and AssociateFaceToUser API instead of a collection. With the user, we can easily identify the faces of the person by calling SearchFacesByUser API.
How to Use Amazon Rekognition on Image: Creating Collections, Indexing Faces, and Assigning Users
- Create a collection with a unique name and follow the same below.
1 2 3 4 5 |
import boto3 client = boto3.client("rekognition",region_name='ap-south-1') response = client.create_collection(CollectionId="Testing") print(response['CollectionArn']) |
- Create a User with the random UUID in the same collection
1 2 3 4 5 6 7 8 9 10 |
import boto3 import uuid client = boto3.client("rekognition",region_name='ap-south-1') user_id=str(uuid.uuid4()) response=client.create_user( CollectionId="Testing", UserId=user_id ) print(response["Users"]) |
- Now, Invoke the IndexFace API on the above image and upload the same image in the Amazon S3 bucket.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import boto3 from boto3.exceptions import Boto3Error import json client = boto3.client("rekognition",region_name='ap-south-1') response = client.index_faces( CollectionId="Testing", Image={ 'S3Object': { 'Bucket': bucket, 'Name': "sample.jpg", } }, DetectionAttributes=['ALL'], MaxFaces=10, QualityFilter='HIGH' ) for faceRecord in response['FaceRecords']: print('Face ID: ' + faceRecord['Face']['FaceId']) |
The above code will provide the faceIds indexed from the IndexFace API on the image having 3 faces of 3 different persons. Below is the response from the above code.
1 2 3 |
Face ID: "a6823cad-7eb0-4a8a-898a-bf143bfe25be" Face ID: "c500284e-253e-47a9-a9fb-adad2833ef03" Face ID: "b2b61313-5caa-4749-a024-c204ad68a50c" |
- Follow the above 2nd step to create three different users as 3 different faces indexed of different persons and follow the below for associating the faces to each user separately.
1 2 3 4 5 6 7 |
def associate_faces(face_id,user_id): response = rek_client.associate_faces( CollectionId="Testing", UserId=user_id, FaceIds=face_id ) return response |
- We can know which faceIDs are associated with which Users by calling the ListFaces API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
{ 'Faces': [ { 'FaceId': '8ac46ff1-cb56-49aa-b420-c2d29cb533c1', 'BoundingBox': { 'Width': 0.20243099331855774, 'Height': 0.5413429737091064, 'Left': 0.06817259639501572, 'Top': 0.18429699540138245 }, 'ImageId': '2dd759a0-ae08-31c7-b561-c690cdc0b8a7', 'ExternalImageId': 'sample.jpg', 'Confidence': 99.99800109863281, 'IndexFacesModelVersion': '6.0', 'UserId': '9aab7144-7b4b-4071-b384-5676e97ff692' }, { 'FaceId': '9ad9ce26-0962-4716-8d53-399400512873', 'BoundingBox': { 'Width': 0.2823359966278076, 'Height': 0.6622650027275085, 'Left': 0.14223499596118927, 'Top': 0.2119469940662384 }, 'ImageId': '2bc3a69b-2ff8-32e0-ad90-474c825abda3', 'ExternalImageId': 'sample.jpg', 'Confidence': 100.0, 'IndexFacesModelVersion': '6.0' } |
In the above sample response of ListFaces API, if the faceIDs are associated with a User, then UserId will be added to the response. The UserId key won’t be in the response if it’s not associated. In this way, we can identify the person as a User with different faceIDs or different poses of the same person.
Conclusion
In this approach, Users represent specific individuals’ persons, each associated with their unique facial image within a collection.
Drop a query if you have any questions regarding Amazon Rekognition and we will get back to you quickly.
Making IT Networks Enterprise-ready – Cloud Management Services
- Accelerated cloud migration
- End-to-end view of the cloud environment
About CloudThat
CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery 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.
To get started, go through our Consultancy page and Managed Services Package, CloudThat’s offerings.
FAQs
1. What is the maximum number of faces that can be associated with a User?
ANS: – The maximum number of faces associated with a User is 100 faces only.
2. What about the pricing of this service?
ANS: – It follows a pay-as-you-go pricing model, and it depends on the number of API calls on images.
WRITTEN BY Sridhar Andavarapu
Sridhar works as a Research Associate at CloudThat. He is highly skilled in both frontend and backend with good practical knowledge of various skills like Python, Azure Services, AWS Services, and ReactJS. Sridhar is interested in sharing his knowledge with others for improving their skills too.
Click to Comment