Skip to content

neeru1207/GUI-Face-recognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

GUI Face recognizer

A GUI based webcam realtime video Face Recognizer coded in Python3 for Windows.

Screenshots

"Main UI" "Face Recognition"

Usage:

Required download:

  • Download the faces.tar file from here.
  • Extract to a folder named faces and move the folder into the Face Recognizer folder.

Required Packages:

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

Running the application

cd Face Recognizer
python main_ui.py

Implementation:

Dataset

"NO" class:

  • The faces dataset forms the NO class of the dataset.

"YES" class:

  • 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

Augmentation:

  • Since the dataset is rather small, Keras Image data generator is used for Image augmentation.

Model:

  • 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.

Recognition:

  • 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.