MTMN is a lightweight Human Face Detection Model, which is built around a new mobile architecture called MobileNetV2 and Multi-task Cascaded Convolutional Networks, and is specially designed for embedded devices.
MTMN consists of three main parts:
The following diagram shows the workflow of MTNM.
box_array_t *face_detect(dl_matrix3du_t *image_matrix, mtmn_config_t *config);
This face_detect()
handles the whole face detection mission.
The inputs are:
dl_matrix3du_t
typeThe output is:
box_array_t
type value contains face boxes, as well as score and landmark of each box.This structure is defined as follows:
typedef struct tag_box_list
{
fptp_t *score;
box_t *box;
landmark_t *landmark;
int len;
} box_array_t;
The structure contains heads of arrays, each array has a same length, which is the number of faces in the image.
face_detect()
provides the config
parameter for users' customized definition.
box_array_t *face_detect(dl_matrix3du_t *image_matrix, mtmn_config_t *config);
The definition of mtmn_config_t
:
typedef struct
{
float min_face; /// The minimum size of a detectable face
float pyramid; /// The scale of the gradient scaling for the input images
int pyramid_times; /// The pyramid resizing times
threshold_config_t p_threshold; /// The thresholds for P-Net. For details, see the definition of threshold_config_t
threshold_config_t r_threshold; /// The thresholds for R-Net. For details, see the definition of threshold_config_t
threshold_config_t o_threshold; /// The thresholds for O-Net. For details, see the definition of threshold_config_t
mtmn_resize_type type; /// The image resize type. 'pyramid' will lose efficacy, when 'type'==FAST.
} mtmn_config_t;
typedef struct
{
float score; /// The threshold of confidence coefficient. The candidate bounding boxes with a confidence coefficient lower than the threshold will be filtered out.
float nms; /// The threshold of NMS. During the Non-Maximum Suppression, the candidate bounding boxes with a overlapping ratio higher than the threshold will be filtered out.
int candidate_number; /// The maximum number of allowed candidate bounding boxes. Only the first 'candidate_number' of all the candidate bounding boxes will be kept.
} threshold_config_t;
min_face
is,
pyramid
is,
FAST
or NORMAL
FAST
: pyramid equals to 0.707106781
in default. At the same pyramid value, FAST
type is faster than NORMAL
type.NORMAL
: If you would like to customize pyramid value, set the type to NORMAL
please.score
is,
nms
is,
candidate_number
is, the longer the processing takes;candidate_number
of O-Net is, the larger number of detected faces isUsers can configure these parameters based on their actual requirements. Please also see the recommended configuration for general-purpose scenarios(one face detection) below:
mtmn_config.type = FAST;
mtmn_config.min_face = 80;
mtmn_config.pyramid = 0.707;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 20;
mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 10;
mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1;
Two versions of MTMN are available by now:
We evaluate all models with the same configuration and our own test set. The results are shown below.
mtmn_config.type = FAST;
mtmn_config.pyramid = 0.707;
mtmn_config.min_face = 80;
mtmn_config.pyramid_times = 4;
mtmn_config.p_threshold.score = 0.6;
mtmn_config.p_threshold.nms = 0.7;
mtmn_config.p_threshold.candidate_number = 100;
mtmn_config.r_threshold.score = 0.7;
mtmn_config.r_threshold.nms = 0.7;
mtmn_config.r_threshold.candidate_number = 100;
mtmn_config.o_threshold.score = 0.7;
mtmn_config.o_threshold.nms = 0.7;
mtmn_config.o_threshold.candidate_number = 1;
Average Time Consumption (ms) | |
---|---|
MTMN lite in quantization | 143.19 |
MTMN lite in float | 178.45 |
MTMN heavy in quantization | 242.84 |
Models can be selected through idf.py menuconfig
or make menuconfig
. Select Component config >> ESP-FACE Configuration >> Detection Model sequentially, you'll see options below.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。