config.ini
: configuration file, required by configparser contains these params:- confidence : float representing the confidence level for a face to be recognized. A face with a confidence score less than this parameter will not be considered for recognition (default 8.)
- threshold : float representing the likelihood that two faces belong to the same person. Calculated as the cosine distance between two output vectors from the CNN. (default 0.35)
- vgg_path : relative (or absolute) path to the pre-trained CNN model file (default None)
- haar_path : relative (or absolute) path to the pre-trained HAAR classifier (default cwd, cloned within this repository)
arch.py
: CNN architecture (VGG16, taken from this source)utils.py
: helper functions needed for config parsing and management, timing and handling pickle files used to store previously tagged identities.identificator.py
: class defining the Identificator object, whom is delegated to detect and recognize the faces seen in the video.main.py
- Python (>= 3.5)
- Tensorflow
- Keras
- OpenCV
- SciPy
- NumPy
- Pickle
- Configparser
- vgg_face.mat : (MATLAB) weights for a 16 layers deep CNN developed and trained by the Visual Geometry Group, as described in this paper. Download from here or follow the instructions in the next section.
- haarcascade_frontalface_default.xml : pre-trained (frontal) face detection feature-based classifier, stored as an XML file.
TODO : generate requirements.txt file for conda/pip
- clone this repo :
git clone https://github.com/w00zie/face_recog
- run
main.py
- once asked for config profile, select
0 - DEFAULT
, if any file needed for the execution is missing it'll be downloaded
Two strings are shown on top of every frame :
- Seen {} different people -> Number of different people seen in this and all the previous sessions (if any). Actual number of different individuals that interacted with the camera.
- Last seen/recognized : {} -> If there is no previous knowledge provided this string represents the last different person who've been recognized (new person 0, new person 1...), besides it displays the name of the previously-tagged person recognized.
The default mode is intended for machines that cannot handle a heavy load. Since running a predict()
may result in a noticeable lag, this workload-saving mode is a compromise between live recognition and mere detection.
Identities are displayed on top of every frame, pointing out the last detected/recognized person.
- First we ran
main.py
with ourdefault
configuration. No previous knowledge provided.
... and we've been asked to insert their relative names to tag these newly detected identities.
- The graph generated by the labelled clusters:
- On the next execution the previously labelled people are now recognized and tagged.
The main structure is the same as the default mode, however it is intended for machines that can handle the heavier load of making many more predicts per frame. Identities, in fact, are predicted and displayed over every face present in every frame.
- We ran
main.py
with ourperformance default
config. No previous knowledge provided.
-
We were shown the graph every 100 nodes. You can notice a predict error near the end of the previous gif, fixed by an automatic run of the Chinese Whispers algorith
-
Then we were asked to insert the names relative to the detected faces, named guy_0 and guy_1 respectively.
- On the next execution the previously labelled people are now recognized and tagged.
- Enriching the clusters in the graph prediction after prediction