How to develop program for verification faces in social networks?
Roman Ivanisenko

How to develop program for verification faces in social networks?

Hi, everybody! Since we need to recognize the faces on the image, further working with the descriptors of recognizable faces, it is need to use the exact solution to more accurately identify the faces on the image and then retrieve face descriptors and for this reason was chosen the Dlib library. This library contains a trained convolutional neural network that provides feature vectors in such a way that they are nearby on the image of one person, and far from each other in image of another. The vectors of this library are named descriptors.

Also need to use the scikit-image library for image processing for the Python programming language. It contains built-in algorithms for analysis, color space regulation, geometric transformations, feature extraction, etc. In order to ensure the identification of detected faces, it is necessary to calculate the distance between the descriptors and use them in Python, you can use the scipy.spatial.distance library.

Calculating the Euclidean distance, one can identify a person by the face by comparing the obtained distance in these descriptors. In Dlib recommended to use the boundary value of the Euclidean distance between face descriptors equal to 0.6. It is possible to determine whether a image belongs to a specific person based on the calculated Euclidean distance. If the value of this distance is less than 0.6, we can conclude that the faces are match up. Use this metric the Dlib library provides 99.38% accuracy in identifying faces Documentation for Dlib and Face Recognition libraries.

Including libraries for recognition, image processing and Euclidean distance calculation:

Import libraries

You need to using trained models for recognizing faces in Dlib and unzip them to your program. (Download trained models from my Github account https://github.com/ncr00t/find-account-by-face/tree/master/training_models) and loading this models into your program:

Loading trained models

Further need to ensure the loading and display of the first photo, as an example, my photo from the passport was chosen:

Code for loading and display of the first photo

After that, using the selection of key points on the face, the face is recognized on the downloaded photo and the data is framed. The face is framed in a rectangular area and key points of the face in the photo are framed inside this areF

Assignment the key points of the face within rectangular area

Then the face has been recognized, we need to obtain descriptors for it using the convolutional neural network, in order to further use this set of descriptors to compare with the face in another photo:

Getting the descriptor from the first photo

Similarly, we load and recognize the face in the second photo. My photo from the social network VKontakte was chosen as second photo for compare:

Assignment key points in rectangular area for second photo from social network

As a result, we extract the face descriptors in the second image for comparison with the face on the first photo:

Getting the descriptor from the second photo from social network

When the descriptors of both faces are received, for their identification it is need to calculate the Euclidean distance between them, passing the calculated descriptors of both faces

Calculating Euclidean distance between two descriptors

As a metric of Euclidean distance value, it is recommended to use a boundary value of 0.6. In case distance obtained is less than 0.6, then the same person in two photos. Since as a result of comparison we get Euclidean distance equal is 0.34, therefore, the faces in both photos are match up and the photos belong to the same person.

The developed module can be integrated in any of the existing automated systems for recognizing and identifying faces. In the future, this module will be integrated in system for searching people by photos in social networks.

Thank for your attention! In case you have questions, write to me and I'll answer you.

要查看或添加评论,请登录

Roman Ruby的更多文章

社区洞察

其他会员也浏览了