DeepFace: A Facial Recognition Library for Python
Introduction to Deep Face Framework for Python
In this video, the speaker introduces the Deep Face Framework for Python, a lightweight face recognition and facial attribute analysis library that can be run with just a few lines of code. The speaker mentions its functionalities and best practices as well as its face recognition module which wraps several state-of-the-art models.
Key Points:
- The face recognition module wraps several state-of-the-art models including VGG Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib.
- To run facial recognition with Deep Face, we need to call the pip install deepface command to install the package. We then import the library from deepface import DeepFace (note uppercase "D" in "DeepFace").
- To run facial recognition with Deep Face, we call
DeepFace.verify()function that expects image one path and image two path as input arguments.
- We can pass optional arguments such as model name (default is VGG-Face), distance metric, pretrained model and face detection backend.
Running Facial Recognition with Deep Face
This section covers how to run facial recognition with Deep Face using just a few lines of code.
Key Points:
- We can run a facial recognition task in a single line of code by calling
DeepFace.verify()function that expects image one path and image two path as input arguments.
- The verification function handles several stages of a common face recognition pipeline such as face detection and alignment in the background.
- We can experiment with different facial recognition algorithms by running the verification function again with different model names.
Facial Recognition and Attribute Analysis with DeepFace
In this video, the presenter demonstrates how to use DeepFace for facial recognition and attribute analysis. The presenter shows how to run a face recognition task with DeepFace using an image pair as input. They also demonstrate how to find similar faces of a single image using the custom find function in DeepFace. Additionally, they show how to analyze facial attributes such as emotion, age, gender, and race using the analyze function in DeepFace.
Running Face Recognition Task with Image Pair
- Read two images:
image1.jpgandimage3.jpg.
- Identify the individuals in each image: Angela Julie and Jennifer Anderson.
- Use Arc Face 18 model for face recognition.
- Pass the image pair as input.
- The model returns false because they are different people.
Finding Similar Faces of a Single Image
- Use the custom find function in DeepFace.
- Pass a single image path as input (
source.jpg).
- Set the second argument as required db path (
deepface/tests/dataset).
- Find function returns a pandas data frame containing similar images of the source one.
- Assign it to a variable named
df.
- Import pandas library.
Analyzing Facial Attributes
Emotion Analysis
- Use analyze function in DeepFace.
- Pass a single image path as input (
image1-pad).
- Returns predictions for emotion, age, gender, and race.
- Dominant emotion is happy with highest score in happy field.
Age Analysis
- Returns age value which is 33 years old woman
Gender Analysis
- Returns gender value which is female
Race Analysis
- Returns distributions of six different races and dominant race which is latino.
Conclusion
- DeepFace offers facial recognition and attribute analysis functions.
- You can support the DeepFace project by starting a GitHub repository.
- You can also support the presenter's channel by liking and subscribing.