Giter VIP home page Giter VIP logo

tf-mtcnn's Introduction

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

# 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.

tf-mtcnn's People

Contributors

blaueck avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.