This project build with different files. Separate python files are run to achieve different tasks.
- settings.py - Hold all the settings for entire project.
- prepare.py - Use to separate raw dataset into desirable ratio.
- implement.py - Training model with processed data and saving model in .pt file.
- gtk.py - Starts up gtk application for face recognition.
- dataloaders.py - Contain pytorch data loading from process images.
- haar.py - Displays haar face detection examples.
- network.py - CNN network build using pytorch.
- show_batches.py - Displays batch images from dataloaders
- transforms.py - Pytorch transform to get face detection with haar cascade
Installation after cloning git repository.
mkdir face-recognition
cd face-recognition
git clone git@github.com:roshanshrestha01/Face-Recognition.git app
virtualenv venv
source venv/bin/activate
cd app/
pip install -r requirements.txt
Split data into test data and traing data set. Stores images in processed data with pass parameters.
python prepare.py 6 4
Above commands sets 6 images for training in train directory and 4 images for testing in test directory.
Running train and validation of model.
python implement.py
Trains model and output orl_databse_faces.pt when validation loss is decreased. Also gives confusion-matrix.xls.
GTK desktop application has major three button capture image, train and predict video
Add subject name in input. This name is use as directory name and label to store captured iamges.
Capture image button open up webcam input. Might have to change source opencv video source in settings.py.
When video frame is open. Press "C" in keyboard with face is detected in video which store image in directory name set in subject name input box.
Click Train model button which uses pretraind model orl_database_faces.pt and added new image from capture directory. After completion an alert is made.
Clicking predict video opens up video frame. Whan face is detection prediction is done and label is written at top right corner of detected face.