DEV Community

loading...
Cover image for Face Recognition System for provisioning AWS instance using Terraform scripts and generating Mail & WhatsApp alerts

Face Recognition System for provisioning AWS instance using Terraform scripts and generating Mail & WhatsApp alerts

Sri Vishnuvardhan A
A Tech Enthusiast who loves to learn & integrate multiple technologies and keen to find the innovative solution of it to solve the existing challenges!!
Updated on ・3 min read

In this article, We are going to know how to create a face recognition system by CV2 and use it for performing some automation tasks in Real-time such as Provisioning AWS instance and its dependencies such as VPC, Subnet, Security Groups, Route tables, Internet Gateway, and 5GB EBS Volume which is done by triggered Terraform scripts.

We are also going to know how to generate Whatsapp and Email alerts when our face is recognized using Python.

Technologies used: Python CV2 and Terraform

Contents Overview:

  • Model1

    • Data Collection
    • Model Training
    • Face Recognition
    • Running Terraform Scripts to provision AWS Instance
  • Model2

    • Data Collection
    • Model Training
    • Face Recognition
    • Generating WhatsApp and Email Alerts

Data Collection

First step of in Machine Learning world is always a Data Collection. Without data, nothing can be achieved. In this step, we are going to collect 100 samples of my face with the size of 200 x 200 pixels and stored in the folder named as Vishnu.
11

This folder name is crucial because this folder name will be our Object name/face name for our model in future. So, give Human name to your folder.

Here, We are going to use haarcascade_frontalface_default.xml file as a face detector.

Model Training

In this phase, model is created using LBPHFaceRecognizer algorithm and the model is trained to recognize my face whenever my face appears in real time in video or appear in image.

Finally, the model is created and now the model has the capability to identify or recognize my face.

Face Recognition

Final step is to do Face Recognition. Our desired output would be the model should recognize my face and display the confident score and say "Hi Vishnu" and ask to hit Enter to perform further operations.

fr
The above figure shows that our model predicted successfully and if we press enter, in the mean time, our Terraform scripts will automatically run and launch VPC, Subnet, Security Groups, Route tables, Internet Gateway, 5GB EBS Volume and finally provisioned AWS instance.
2 success

EC2 Dashboard

4

VPC Dashboard

5

Model2

Now, We are going to create another model for demonstrating automatic Email and WhatsApp alert messages when the face is detected and recognized. Here, we are going to use the face of Actor Vijay.

Data Collection

Same Procedure. Samples are collecting and storing in another folder named "Vijay" for training the model.

Capture

Model Training

Model is trained using LBPH(Local Binary Pattern Histogram) algorithm and used to trained the samples of Actor Vijay's face.

v2

Above figure shows model is trained successfully and attain its capability of Face Recognition.

Face Recognition

When the Vijay's face is recognized, it will give the confident score and will say "Hi Vijay" and asked to hit enter to perform further operations. When we hit enter, it will send Email and Whatsapp messages alert to the mentioned mail ID and WhatsApp number.

WhatsApp Alert

ww

Email Alert

vv

Output will be..

ffffffffffffffffffff

Above figures shows that desired output was got and it shows our model was trained successfully and predicted correctly.

If you want to play, feel free to download the code in the GitHub by click here

That's it. Thank you for your reads. Stay tuned for my upcoming more interesting articles!!

Discussion (0)