What is Face-Recognition?
In this post, we are not talking about face recognition theory. Instead, we are going to talk about the module face-recognition.
It works as same as face recognition. Let’s see how to recognize face by the module.
Steps of Face-Recognition
Load images and learn how to recognize it. The images can be loaded by face_recognition.load_image_file(file) where:
- file : image file name or file object to load.
- file : image file name or file object to load.
Convert the images to prepare comparsion group. The images can be converted by face_recognition.face_encodings(face_image, known_face_locations=None, num_jitters=1, model=’small’) where:
face_image : Input image.
known_face_locations : The bounding boxes of each face if you already know them.
num_jilters : How many times to re-sample the face when calculating encoding.
model : Which model to use. “Large” or “Small”
Create two lits of known face encodings and their names.
Get the face location of the target image by face_recognition.face_locations(img, number_of_times_to_upsample=1, model=’hog’) where:
Encoding the image by usingface_recognition.face_encodings() again. Note that we should use the tuples that obtain from Step 4.
Compare the data between we obtained at Step 5 and we prepared at Step 3 by using face_recognition.compare_faces(known_face_encodings, face_encoding_to_check, tolerance=0.6) where:
known_face_encodings : A list of known face encodings.
face_encoding_to_check : A single face encoding to compare against the list.
tolerance : How much distance between faces to consider it a match.