Tensorflow implementation for MobileFaceNet.
This version is different from the original repo sirius-ai/MobileFaceNet_TF:
- Model checkpoint and re-train continuously is more easier. This is suitable for model training progress on Google Colaboratory.
- Bug fixes
- Convert to Tensorflow Lite format
- Provide examples on ipython notebooks
Pretrain is available at arch/pretrained_model/MobileFaceNet_TFLite/.
- tensorflow 1.x >= r1.5
- opencv-python 3.x
- python 3.x
- scipy
- sklearn
- numpy
- mxnet
- pickle
- Choose one of the following links to download dataset which is provide by insightface. (Special Recommend MS1M-refine-v2)
- MS1M-refine-v2@BaiduDrive, MS1M-refine-v2@GoogleDrive
- Refined-MS1M@BaiduDrive, Refined-MS1M@GoogleDrive
- VGGFace2@BaiduDrive, VGGFace2@GoogleDrive
- Insightface Dataset Zoo
- Move dataset to
${MobileFaceNet_TF_ROOT}/datasets
. - Run
${MobileFaceNet_TF_ROOT}/utils/data_process.py
.
Take a look at data_prepair.ipynb for more details.
- Refined super parameters by yourself special project.
- Run script
${MobileFaceNet_TF_ROOT}/train_nets.py
- Have a snapshot result at
${MobileFaceNet_TF_ROOT}/output
.
Take a look at train.ipynb for more details.
- Choose your best model checkpoint.
- Freeze graph and get the
.pb
model file using freeze_graph.py
python3 freeze_graph.py \
--pretrained_model ./arch/pretrained_model/MobileFaceNet_TFLite/checkpoints/895000_MobileFaceNet.ckpt \
--output_file ./arch/pretrained_model/MobileFaceNet_TFLite/MobileFaceNet.pb
- Convert to TFLite format
For example:
tflite_convert \
--output_file ./arch/pretrained_model/MobileFaceNet_TFLite/MobileFaceNet.tflite \
--graph_def_file ./arch/pretrained_model/MobileFaceNet_TFLite/MobileFaceNet.pb \
--input_arrays "input" \
--input_shapes "1,112,112,3" \
--output_arrays embeddings \
--output_format TFLITE
You may need to choose the suitable inference batch size. The previous example use batchsize = 1.
Take a look at test.ipynb for more details.
size | LFW(%) | Val@1e-3(%) | inference@GPU: Qualcomm Adreno TM 509(ms) |
---|---|---|---|
4.9MB | 99.4+ | 98.3+ | 30- |