This repository contains code for a custom face recognition implemented in python. Using the code in this repository, one can create a face recognition system having eye blink detector as an anti-spoofing method, that prevents a photo to be used as a measure to detect a face.
This code can be used to create a software as well as a hardware implementation to create a face recognition unlocking system.
Source |
Source |
Run the files preferably on the command line.
-
Run
pip install -r requirements.txt
to install all required libraries. Check out this article to know more about requirements.txt. -
Run
python face_store_data.py
. Input the name of the person of whom you are creating the dataset of images. Now, with the face recognition window as the active window, use key 'k' to cature your image when the camera recognizes your face. After capturing a good amount of photos, use key 'q' to exit.
Advice: The more images the better ๐ท. Try to click atleast 50 to get a good recognition system. Also, if your camera doesn't recognize your face, invest in a better camera ๐ -
Run
python train.py
. Sit tight for a few seconds โ -
Run
python final_code.py
and VOILA! You have your own face recognition system.
One can change the below mentioned variables according to their needs
- The
final_code.py
file consists of a variableEYE_AR_THRESHOLD
that is set to 0.27 i.e. if the eye blink falls below this threshold, it will be considered as a blink. - The above file has variable
EYE_AR_CONSEC_FRAMES
set to 1 which implies that a blink must last for atleast one frame. - Finally, at the end of the same file, an if condition is set to check if blinks are greater than 2. If so, the code breaks out of the loop.
A special thanks to https://pyimagesearch.com. Their website helped a lot. Do check out their website.