All Projects → jiangxiluning → Facenet_mtcnn_to_mobile

jiangxiluning / Facenet_mtcnn_to_mobile

Licence: mit
convert facenet and mtcnn models from tensorflow to tensorflow lite and coreml (使用 TFLite 将 FaceNet 和 MTCNN 移植到移动端)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Facenet mtcnn to mobile

Facerecognition In Arkit
Detects faces using the Vision-API and runs the extracted face through a CoreML-model to identiy the specific persons.
Stars: ✭ 768 (+362.65%)
Mutual labels:  face-recognition, coreml
WhoAreYou
Face detection and recognition with CoreML and ARKit
Stars: ✭ 91 (-45.18%)
Mutual labels:  face-recognition, coreml
Styletransfer Ios
Stars: ✭ 155 (-6.63%)
Mutual labels:  coreml
Mobile Toolkit
📱 Shell scripts for Android and iOS device management
Stars: ✭ 161 (-3.01%)
Mutual labels:  mobile
Framework
The Aurelia 1 framework entry point, bringing together all the required sub-modules of Aurelia.
Stars: ✭ 11,672 (+6931.33%)
Mutual labels:  mobile
Showandtell
A Show And Tell implementation for iOS 11.0 based on CoreML
Stars: ✭ 155 (-6.63%)
Mutual labels:  coreml
Expand
DevExpress XAF extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
Stars: ✭ 158 (-4.82%)
Mutual labels:  mobile
Picodeploy
Deploy Pico-8 Carts as Standalone Applications on Desktop 🖥️(Electron) and Mobile 📱(Ionic) 📦👾
Stars: ✭ 153 (-7.83%)
Mutual labels:  mobile
Ws Scrcpy
Web client prototype for scrcpy.
Stars: ✭ 164 (-1.2%)
Mutual labels:  mobile
Vimo
A H5 Platform Based On Vue2.x
Stars: ✭ 157 (-5.42%)
Mutual labels:  mobile
Lookatme
VideoView that plays video only when 👀 are open and 👦 is detected with various other features
Stars: ✭ 161 (-3.01%)
Mutual labels:  face-recognition
Surfgear
Gear for safe Surf in Flutter
Stars: ✭ 156 (-6.02%)
Mutual labels:  mobile
Texture Compressor
CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.
Stars: ✭ 156 (-6.02%)
Mutual labels:  mobile
Motion Sense
MotionSense Dataset for Human Activity and Attribute Recognition ( time-series data generated by smartphone's sensors: accelerometer and gyroscope)
Stars: ✭ 159 (-4.22%)
Mutual labels:  mobile
Audio recorder
Stars: ✭ 156 (-6.02%)
Mutual labels:  mobile
Facenet Pytorch
Pretrained Pytorch face detection (MTCNN) and facial recognition (InceptionResnet) models
Stars: ✭ 2,564 (+1444.58%)
Mutual labels:  face-recognition
React Native Nav Transition
React Native Nav Transition
Stars: ✭ 154 (-7.23%)
Mutual labels:  mobile
Telegram Kraken Bot
Python bot to trade on Kraken via Telegram
Stars: ✭ 156 (-6.02%)
Mutual labels:  mobile
Facenet
Face recognition using Tensorflow
Stars: ✭ 12,189 (+7242.77%)
Mutual labels:  face-recognition
Autocomplete
Persistent, simple, powerful and portable autocomplete library
Stars: ✭ 166 (+0%)
Mutual labels:  portable

FaceNet 和 MTCNN 转 TFLITE 和 CoreML

git clone https://github.com/jiangxiluning/facenet_mtcnn_to_mobile.git
cd facenet_mtcnn_to_mobile
pipenv install --dev  # 布道 pipenv , 通过使用 pipenv 安装所有依赖包,使用其他版本的包,有可能出现各种转换问题。
pipenv shell # 孵化出运行项目的 shell 环境,以下命令需要在该环境中运行

转换 FaceNet

cd facenet

Model name LFW accuracy Training dataset Architecture
20180402-114759 0.9965 VGGFace2 Inception ResNet v1

将预训练模型 20180402-114759 下载并解压至 model_pc,如下图所示:

WX20190108-113436@2x.png

将作者提供的 training graph 转为 eval graph,因为不转换为 eval 会附带很多 training 的 op, 并且有很多 op TFLite 和 Core ML 等移动框架并不支持。(最主要的问题是 TFLite 目前不支持 Bool 型标量,比如:phase_train)

python eval_graph.py model_pc model_pc_eval

如下所示:

WX20190108-120019@2x.png

使用转换后的 eval graph,将参数和结构固化,这里我们用 facenet 自带的 freeze_graph.py 脚本,不过由于我们之前导出的是 eval graph 所以 phase_train 这个参数输入被我们删除了,导致输出的 facenet.pb 只有一个输入节点 input shape=(1, 64, 64, 3) 和一个输出 output shape=(1,512)

python freeze_graph.py model_pc_eval facenet.pb

将生成的 facenet.pb 转化为 tflite 格式:

tflite_convert --output_file model_mobile_eval/facenet.tflite --graph_def_file facenet.pb  --input_arrays "input" --input_shapes "1,160,160,3" --output_arrays output --output_format TFLITE

祝贺你,你会在文件夹 model_mobile_eval 中找到 facenet.tflite 文件。此时如果你不再需要你的虚拟环境,你可以运行:

pipenv --rm

如果你想转换为 CoreML ,运行 python tocoreml.py

转换 MTCNN

cd mtcnn

model 下载到 MTCNN_model。如下如所示:

WX20190109-140637@2x.png

生成 PNet, ONet 和 RNet 三个网络的 eval graph, 并指定 PNet 图的输入大小, 默认宽高为 800 * 600.

python freeze_graph.py --width 800 --height 600

生成 TFLite 模型

./to_tflite.sh

祝贺你,在 MTCNN_mobile 下会生成相应的 TFLite 模型。

WX20190109-141301@2x.png

如果你想转换为 CoreML ,运行 python tocoreml.py

觉得好大家给颗星,谢谢!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].