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:
python train_embs.py
After embedding, embedded file will be saved to output / train_embs.pickle
Train softmax model:
python train_classify.py
The number of classes i'm setting here is 37 classes, so change the number of classes that match your dataset
Enjoy result:
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