Skip to main content

Multi-task Cascaded Convolutional Neural Networks for Face Detection, based on TensorFlow

Project description

MTCNN

https://badge.fury.io/py/mtcnn.svg

Implementation of the MTCNN face detector for TensorFlow. It is written from scratch, using as a reference the implementation of MTCNN from David Sandberg (FaceNet’s MTCNN). It is based on the paper Zhang et al. (2016) [ZHANG2016].

result.jpg

INSTALLATION

Currently it is only supported python3 onwards. It can be installed with pip:

$ pip3 install mtcnn

USAGE

The following example illustrates the ease of use of this package:

>>> from mtcnn.mtcnn import MTCNN
>>> import cv2
>>>
>>> img = cv2.imread("ivan.jpg")
>>> detector = MTCNN()
>>> print(detector.detect_faces(img))
[{'box': [277, 90, 48, 63], 'keypoints': {'nose': (303, 131), 'mouth_right': (313, 141), 'right_eye': (314, 114), 'left_eye': (291, 117), 'mouth_left': (296, 143)}, 'confidence': 0.99851983785629272}]

The detector returns a list of JSON objects. Each JSON object contains two main keys: ‘box’ and ‘keypoints’. The bounding box is formatted as [x, y, width, height] under the key ‘box’. The keypoints are formatted into a JSON object with the keys ‘left_eye’, ‘right_eye’, ‘nose’, ‘mouth_left’, ‘mouth_right’. Each keypoint is identified by a pixel position (x, y).

A good example of usage can be found in the file “example.py.” located in the root of this repository.

MODEL

The model is adapted from the Facenet’s MTCNN implementation, merged in a single file located inside the folder ‘data’ relative to the module’s path. It can be overriden by injecting it into the MTCNN() constructor during instantiation.

The model must be a numpy-model containing the 3 main keys “pnet”, “rnet” and “onet”, having each of them the weights of each of the layers of the network.

REFERENCE

[ZHANG2016]

Zhang, K., Zhang, Z., Li, Z., and Qiao, Y. (2016). Joint face detection and alignment using multitask cascaded convolutional networks. IEEE Signal Processing Letters, 23(10):1499–1503.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtcnn-0.0.1.tar.gz (2.3 MB view details)

Uploaded Source

File details

Details for the file mtcnn-0.0.1.tar.gz.

File metadata

  • Download URL: mtcnn-0.0.1.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mtcnn-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8c5cda05964f306b8d768fd2ac5bcc03a4b29806fd483e8687b3689f8127dfab
MD5 bba42532a2f006d61b0de0cacbecec57
BLAKE2b-256 bd285080d4bfc2407e1e9ed1dd7493b7e11bd4e591ebe68b5d005493db0eabff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page