How to make a Face recognition from scratch? As one of the most successful applications of image analysis, facial recognition allows a person to be identified by analyzing the biometric characteristics of their face and has recently received significant attention.
Face recognition systems have become part of our daily lives. The face is used in different parts of the world to unlock mobiles, for certain airport controls, to be able to withdraw money at ATMs, make payments at establishments, or even identify suspects in events with many people as did the singer Taylor Swift in a Los Angeles concert in 2018. It is due to the availability of viable technologies, including mobile solutions.
Now, let’s learn to perform easy recognition in an easy way with python.
First, we will start with install dependencies
In your terminal:
$ pip face_recognition
Yes, just that library need for make face recognition from scratch.
IMPORTANT: This library work with MacOS and Linux, Windows is no supported.
Now the code
import face_recognition know_image = face_recognition.load_image_file("your_photo.jpg") unknown_image = face_recognition.load_image_file("unknown.jpg") try: know_face_encoding = face_recognition.face_encodings(know_image) unknown_face_encoding = face_recognition.face_encodings(unknown_image) except IndexError: print("I wasn't able to locate any faces in at least one of the images. Check the image files. Aborting...") quit() known_faces = [ know_face_encoding, ] results = face_recognition.compare_faces(known_faces, unknown_face_encoding) if(results): print("I found Guido in the image") else: print("Unknown person")
I use this image for training my algorithm:
That is our face to detect, first we save his face and also that of a stranger (it will be the one that will be compared to our first image)
Try use this image:
This result is because that face is not equal to that of the first image, now try with first image like unknown person, result:
"I found Guido in the image"
You need more…?
Here I leave the library repository, there are more examples here, also real time recognition is possible.
Face recognition opens up enormous opportunities for the creation of new aplication that can be great help for different industries, including retail(advertising impact),healthcare (patient pain levels), , and public safety(identifying risk).
If you are interested in how it works Face recognition or learning more about other technologies in trend suscribe to our blog for keep ypu up to date.