For Machine Learning Approach Scroll to The End of the Page.
Creating a Basic Face Lock isn’t a Rocket Science when you have Python’s
package openCV with you.
I will suggest you, use Jupyter Notebook for this project
https://jupyter.org/install — link to install Jupyter Notebook
So first install openCV package in you Jupyter Notebook
now import both the packages in your notebook
Download Haar Cascade XML files for Object Detection which will help you to detect Faces:
http://alereimondo.no-ip.org/OpenCV/34 — Download Harr Cascade Choose Frontal Face Zip
the Code below will help you to Register Your Face Which will be Compared With Scanned Faces(Functionalities of every line is explained in the comments)
now from this Cell, we have divided the Captured Image into Small Pixels Which are further Encoded with their respective Pixel code in NumPy Array.
1. Natural Language Generation:
The Commercial State of the Art in 2020
2. This Entire Article Was Written by Open AI’s GPT2
3. Learning To Classify Images Without Labels
4. Becoming a Data Scientist, Data Analyst, Financial Analyst and Research Analyst
For Eg:- I Applied this function on my image and this is what I got:-
and from the function below we can again convert the NumPy Array To Respective Image and Save it By the Function Below:-
Now use the Second Instance of The faceCascade to Compare it with the Registered image and then Find the Accuracy :
this Cell Will again do the same, Capture the image and the will convert it into Its Respective NumPy Array
Now we Have Both the NumPy Array The Registered one and another to Test on.
so now we are cropping the image of the Face only by the detected Rectangle Dimensions around the Faces ,for both Images (Registered and Testing One)
Look at the comments to know what’s every line doing
Now Coming To Train Your Model
Actually This Process Should be implemented When we Were Registering Faces, but this will become too much for now so I placed it here
for This, We have to Train Our Model First
For This Run the Cell Below:-
Run this Cell for 7–8 Times and Every Time Add train_list to a 2-D Matrix Column Wise for Every iteration.
(Sometimes try to run with Different Faces and Mark Them with 0(Wrong) for Better Training.)
Suppose you run the cell for 7 times and stores the list in a 2-D Matrix You will get a Matrix Of Dimensions:-
Create a respective [1:number of elements] matrix(TRAIN_Y) with Values 1 when you scanned your face and 0 when you used Different Faces.
Now Use Logistic Regression to Train You model By Iteration of Training Matrix (TRAIN_X) and The Result Matrix(TRAIN_Y) Column Wise.
Heyyyaahh !! Model Is Trained:
Now Every Time You Use This Facial Recognition Convert the Image to Respective List as we have Done Above, Then Use LogisticRegression.Predict() and Pass Your List In Predict Method.
After That If The Logistic Regression Model Shows 1 This Means Permission Granted and 0 For Permission Denied.
For Any Queries:- firstname.lastname@example.org