Skip to content
This project provide a single tensorflow model implement the mtcnn face detector. And it shows how to convert model from caffe to tensorflow in a hard way.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Feb 13, 2018 Update Dec 2, 2018 Fix the comment error. Mar 22, 2018
mtcnn.pb Add files via upload Feb 13, 2018
mtcnn_1.12.pb add some comments. Mar 28, 2018
result.jpg Add files via upload Feb 13, 2018
test_image.jpg Add files via upload Feb 13, 2018


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.


  • 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)


# simple detection demo
python 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 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
# convert model
python MTCNN_face_detection_alignment/code/codes/MTCNNv1/model ./mtcnn.pb



Input and Ouput


BGR image.


  • 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], ...]


  • 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.
You can’t perform that action at this time.