Creating a Face Recognition Program This program will Detect your and your friend’s face and will send notification and create an AWS instance and attach volume to it.

Garvit Garg
4 min readJun 24, 2021

Language used : Python

Hey guys in this blog we are gonna make a program that will recognize our face and will send a notification to our id’s + this program after recognizing 2nd image will create an AWS instance and will attach an EBS volume to it.

So this project will go in 4 parts.

  1. Code that will train the model with given data.
  2. Code that will send Notification
  3. Code that will generate AWS Instance and add a 5Gb EBS Volume to it
  4. Integrating above steps to create full program that will detect your and your friend’s face and will send notification and create an AWS instance and attach volume to it

So lets start with Step-1 :

Training the model :

To train the model we have to firstly provide our model data.
So we are gonna provide firstly an image of ours from which our model will extract the face.
Then we will provide 100 more faces to get it trained properly.

For that we have to import some libraries :

Now let’s load our image in the server and crop our face out of it and convert whole of this colored pic in grey color.

Now lets collect 100 Samples of images to train our model.

Now let’s train our model with the provided data.

Our Model is now trained.
Let’s move to 2nd step

Sending the Notification :

For sending the mail firstly we have to import some libraries :

Program to send mail :

Program to send Whatsapp Message :

Notification is sent.
Now lets move to 3rd step.

AWS Work :

In AWS we have to firstly create an instance.
Then we have to attach an EBS Volume of 5Gb to it.
To do so :
Firstly we have to configure AWS which we can either do before logging in to python Jupyter Notebook or we can do after logging in to Jupyter Notebook.

I am gonna do it before logging in to Jupyter Notebook :

After logging to continue with AWS in python we need to download and import a library

Now to create an instance we need to firstly create a key pair :

Now after creating a key pair we need :

  1. Image Id : Can get Image Id from AWS Consol
  2. Instance Type : t2.micro is the only free Type
  3. Key Pair : That we created above/ Before created can also be used
  4. Max Count : Maximum instance you want to create
  5. Security Group Id : Can create one/ Can use default one
  6. Security Group Name : Can create one/ Can use default one

Fill above blanks and our Instance will be created
Now we need to create an EBS volume :

Volume of 5Gb is created
Now our last step is to attach it with the instance that we created :

Now every function is ready.
Our model is also trained.
Now its time to run the model which we can do as :

--

--