Coders Packet

Face Recognition system in Python using OpenCV and system built using a pre-trained model

By Mihir Shri

This project is about a face recognition system built using a pre-trained model available in Python's face_recognition library and OpenCV.

This project is used to recognize unknown faces in an image. We all are familiar with the famous concept of face recognition. Many times users get confused about face recognition and face detection. The concept is simple, face detection is just identifying the faces present in an image, whether it is a man, a woman, a child, it doesn't care. It will just tell you that "Hey, there are 5 faces in this image" whereas face recognition on the other hand, in addition to detecting faces, also tells the identity of that face. It clearly distinguishes people from one another. For eg, for a face detection system, you and your friend are the same to it, just 2 faces but for a face recognition system, you and your friend are completely different from one another.

This project is about a face recognition system built using a pre-trained model available in Python's face_recognition library and OpenCV.

I have used the face_recognition library available in python which comes with a pre-trained model for face recognition and has an accuracy of a whopping 99.38%. So, if fed with the right training images, the system will almost never fail.

The famous OpenCV library has also been used for some basic features it provides.

Follow the below steps to get started:

1. Extract the zip file. You'll get a .ipynb python notebook.

2. Open it in google colab. Just search for google colab on google and open the file from there.

3. Create a folder in your google drive. Make sure you remember its name (I used "sujoy data" as I initially made this for a friend so if you don't want to make many changes and want the system to work asap, create a folder with the name "sujoy data")

4. Inside this folder, create two more folders. (Now again, you can give whatever name you feel like. I gave it "known_faces" and "unknown faces". Feel free to give any names to the folders)

5. Now, inside the "known_faces" folders you can create as many folders as you like of the people/things you want the system to recognize. (What I did was, created two folders named "LM10" (short for Lionel Messi) and "CR7" (short for Cristiano Ronaldo). You can create as many as you want). Inside these folders, put the images of the people after whom you named the folders. For eg, I'll put Lionel Messi's pics inside the LM10 folder and Cristiano Ronaldo's pic inside the CR7 folder. (For those who don't know, Lionel Messi and Cristiano Ronaldo are two of the best footballers in the world.)

6. Now, these folders will serve as your labels, i.e. whenever the system sees the image of Lionel Messi, it will display "LM10". Feel free to give any name to these folders but make sure you're putting the right images under the right folders.

7. You're almost done. Put all the images that you want your system to recognize in the "unknown_faces" folder.

8. Run the notebook in google colab. The first cell mounts your google drive content into the google colab platform. It will ask for some permissions, grant them.

9. Make sure to change the path in the next few cells. Since I used "sujoy data" as the folder's name. You should put the correct name of the folder.

10. That's all. Your face recognition system is ready! 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Mihir Shri (coe18b064)

Download packets of source code on Coders Packet