This repository contains tools and different method to peform facial recognition. The algorithms that are supported so far are:
- OpenFace: https://cmusatyalab.github.io/openface/
- FaceNet: https://github.com/davidsandberg/facenet
- VGG-Face: https://github.com/rcmalli/keras-vggface
- face_recognition (dlib): https://github.com/ageitgey/face_recognition y https://github.com/davisking/dlib-models (68 point shape predictor)
- AlexNet: https://github.com/kgrm/face-recog-eval
- GoogleNet (Inception-V3): https://github.com/kgrm/face-recog-eval
- SqueezeNet: https://github.com/kgrm/face-recog-eval
- [NOT IMPLEMENTED] SphereFace: https://github.com/clcarwin/sphereface_pytorch
The main goal of this toolbox is to compare the performance of different facial recognition methods as done in this paper
To use this library, clone the reopository using git clone https://github.com/evd995/face_recognition_toolbox.git
Libraries used:
- Numpy:
pip install numpy
- Matplotlib:
pip install matplotlib
- OpenCV:
pip install opencv-python
- Tensorflow:
pip install tensorflow
- Keras:
pip install keras
- AlexNet, GoogleNet and SqueezeNet can only run in Keras 1.2
- dlib:
pip install dlib
- h5py:
pip install h5py
Each method has different installing instructions, each of which can be found bellow.
-
Download pre-trained models at https://github.com/davidsandberg/facenet#pre-trained-models
-
Move weight to the weight directory.
-
When running
predict
it is necessary to specify themodel
parameter as the name of the file of the pre-trained model -
2018-04-08: FaceNet has two pretrained models available, one trained with the CASIA-WebFace dataset and the other with VGGFace2. Both are trained with an Inception ResNet v1 arquitecture. The name of the respective models are:
- facenet-20180408-102900.pb (for CASIA-WebFace)
- facenet-20180402-114759.pb (for VGGFace2, default)
Pre-trained models can be downloaded at https://github.com/davidsandberg/facenet#pre-trained-models
Simple example:
import cv2
# Add package to path
import sys
sys.path.append("/PATH_TO_CLONED_GIT/face_recognition_toolbox")
# Import package
from face_recognition_toolbox import predict
# Looks for "facenet-20180402-114759.pb" (default) in the "/weights" directory
descriptor = predict(image, method_name='FaceNet')
# Looks for "facenet-20180402-114759.pb" in the "/weights" directory using "model" parameter
descriptor = predict(image, method_name='FaceNet', model="facenet-20180402-114759.pb")
- Run
pip install keras_vggface
or follow instructions in https://github.com/rcmalli/keras-vggface#keras-vggface- - 2019-03-21: As of today,
keras_vggface
supports the models: vgg16, resnet50 and senet50. The default is resnet50 but it can be specified by passing themodel
parameter with the desired model name.
Simple example:
import cv2
# Add package to path
import sys
sys.path.append("/PATH_TO_CLONED_GIT/face_recognition_toolbox")
# Import package
from face_recognition_toolbox import predict
# Using default model (resnet50)
descriptor = predict(image, method_name='VGGFace')
# Specifying model with "model" parameter
descriptor = predict(image, method_name='VGGFace', model='resnet50')
- Run
pip install face_recognition
or follow instructions in https://github.com/ageitgey/face_recognition#installation
Simple example:
import cv2
# Add package to path
import sys
sys.path.append("/PATH_TO_CLONED_GIT/face_recognition_toolbox")
# Import package
from face_recognition_toolbox import predict
descriptor = predict(image, method_name='face_recognition')
WARNING: OpenFace can only run in Python 2.7
- Follow instructions at https://cmusatyalab.github.io/openface/setup/
WARNING: AlexNet, GoogleNet and SphereFace can only run in Python 2.7 and Keras 1.2.2
- Download weights at https://github.com/kgrm/face-recog-eval
- Move weight to the weight directory.
- If currently installed version of Keras is greater than 1.2.2, it has to be downgraded before running this method with the command
pip install --upgrade keras==1.2.2
- A simple impletentation can be found in this notebook
To contribute it is possible to perform a pull request. If your goal is to add a new method then follow the next steps: