It is a Machine Learning project that recognizes faces of multiple people using Google facenet and SVM algorithm to predict the face in real time
Python 3
Tensorflow
Keras
Open-cv
Scikit Learn
Numpy
Matplotlib
- First the face is detected and extracted from the training images of all classes using opencv haar-cascade(face_preprocessing.py)
- Then the images are converted to a particular size and fed into the Google facenet which returns a 128 length vector per image(via triplet loss) and the labels are encoded into one-hot arrays.
- The list of preprocessed images and one-hot arrays are then fed into SVM (face_classification.py)
- The model is then tested for accuracy (test.py)
- For live prediction using webcam input image is taken from open-cv and it is again converted into 128 length vector using steps 1 to 3
All the codes are in the "src" directory.
Make the following directory structure
Dataset->data->train->training classes with images of respective classes
Dataset->data->val->test classes with images of respective classes
if __name__ == "__main__":
trainX, trainy = load_dataset('D:\\Dataset\\data\\train')
print(trainX.shape, trainy.shape)
# load test dataset
testX, testy = load_dataset('D:\\Dataset\\data\\val')
and put the directory address in the load_dataset() in above code in face_preprocessing.py
Then run embeddings.py->face_classification.py->test.y (for getting the accuracy)
For usign webcam you can run the file real_time_recognizer.py
The model achieved an accuracy of around 82% which is quite good as there were a total of around 50 images per class
References-Google Facenet model