Face recognition with eye detection
- Install python3
On MacOs
brew install python3
On Ubuntu
sudo apt-get install python3
-
Setup a virtual environment in the folder
sudo pip3 install virtualenv
virtualenv myenv
source myenv/bin/activate
-
Install requirements
pip3 install -r requirements.txt
├── pandas
├── numpy
├── sklearn
├── flask
├── flask_cors
├── imutils
├── cmake
├── dlib
├── opencv-python
├── dataset
│ └── harshith
├── detect_blinks.py
├── extract_embeddings.py
├── face_detection_model
│ ├── deploy.prototxt
│ └── res10_300x300_ssd_iter_140000.caffemodel
├── facerecog_v2.py
├── face_registration.py
├── flask_backend.py
├── haarcascade_frontalface_default.xml
├── openface_nn4.small2.v1.t7
├── output
│ ├── embeddings.pickle
│ ├── le.pickle
│ └── recognizer.pickle
├── pycache
│ └── flask.cpython-37.pyc
├── README.md
├── recognize.py
├── recognize_video.py
├── requirements.txt
├── shape_predictor_68_face_landmarks.dat
├── test
│ └── test.png
└── train_model.py
- Face registration (collecting images)
- Face recognition with blink detection
Dataset: Labelled faces in the wild Download
- For using a custom dataset, run
python3 face_registration.py --name [person_name]
to collect images of a person in folderdataset/[person_name]
- Extract embeddings from an image
python3 extract_embeddings.py
. The embeddings are stored in the pathoutput/embeddings.pickle
Added flask server to make an api call
python3 facerecog_v2.py
- Using face alignment [2] to get the facial landmarks and using [1] to compute eye aspect ratio to identify eye blinking.
- This is to avoid spoofing attacks by clearly differentiating a real person's face and an image of the person
- Generate 128-d embedding of each person's image in the dataset.
- Train the SVM model for classification
- Testing: Generate the embedding of the person you want to recognize and compute the similarity between test person's embedding and pre-computed embedding.