A GUI based webcam realtime video Face Recognizer coded in Python3 for Windows.
- Download the faces.tar file from here.
- Extract to a folder named faces and move the folder into the Face Recognizer folder.
Install Python3 and Anaconda if you haven't.
- Create a new conda environment
conda create --name envname
- Activate the environment
conda activate envname
- Install Keras, OpenCV, Numpy, h5py and PIL:
conda install keras
conda install opencv
conda install numpy
conda install h5py
conda install pillow
cd Face Recognizer
python main_ui.py
- The faces dataset forms the NO class of the dataset.
- Frontal face Haar cascade is used for webcam based face detection in OpenCV.
- The detected face in every frame of the video stream is cropped and saved as an image.
- This forms the "YES" class of the dataset
- Since the dataset is rather small, Keras Image data generator is used for Image augmentation.
- A Convolutional Neural Network is built using Keras. This model is trained on the constructed dataset over 25 epochs with 400 samples per epoch.
- The loss function used is Binary crossentropy and the optimizer used is adam.
- The model is saved after training into a .h5 file for later use.
- The class indices are also saved into a poslabel.txt file.
- For every frame in the video stream, face is detected using frontal_face_haar_cascade in Opencv.
- The detected face is saved to a tmpimg.jpg file.
- Th trained CNN model is used to recognize the face.
- The result is shown using cv.rectangle around the face and text.
- Green colored rectangle and Name text if YES else Red colored rectangle and Not Name text.