Baidu industry's first open source mask face detection and classification models

The fight against the epidemic, united, artificial intelligence technology is being applied to the epidemic prevention and control in the past.

February 13, Baidu announced the industry's first free, open source mask face detection and classification models. The model can effectively detect and carry the owner did not wear a mask carrying a dense crowd in the face area, while the judge whether to wear a mask. Open source has to fly through PaddleHub paddle out, the majority of developers with a few lines of code can quickly get started, free calls.

Model Visualization: a mask to be worn green boxes marked with a red frame is not wearing the mask denoted

With each week, companies have to return to work after the holiday economy began to recover, face masks detection scheme has become an important demand rework tide in many communities, large companies, central enterprises. Such as the work area to determine whether the staff wear masks, how crowded transportation center mark to identify people wearing masks and face temperature, whether wearing a mask can be completed daily brush face punch, etc. ...... are real pain points to be addressed under the new crown pneumonia outbreak .

The self-declared free open-source research masks face detection and classification model is based on research papers PyramidBox 2018 Baidu included in the top international Conference on Computer Vision ECCV can detect human faces in the mass crowded public scene at the same time, will wear not wearing masks and face masks quick identification mark. Based on this pre-training model, developers need only use a small amount of its own data, you can quickly develop its own model of the scene.

Baidu R & D engineer, masks, face detection and classification model consists of two functional units, can complete classification masks face detection and face masks, respectively. After testing, the face detection algorithm based backbone network faceboxes model joined the more than 100,000 face masks training data can be accurate in 98% of cases, the recall rate was significantly increased by 30%. The face masks judgment model can achieve determine whether to wear face masks, masks discrimination accuracy rate of 96.5%, to meet the conventional mask inspection needs . The developer may also be based on its own model to optimize the second scene data can further enhance the model precision and recall rates.

Behind such a high accuracy is the result of a large amount of training data, the new model uses a training data over one hundred thousand pictures, to ensure adequate and effective sample size. On the other hand, face detection self-development model Baidu championship algorithm, the entire development process is based on open source Baidu fly paddle depth learning platform enables efficient and convenient model development, training and deployment.

Online demonstration effect: green bounding box is wearing a mask face, red bounding box to not wear a mask face. Interested developers can upload their own pictures to test the effect of the model.

Online Demo Address:

https://www.paddlepaddle.org.cn/hub/scene/maskdetect

For the actual scene lighting, occlusion mask, changes in the expression, scale changes and so on, the model is robust and can be detected in real time in a variety of different end edge, cloud device, to be truly useful in the landing process.

Pre-training model, the immediate deployment

In order to facilitate developers to maximize application, Baidu deep learning platform will fly paddle face mask detection model out of open source by a simple-to-use pre-training model management tools PaddleHub, just basic python programming skills, you can quickly get started calling, if you have certain mobile terminal APP and development capabilities, the model can be quickly deployed to the mobile terminal.

Top algorithms and data

This program, the model for face recognition in 2018, Baidu's top International Conference on Computer Vision ECCV papers PyramidBox 2018 based on the research and development, training based on self-depth study of fly paddle open-source learning platform, and through PaddleSlim and other miniaturized models technical such algorithm can run efficiently on a limited number of operator force device.

Furthermore fly paddle will also provide secondary development tool component mass, and the associated detection algorithms more human face, all of the above techniques and tools are open source and free.

Practice

As long as five lines of code, you can deal with face detection masks on their computers. In the case of actual CPU detects substantially real time, very fast estimation. The following is the core code to call a pre-training model, which in the current folder decentralization of a test image:

import paddlehub as hub
# 加载模型,本例为服务器端模型pyramidbox_lite_server_mask# 移动端模型参数可以换成pyramidbox_lite_mobile_maskmodule = hub.Module(name="pyramidbox_lite_server_mask")
# 设置输入数据input_dict = {"image": ["test.jpg"]}for data in module.face_detection(data=input_dict):    print(data)

More importantly, as a complete open-source work, in addition to local infer that also need to consider how to deploy the model to the server or mobile device. If we can quickly deploy to all platforms, it really means it can be used as basic tools "Contagion" is.

Currently, Baidu provides two pre-training model that masks the server side face detection and classification models "pyramidbox_lite_server_mask" mobile terminal masks and face detection and classification models "pyramidbox_lite_mobile_mask", both of which can meet various downstream tasks.

1. step deployment server

With PaddleHub, deploy the server is also very simple, direct use of a command line server startup masks, face detection and classification models on the list:

hub serving start -m pyramidbox_lite_server_mask -p 8866

2. deployed to the mobile terminal

Paddle Lite fly paddle end inference engine, specifically for the deployment of mobile terminal inference model. If you need to put a mask face detection and classification model is embedded into mobile phones and other mobile devices, so this side Paddle Lite inference engine can help save a lot of work.

Deploy masks face detection and classification model in the mobile terminal, need only three steps:

① download forecasts library, Paddle Lite will provide forecast compiled libraries;

② optimization model, using model_optimize_tool tools to achieve optimization model;

③ implementation calls by predicting API.

Developers can face masks recognition model by PaddleHub download people. After the normal installation PaddleHub, the following code can be executed by python Download and save the model to save the download mobile end face masks recognition model as an example:

import paddlehub as hub
module = hub.Module(name="pyramidbox_lite_mobile_mask")
# Save the model in a folder in test_program
module.processor.save_inference_model(dirname="test_program")

Through the above code, you can get face detection and estimation model wearing masks, are stored in pyramidbox_lite and mask_detector subfolder under the folder in the directory test_program. Folder __model__ model is structured file, __ param__ file is a file weights.

Paddle Lite description:

https://github.com/PaddlePaddle/Paddle-Lite

The more important is the API call method in a mobile terminal, please refer to the Paddle Lite specific implementation example of the address given below.


// 读取图片

cv::Mat img = imread(img_path, cv::IMREAD_COLOR);

// 加载人脸检测或者口罩佩戴判别模型

MobileConfig config;

config.set_model_dir(model_dir);

PaddlePredictor* predictor =

      CreatePaddlePredictor<MobileConfig>(config);

// 设置输入

Tensor* input_tensor = predictor->GetInput(0);

input_tensor->Resize({1, 3, img.rows,img.cols});

set_input(img, input_tensor); //调用自定义函数

// 执行

predictor->Run();

// 输出结果

Tensor* output_tensor = predictor->GetOutput(0);

show_output(img, output_tensor); //调用自定义函数

Face masks worn and determines exemplary deployment of address of the mobile terminal:

https://github.com/PaddlePaddle/Paddle-Lite/tree/develop/lite/demo/cxx

Guess you like

Origin www.oschina.net/news/113372/paddlepaddle-news