Object Detection using Amazon Rekognition

Hello guys,

I hope you all are pink in your health.

Today I am going to present you a cloud project that can detect objects from image using Amazon Rekognition.

INTRODUCTION

Amazon Web Services(AWS) is a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow.

Why we have used Amazon Rekognition?

Amazon Rekognition makes it easy to add image and video analysis to your applications using proven, highly scalable, deep learning technology that requires no machine learning expertise to use. With Amazon Rekognition, you can identify objects, people, text, scenes, and activities in images and videos, as well as detect any inappropriate content. Amazon Rekognition also provides highly accurate facial analysis and facial search capabilities that you can use to detect, analyze, and compare faces for a wide variety of user verification, people counting, and public safety use cases.

Currently the application is under development. And eventually we are going to create an server less web application on AWS that uses different AWS services for making it working.

How we are deploying resources on AWS:

We are using AWS CDK for defining our cloud application resources. The AWS Cloud Development Kit (AWS CDK) is an open source software development framework to define your cloud application resources using familiar programming languages that are Python, Java, TypeScript, JavaScript, C#. We have used TypeScript for deploying our resources. We need to create the Cloud Formation stack that contains all the services and their functionalities.
We need to import all the dependent packages that are used for different services. When we synthesize the stack, it will create the full canonical form of Cloud Formation stack. When we deploy the stack, AWS Cloud Formation provisions and configures the resources we specified on our template and deploys them on cloud.

Architecture of the application

Architectural overview of application

The architecture that is shown above is server less that is we do not need to manage any servers rather we can focus on building our application. The architecture is also decoupled.

The website is hosted in Amazon S3 bucket that is used to store objects and also for static website hosting. The website uses Amazon Cognito for creating new users from user pool. Using user pool, the users can sign in to the web or mobile app through Amazon Cognito. Amazon Cognito identity pools provide temporary AWS credentials for users of user pool. An identity pool is a store of user identity data specific to provide access to resources that are intended to be accessed by corresponding user.

As soon as the user uploads a image in S3 bucket, a Rekognition lambda function triggers and sends the image to Amazon Rekognition for object detection. Then the same lambda function is again triggered as the labels from image are generated and stores them in Amazon DynamoDB. The same lambda function generates a resized image of size of a thumbnail and stores it in a different S3 bucket, this thumbnail image is used to provide a insight to user that they are uploaded.

The API Gateway is the key service that is used for generating RESTFull API for all types request/response. The another Service lambda function is integrated with API Gateway for providing all request/response to user. The requests that user can make are: GET and DELETE. GET request for getting the object recognized by Amazon Rekognition and image itself and DELETE request for deleting the image that are previously uploaded by the user.
Amazon SQS is used for decoupling the architecture that is if any service fails due to any reason, the whole architecture don’t get affected by it.

Project implementation

Home page of Web Application
Users visiting first time need to Register

We have integrated AWS Cognito for providing temporary credentials every time a new user registers or a user logs in to his account, so that they can temporarily access the resources. Also we have kept some validation for security purposes like the password must have at least one special character, lower case, upper case and number. If a user forgot the password he can change it by selecting the forgot password option.

Verifying the user

For verifying that the user is authenticated, Amazon Cognito sends a verification One time password (OTP) to the users email address and after verifying, the user needs to log in for using the functionalities.

The user will be able upload images through this page

After Logging in, the user will now be able to upload any image without any problem. Also if a user has uploaded one more images he will be able to see all the images listed in table. By selecting a image, the user will be able to see more details on image like its name, last modified date and time and size of the image. If you want to delete a image, you can delete it by selecting the delete option.

User can view the identified object from the image

By visiting the your photos page, the user can view the image and the labels that are identified by the Amazon Rekognition from the image. For viewing the labels, user needs to press on the play button that is present on the screen. You can view all the images that you have uploaded previously. Also we have kept a zoom in functionality for better view of image.

Profile page of the particular user

On the profile page, the user can view his profile and also will be able to change his password in case he wanted to rotate the password. In the profile menu, the user can view the username and email address from which he had logged in.

Password Change option

By entering old password for verification of authenticated user and then entering the new password, a user can change his password. And also be able to change password if he forgets the password.

If you are curious and want to know what’s happening in back-end, here is a nice view of the AWS Management Console of different services that holds data in it and also holds very important place in the whole architecture.

AWS Cognito user pool

In the AWS Management Console, you can see all the users that are registered and different parameters available like Username, Account status, email address, email verification, account updated date and time and account created date and time.

S3 bucket view that holds the images

If you see carefully, you will be able to find that the cognito user id in above image is same as the cognito user id that can be seen in the profile menu picture. All the images are stored in a S3 bucket inside a folder again partitioned by a folder with name of user id and it is private so no other user can access some other users data. For better understanding, you see the file structure present at the top part of S3 console.

Amazon Dynamo DB table view

In this Management Console, you can see that the image is uploaded previously passed to the Amazon Rekognition through Amazon Lambda function and same Lambda function passes detected labels to the Dynamo DB table and stores them in it. You can also see all the labels are same that we seen in the frontend web application image.

Thank you for reading this.

Conclusion

Thank you for reading. Hope you enjoyed our project.
The contributors of this projects are:
Sunny Agrawal and Aghera Shyamkumar Bhupendrakumar.

Github Link:
https://github.com/SunnyAgrawal1208/ObjectDetection_Using_Amazon_Rekognition
https://github.com/agherashyam2000/ObjectDetection_Using_Amazon_Rekognition

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store