Package: face-biometric-recognition
Facial RecognitionRecognize and manipulate faces from Python. This is a fork fromhttps://github.com/ageitgey/face_recognition.Built usingdlib's state-of-the-art face recognition
built with deep learning. The model has an accuracy of 99.38% on theLabeled Faces in the Wildbenchmark.FeaturesFind faces in picturesFind all the faces that appear in a picture:importface_biometric_recognitionimage=face_biometric_recognition.load_image_file("your_file.jpg")face_locations=face_biometric_recognition.face_locations(image)Find and manipulate facial features in picturesGet the locations and outlines of each person's eyes, nose, mouth and chin.importface_biometric_recognitionimage=face_biometric_recognition.load_image_file("your_file.jpg")face_landmarks_list=face_biometric_recognition.face_landmarks(image)Identify faces in picturesRecognize who appears in each photo.importface_biometric_recognitionknown_image=face_biometric_recognition.load_image_file("biden.jpg")unknown_image=face_biometric_recognition.load_image_file("unknown.jpg")biden_encoding=face_biometric_recognition.face_encodings(known_image)[0]unknown_encoding=face_biometric_recognition.face_encodings(unknown_image)[0]results=face_biometric_recognition.compare_faces([biden_encoding],unknown_encoding)InstallationRequirementsPython 3.3+ or Python 2.7macOS or Linux (Windows not officially supported, but might work)Installation Options:Installing on Mac or LinuxFirst, make sure you have dlib already installed with Python bindings:How to install dlib from source on macOS or UbuntuThen, make sure you have cmake installed:brew install cmakeFinally, install this module from pypi usingpip3(orpip2for Python 2):pip3installface_biometric_recognition--no-index--find-linksfile:/path/to/face_biometric_recognitionUsagePython ModuleYou can import theface_biometric_recognitionmodule and then easily manipulate
faces with just a couple of lines of code. It's super easy!Automatically find all the faces in an imageimportface_biometric_recognitionimage=face_biometric_recognition.load_image_file("my_picture.jpg")face_locations=face_biometric_recognition.face_locations(image)# face_locations is now an array listing the co-ordinates of each face!You can also opt-in to a somewhat more accurate deep-learning-based face detection model.Note: GPU acceleration (via NVidia's CUDA library) is required for good
performance with this model. You'll also want to enable CUDA support
when complilingdlib.importface_biometric_recognitionimage=face_biometric_recognition.load_image_file("my_picture.jpg")face_locations=face_biometric_recognition.face_locations(image,model="cnn")# face_locations is now an array listing the co-ordinates of each face!Automatically locate the facial features of a person in an imageimportface_biometric_recognitionimage=face_biometric_recognition.load_image_file("my_picture.jpg")face_landmarks_list=face_biometric_recognition.face_landmarks(image)# face_landmarks_list is now an array with the locations of each facial feature in each face.# face_landmarks_list[0]['left_eye'] would be the location and outline of the first person's left eye.Recognize faces in images and identify who they areimportface_biometric_recognitionpicture_of_me=face_biometric_recognition.load_image_file("me.jpg")my_face_encoding=face_biometric_recognition.face_encodings(picture_of_me)[0]# my_face_encoding now contains a universal 'encoding' of my facial features# that can be compared to any other picture of a face!unknown_picture=face_biometric_recognition.load_image_file("unknown.jpg")unknown_face_encoding=face_biometric_recognition.face_encodings(unknown_picture)[0]# Now we can see the two face encodings# are of the same person with `compare_faces`!results=face_biometric_recognition.compare_faces([my_face_encoding],unknown_face_encoding)ifresults[0]isTrue:print("It's a picture of me!")else:print("It's not a picture of me!")Articles and Guides that coverface_biometric_recognitionAdam Geitgey's article on how Face Recognition works:Modern Face Recognition with Deep LearningCovers the algorithms and how they generally workFace recognition with OpenCV, Python, and deep learningby Adrian RosebrockCovers how to use face recognition in practiceRaspberry Pi Face Recognitionby Adrian RosebrockCovers how to use this on a Raspberry PiFace clustering with Pythonby Adrian RosebrockCovers how to automatically cluster photos based on who appears in each photo using unsupervised learningHow Face Recognition WorksIf you want to learn how face location and recognition work instead of
depending on a black box library,read Adam Geitgey's article.CaveatsThe facial recognition model is trained on adults and does not work very well on children. It tends to mix
up children quite easy using the default comparison threshold of 0.6.Accuracy may vary between ethnic groups. Please seethis wiki pagefor more details.ThanksMany thanks toAdam Geitgeyfor putting together such an amazing project and allowing public access to it.