0% found this document useful (0 votes)
57 views15 pages

AWS Discovery Day - Image Recognition Handout

This document provides instructions for building a facial recognition application on AWS. It involves creating an EC2 instance with an IAM role to access Rekognition, connecting to the instance, installing Node.js and the application code, and configuring security groups to allow access on port 3000. The application uses Rekognition's API to detect labels and facial attributes in uploaded images. Screenshots and useful resources are also included.

Uploaded by

Divya Prasoona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views15 pages

AWS Discovery Day - Image Recognition Handout

This document provides instructions for building a facial recognition application on AWS. It involves creating an EC2 instance with an IAM role to access Rekognition, connecting to the instance, installing Node.js and the application code, and configuring security groups to allow access on port 3000. The application uses Rekognition's API to detect labels and facial attributes in uploaded images. Screenshots and useful resources are also included.

Uploaded by

Divya Prasoona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

AWS Masterclass Series

In association with NASSCOM FutureSkills Prime

Discovery Day Handout


OCTOBER 2022
2

DISCLAIMER 3

Image and Facial Analysis Demo Overview 4

Pre-requisites 5

Keywords 5

AWS Services Used 5

Resources Used 7

Frameworks/Libraries Used 7

Steps Overview 8

Steps to Build the App 9


Step 1: Create an EC2 instance and an IAM role 9
Step 2: Connect to the EC2 Instance 11
Step 3: Install Node.js and Setup the Application 11
Step 4: Finish 13

Screenshots 14

Useful Resources 15
3

DISCLAIMER
You might be billed for using the services on AWS for creating, using, distributing, or
evaluating this demo on your cloud provider accounts. To avoid charges while on the
AWS Free Tier, you must keep your usage below the AWS Free Tier limits.

You will be charged for any usage that exceeds the limits. To help you stay within the
limits, you can track your AWS Free Tier usage and set a billing alarm to notify you if
you start incurring charges. For tips about avoiding unexpected charges, see Avoiding
unexpected charges.

Contact AWS Support if you require additional explanation of unexpected charges on


your bill. In addition to any usage fees might incur, you are responsible for paying any
internet or other telecommunications charges that you may incur by accessing the
AWS services or using the services available on it.

Ethnus or Codemithra will not be responsible for any cost incurred by you in any case.
We encourage students to consciously manage their resources and monitor their
costs. Ultimately you are responsible for managing your resources and therefore your
costs.
4

Image and Facial Analysis Demo Overview


The scope of the demo is to build an application that provides us with a simple frontend (built
using HTML and Bootstrap) to upload an image, a server running on EC2 - a virtual server on
AWS, Amazon Rekognition - a powerful Machine Learning service on AWS.

The image analysis recognizes and lists the labels of an image - attribute (Ex. Scenery, Dance,
Electronics, etc) and some facial attributes (if any) of the uploaded image.
5

Pre-requisites
To deploy the sample application you will require an AWS account. If you don’t already have an
AWS account, create one at https://aws.amazon.com by following the on-screen instructions.
Your access to the AWS account must have IAM permissions to launch the services that are
used in this demo. To use the sample application you will require a modern browser.

Keywords
Javascript, Express, Node.js, Amazon Web Services, Machine Learning, AWS SDK, AWS
Rekognition, Face Detection, Image Detection, AWS IAM

AWS Services Used


● Amazon EC2 - Amazon Elastic Compute Cloud (Amazon EC2) is a web service that
provides secure, resizable compute capacity in the cloud. It is designed to make
web-scale cloud computing easier for developers. Amazon EC2’s simple web service
interface allows you to obtain and configure capacity with minimal friction. It provides
you with complete control of your computing resources and lets you run on Amazon’s
proven computing environment. Amazon EC2 offers the broadest and deepest compute
platform with choice of processor, storage, networking, operating system, and purchase
model. We offer the fastest processors in the cloud and we are the only cloud with 400
Gbps ethernet networking. We have the most powerful GPU instances for machine
learning training and graphics workloads, as well as the lowest cost-per-inference
instances in the cloud.

● 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
6

compare faces for a wide variety of user verification, people counting, and public
safety use cases.

● Amazon VPC - Amazon Virtual Private Cloud (Amazon VPC) is a service that lets you
launch AWS resources in a logically isolated virtual network that you define. You have
complete control over your virtual networking environment, including selection of your
own IP address range, creation of subnets, and configuration of route tables and network
gateways. You can use both IPv4 and IPv6 for most resources in your virtual private
cloud, helping to ensure secure and easy access to resources and applications.

● AWS Identity and Access Management (IAM) - AWS Identity and Access Management
(IAM) enables you to manage access to AWS services and resources securely. Using
IAM, you can create and manage AWS users and groups, and use permissions to allow
and deny their access to AWS resources. IAM is a feature of your AWS account offered
at no additional charge. You will be charged only for use of other AWS services.
7

Resources Used
● index.html: Markup for the static application

https://awsmc-dd.s3.ap-south-1.amazonaws.com/index.html

● index.js: Javascript logic for making API calls to the backend

https://awsmc-dd.s3.ap-south-1.amazonaws.com/index.js

● server.js: Backend logic which invokes the Amazon Rekognition service on the user’s

behalf

https://awsmc-dd.s3.ap-south-1.amazonaws.com/server.js

● package.json: Dependency list for server.js

https://awsmc-dd.s3.ap-south-1.amazonaws.com/package.json

Frameworks/Libraries Used
● Bootstrap v5

Bootstrap is a free and open-source framework for building the front end of the
application.

Learn More: https://getbootstrap.com/

● aws-sdk v2 for Javascript

aws-sdk allows our application to access the AWS services on our behalf.

Example: Listing all the buckets in our S3 account

Learn More: https://docs.aws.amazon.com/sdk-for-javascript


8

● Express

A node.js framework to serve our application and to provide API endpoints for the
frontend to invoke the functions to detect the labels and the facial expressions.

Steps Overview
● Go to https://aws.amazon.com/console/
● Create an EC2 Instance (server) on AWS
● Configure the OS, Instance Type, Storage, Security, and other settings for your EC2
Instance.
● Assign permissions (through the IAM role) to your EC2 instance to access the Amazon
Rekognition service.
● Launch the instance.
● Connect to the instance.
● In the terminal, type all the necessary commands, and once processed, your application
will be ready to use.
● Copy the public IP address of your EC2 Instance and paste it into the new tab in the
format <public ip>:3000 Example: http://13.107.178.22:3000
● You will be able to see the application running.
● Try uploading different images and inspect the response.
9

Steps to Build the App


Step 1: Create an EC2 instance and an IAM role

1. Go to https://aws.amazon.com/console/
2. After logging in, Navigate to the Console and select “EC2” from the services dropdown.
3. Click on “Launch Instance”
4. Select Amazon Linux 2 AMI (HVM), SSD Volume Type as the AMI
5. Select t2.micro type of instance and click on “Next: Configure Instance Details”
6. On this page (configure instance details or Step 3), we create an IAM role that gives
permissions to the EC2 to access the AWS Rekognition service on your behalf. Click on
“Create a new IAM role”
7. A new tab would be opened. Navigate to the new tab and click on on “Create Role”
8. Under “Choose a use case”, click on EC2 which would be under “Common use cases”
9. Now, we should attach the relevant permissions to our role. Search for
AmazonRekognitionFullAccess and tick the box so that it will be attached to our role.
10. Click next and here you can optionally add tags.
11. Click next and assign a name to the role. I am going to assign the name as
“aws-rekog-1”. Give a description and click “Create Role”.
12. Navigate to the previous tab, and click on the refresh button near “Create new IAM role”

13. Select the role that you just created. In my case it is aws-rekog-1. Now the IAM role
field should look like this.

14. Click on “Next: Add Storage” and after that “Next: Add Tags” and then “Next: Configure
Security Groups”. We will leave Storage and Tags as defaults.
15. In the security groups, Click on add a new rule and let the type of the new rule be
“Custom TCP Rule”. Fill in the rule and finally, the rules should look as follows.
10

16. The new rule is going to allow us to access the EC2 instance from anywhere. We would
be using the port number 3000 to host our application, but you can use any port number
greater than 1024.
17. Click “Review and Launch”. Review your configuration and click on Launch.
18. A pop-up window will appear. Fill the form as below:

19. You can give any name to your key pair. Download the key pair and keep it safe. After
that click on Launch Instances.
NOTE: You can also proceed without creating a key pair for this demo.
11

Step 2: Connect to the EC2 Instance

1. After the EC2 instance is created, connect to the EC2 instance by clicking on the
“Connect” button. This will open an SSH connection to the EC2 instance.
2. A terminal should appear like shown below

Step 3: Install Node.js and Setup the Application

1. Install Node.js by executing the following commands in the terminal

curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash

sudo yum install -y nodejs

2. Execute the following commands:

mkdir app

cd app

mkdir public && mkdir server

cd public

wget https://awsmc-dd.s3.ap-south-1.amazonaws.com/index.html

wget https://awsmc-dd.s3.ap-south-1.amazonaws.com/index.js

cd ..
12

cd server

wget https://awsmc-dd.s3.ap-south-1.amazonaws.com/package.json

wget https://awsmc-dd.s3.ap-south-1.amazonaws.com/server.js

npm install

3. In point 4, steps a-c create the directories. Steps d-f involve navigating to the folder
“public” and downloading index.html and index.js. Steps g-h involve navigating to the
folder server and downloading package.json and server.js. Package.json contains the
dependencies required by server.js. On doing npm install, those dependencies will be
installed
4. Execute the following command in the terminal

node server.js

5. The above command will start the server and the terminal should look like below
13

Step 4: Finish

1. You can find out the Public IP address of your EC2 Instance on the bottom left of the
terminal window. OR you can find the Public IP address of the EC2 instance in the EC2
Management Console. On selecting the newly created instance, the public IP address
will be shown in the properties of the selected EC2 instance.
2. Navigate to the browser and type the following:-

http://<IP_ADDDRESS>:3000

NOTE: The <IP_ADDDRESS> will be the IP address that you found in the previous step.
Example: http://13.107.178.22:3000

3. You would be able to see the webpage now. Congratulations! You have a working Image
recognizer and the power of deep learning at your disposal.
14

Screenshots
15

Useful Resources
● How do I create and activate a new AWS account?
● What is the AWS Free Tier, and how do I use it?
● How do I make sure I don't incur charges when I'm using the AWS Free Tier?
● I unintentionally incurred charges while using the AWS Free Tier. How do I make sure
that I'm not billed again?
● Avoiding unexpected charges while using AWS
● What should I do if I didn't receive a call from AWS to verify my new account?

Link to this document: https://ethnus.link/awsddhandout

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy