1 Star 0 Fork 0

shiguang / tf-mtcnn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Description

This project provide a single tensorflow model implemented the mtcnn face detector. It is very handy for face detection in python and easy for deployment with tensorflow. The model is converted and modified from the original author's caffe model.

For more detail about mtcnn, see the original project.

Requirement

  • tensorflow >= 1.5.0 (older version may work as well, but it is not tested)
  • opencv python binding (for reading image and show the result)
  • pycaffe (optional, for convert model from caffe to tensorflow)

Run

# simple detection demo
python mtcnn.py test_image.jpg

# for tensorflow 2.0
python mtcnn_tfv2.py test_image.jpg

# A demo shows how to use tensorflow dataset api
# to accelerate detection with multi-cores. This is
# especially useful for processing large amount of
# small image data in a powerful server.
python mtcnn_data.py imglist.txt result

Convert model

The default model mtcnn.pb will work well. But if you want to modify the model's behave, you may need to convert the model yourself.

# download model from original project
git clone https://github.com/kpzhang93/MTCNN_face_detection_alignment
# convert model
python caffe2tf.py MTCNN_face_detection_alignment/code/codes/MTCNNv1/model ./mtcnn.pb

Result

result.jpg

Input and Ouput

Input:

BGR image.

Output:

  • box: bouding box, 2D float tensor with format [[y1, x1, y2, x2], ...]
  • prob: confidence, 1D float tensor with format [x, ...]
  • landmarks: face landmarks, 2D float tensor with format[[y1, y2, y3, y4, y5, x1, x2, x3, x4, x5], ...]

Note

  • The mtcnn.pb is not compatible with tensorflow with version 1.12. You can use mtcnn_1.12.pb or consider to convert the model your self.
  • Because the model is designed to work with opencv, so the input image format is BGR instead of RGB. If you prefer RGB, you can modify the convert script and convert the model yourself.
  • The convert code make the model more suitable for tensorflow and opencv by modifying the model's parameters.
MIT License Copyright (c) 2020 blaueck Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/fzw0910/tf-mtcnn.git
git@gitee.com:fzw0910/tf-mtcnn.git
fzw0910
tf-mtcnn
tf-mtcnn
master

搜索帮助