Face Recognition System for provisioning AWS instance using Terraform scripts and generating Mail & WhatsApp alerts
Sri Vishnuvardhan A
Posted on June 24, 2021
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.
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.
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.
EC2 Dashboard
VPC Dashboard
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.
Model Training
Model is trained using LBPH(Local Binary Pattern Histogram) algorithm and used to trained the samples of Actor Vijay's face.
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
Email Alert
Output will be..
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!!
Posted on June 24, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.