FaceRecognition with MTCNN using ArcFace
git clone https://github.com/naseemap47/FaceRecognition-MTCNN-ArcFace.git
cd FaceRecognition-MTCNN-ArcFace
pip3 install -r requirement.txt
You can use:
Command Line
OR
Streamlit Dashboard
pip3 install streamlit
streamlit run app.py
python3 take_imgs.py --name <name of person> --save <path to save dir>
Example:
python3 take_imgs.py --name JoneSnow --save data
📖 Note:
Repeate this process for all people, that we need to detect on CCTV, Web-cam or in Video.
In side save Dir, contain folder with name of people. Inside that, it contain collected image data of respective people.
Structure of Save Dir:
├── data_dir
│ ├── person_1
│ │ ├── 1.jpg
│ │ ├── 2.jpg
│ │ ├── ...
│ ├── person_2
│ │ ├── 1.jpg
│ │ ├── 2.jpg
│ │ ├── ...
. .
. .
It will Normalize all data inside path to save Dir and save same as like Data Collected Dir
python3 norm_img.py --dataset <path to collected data> --save <path to save Dir>
Example:
python3 norm_img.py --dataset data/ --save norm_data
Structure of Normalized Data Dir:
├── norm_dir
│ ├── person_1
│ │ ├── 1_norm.jpg
│ │ ├── 2_norm.jpg
│ │ ├── ...
│ ├── person_2
│ │ ├── 1_norm.jpg
│ │ ├── 2_norm.jpg
│ │ ├── ...
. .
. .
python3 train.py --dataset <path to normalized Data> --save <path to save model.h5>
Example:
python3 train.py --dataset norm_data/ --save model.h5
Open inference_img.py and inference.py:-
Change class_names List into your class names. Don't forget to give in same order used for Training the Model.
python3 inference_img.py --image <path to image> --model <path to model.h5> --conf <min model prediction confidence>
Example:
python3 inference_img.py --image data/JoneSnow/54.jpg --model model.h5 --conf 0.85
To Exit Window - Press Q-Key
python3 inference.py --source <path to video or webcam index> --model <path to model.h5> --conf <min prediction confi>
Example:
# Video (mp4, avi ..)
python3 inference.py --source test/video.mp4 --model model.h5 --conf 0.85
# Webcam
python3 inference.py --source 0 --model model.h5 --conf 0.85
To Exit Window - Press Q-Key