AWS Face Recognition
AWS Face Recognition
AWS Face Recognition
Amazon Web
Services offers
reliable, scalable, and
inexpensive cloud
computing services. In
this project I will be
building a Face
Detection Application
on AWS.
K G PRAJWAL
Student, DSU, Bengaluru 76
AWS face recognition project
By Ethnus
DAY 1 – EC2
Keys
Public and Private
Public - Server --> instance
Private - Upload while connecting to the server
Download PuTTY
PuTTY - . ppk => .pem
Getting connected
1. Convert .pem to .ppk using puttygen command
puttygen KEYFILE.pem -o KEYFILE.ppk
Save the .ppk file
2. Open up PuTTY Software and select SSH and Port No: 22 and paste the IP address
from AWS Console
Go to SHH -> Auth
Browse the .ppk file and hit open
login as: ec2-user
Rekognition
1. Terminate
2. Reboot
3. Stop
On termination of the instance, by default the storage(EBS – Elastic Block Storage) will also be deleted.
Availability Zones – An actual place where data centre exists. Every region has minimum two availability
zones.
S3 Tiering:
1. Amazon S3 Standard
2. Amazon S3 Standard-Infrequent Access
3. Amazon S3 One Zone-Infrequent Access
4. Amazon S3 Glacier
DAY 3 – VPC
VPC = Virtual Public Cloud
VPC lets us provision a logically isolated section of the AWS Cloud where we can launch AWS resources in a
virtual network that we define.
CIDR – Classless inter-domain routing: is a set of IP standards that is used to create unique identifiers for
networks and individual devices.
Because there are groups inside our workplace where a single network has to divided into multiple networks
using the process called subnetting to create subnets.
Ex:
TestB – IAM User – Check the EC2 Instances. -> Testers Group
Steps:
1. Create an AWS Instance and generate the .ppk file from the downloaded .pem file.
2. Login to the instance using PuTTY.
3. Install php using ‘sudo yum install php’
5. cd /var/www/html
6. sudo mkdir face
7. cd face
8. Install AWS SDK using ‘sudo php -d memory_limit=-1 ~/composer.phar require aws/aws-sdk-php’
9. sudo wget https://i.pinimg.com/originals/b9/7e/a3/b97ea33b5842c7894b804923c6c05580.jpg
10. sudo mv b97ea33b5842c7894b804923c6c05580.jpg sample.jpg
11. sudo vim index.php
12. index.php:
<?php
/*
*/
error_reporting(0);
require_once(__DIR__ . '/vendor/autoload.php');
use Aws\S3\S3Client;
use Aws\Rekognition\RekognitionClient;
$s3 = S3Client::factory([
'profile' => 'default',
'region' => 'us-east-2',
'version' => '2006-03-01',
'signature' => 'v4'
]);
try {
// Upload data.
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => __DIR__. "/$keyname",
'ACL' => 'public-read'
]);
Login
EC2
S3
Make Public
PuTTY
Amazon Rekognition
Day 4:
Change content of index.php to:
<?php
/*
Incase if you are getting any class NOT found error, follow these steps
*/
// error_reporting(0);
require_once(__DIR__ . '/vendor/autoload.php');
use Aws\S3\S3Client;
use Aws\Rekognition\RekognitionClient;
$bucket = 'aws-face-recognition';
$keyname = 'sample.jpg';
try {
// Upload data.
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $keyname,
'SourceFile' => __DIR__. "/$keyname",
'ACL' => 'public-read-write'
]);
// Print the URL to the object.
$imageUrl = $result['ObjectURL'];
if($imageUrl) {
echo "Image upload done... Here is the URL: " . $imageUrl;
$result = $rekognition->detectFaces([
'Attributes' => ['DEFAULT'],
'Image' => [
'S3Object' => [
'Bucket' => $bucket,
'Name' => $keyname,
'Key' => $keyname,
],
],
]);
url_to_send_updates_to = IP/face/index.php