- Build a Python program that can recognize faces in photos
- Train the program on known faces
- Recognize and identify those trained faces in random photos
- Ubuntu 18.04 LTS
- Python 3
- Nvidia Jetpack 4.3-b134
- OpenCV open source library for computer vision 4.1.1
- Python open source face-recognition library
- Dlib machine learning toolkit
- Pickle Python object serializer
- Installed Nvidia Jetpack on and SD card and installed in the Jetson Nano
- Installed OpenCV
- Installed Dlib
- Installed face-recognition library
- Installed pickle
I started by downloading training images of my two subjects, Bill Gates and Steve Jobs and placed them in a "known" images folder. Then, I downloaded several other images with Bill and/or Steve and other people and placed those in an "unknown" folder.
Using the Python face-recognition library, the program loads each training image and encodes it using the file name as the label. Then, using pickle, the training data is saved into a file named train.pkl.
Next, the face-recognition library is used to decode each test image, locate faces in the images, and encode them. Then, the encoded testing images are compared to the training images and rectangles and labels are applied using OpenCV. Finally, the new images with annotations are saved.
ResultsThe results were not perfect, but considering I only trained the model on one image of each person, it did a pretty good job! I was surprised it recognized their faces when they were much younger and picked them out with different expressions and backgrounds.
Comments
Please log in or sign up to comment.