Face recognition - realtime recognition by tf2
pip install mtcnn (for pip)
conda install -c conda-forge mtcnn (for conda)
python src/save_data.py --name (name of save_dir)
Make sure your computer has a webcam
Preprocessing:
- Train embedding model with your dataset, you need to organize dataset as follows:
Each person needs 4-5 raw photos with many different angle shooting: front, left, right, …
Face-Recognition
└───data/
└───person1/
| └───person1_1.jpg
| person1_2.jpg
| .....
└───person2/
| └───person2_1.jpg
| person2_2.jpg
| .....
└───personN/
└───personN_1.jpg
personN_2.jpg
.....
Augment data:
- After having the raw image files, run augment_data.py to augment more images, each person after running will have 100 different images. Augments: rotation_range = 15, brightness_range=[0.4,1.5], horizontal_flip
python augment_data.py
Train embedding model:
After embedding, embedded file will be saved to output / train_embs.pickle
python train_embs.py
Train softmax model:
The number of classes i’m setting here is 37 classes, so change the number of classes that match your dataset
python train_classify.py
Enjoy result:
<img alt="Qries" src="https://github.com/manhminno/Face-Recognition/blob/master/output/1.jpg">
Label is name of saved-dir - box is green, unknown will don’t have label - box is red. Here label is id of person.
python image_recognition.py --path (path to image) --facedetect (use MTCNN to detect face before recognition - yes/no)
Output will be saved to output/(name_of_img.jpg)
python video_recognition.py --path (path to video) --facemodel (path of facenet weights) --classifymodel (path of classify model weight) --embspath (path of embed dir)
python stream_recognition.py
Make sure your computer has a webcam, here i’m setting webcam 0