Deepweb
Deepweb
We will try to create a face detection and facial feature recognition model using
Facebook’s Deepface Framework to identify and distinguish between a set of images.
We will also compare the results using two of many in-house models present in the
framework and predict the age of the faces present in the images.
So let’s start!
We will now import and call our modules from the framework. We will also use OpenCV
to help our model with image processing and matplotlib to plot the results.
We will now call our first library model for facial analysis called VGG-Face. When
we call the model, it imports a set of pre-trained deep learning networks with pre-
trained weights.
#calling VGGFace
model_name = "VGG-Face"
model = DeepFace.build_model(model_name)
Verifying the Results
Creating a function called result to get our results and using the verify function
to validate the images
{'distance': 0.2570606020004992,
'max_threshold_to_verify': 0.4,
'model': 'VGG-Face',
'similarity_metric': 'cosine',
'verified': True}
Here, the distance tells us how far apart are the two faces present in images, i.e.
the difference between the two. We can also see that it provides us with our image
verification result as TRUE telling us that the compared faces present in images
are of similar people.
{'distance': 0.6309288770738648,
'max_threshold_to_verify': 0.4,
'model': 'VGG-Face',
'similarity_metric': 'cosine',
'verified': False}
As we can notice, the distance this time is very high, and the verification says
FALSE, telling us that the compared faces are of two different people!
{'distance': 0.42664666323609834,
'max_threshold_to_verify': 0.4,
'model': 'Facenet',
'similarity_metric': 'cosine',
'verified': True}
We can see by comparing the faces present in the first two images, although Facenet
tells us that they are similar, the distance seems to be a bit high. Hence, telling
us that the VGG Face model gives a more accurate representation of results than
Facenet.
We can also match and rank the similarity of faces using a different image of the
same person.
Result :
ENDNOTES
This article has now implemented and learned how to create a Face Recognition &
Facial Feature Detection model to analyze faces from a set of images. You can
choose other models present in Deepface such as “OpenFace”, “DeepID”, “ArcFace”,
“Dlib ” and check their recognition accuracy as well. The full Colab file for the
following can be accessed from here.
Happy Learning!
References
Deepface and its Implementations
Deepface Documentation
More Great AIM Stories
What did Oracle do in 2022?
What Changed After Akamai’s Acquisition of Linode
Top Data Science and AI Trends for 2023
TSMC’s 3nm: Lost in Memory Lane
Could Tata’s Semiconductor Push Make the Conglomerate Self Reliable?