PaddleHub 口罩检测

网络简介:

pip install --upgrade paddlehub -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install paddlepaddle

有误检:

import time

import cv2

import paddlehub as hub

import paddlehub as hub
module = hub.Module(name="pyramidbox_lite_mobile_mask")
# 将模型保存在test_program文件夹之中
# module.processor.save_inference_model(dirname="test_program")

module = hub.Module(name="pyramidbox_lite_mobile_mask")


def detect_img():
    img_data= cv2.imread(r"test_program/6e1c74e85298b5120f9f884ad348c243.jpg")

    input_dict = {"data": [img_data]}


    for i in range(10):
        start=time.time()
        # execute predict and print the result
        results = module.face_detection(data=input_dict)
        for result in results:
            left=float(result['data']['left'])
            right=float(result['data']['right'])
            bottom=float(result['data']['bottom'])
            top=float(result['data']['top'])
            conf=float( result['data']['confidence'])
            color=(0, 0, 255)
            if result['data']['label'] != 'MASK':
                color = (255, 0, 0)
            cv2.rectangle(img_data, (int(left),int(top)),(int(right),int(bottom)), color, 1)
        print("time", time.time() - start)
        cv2.imshow("asdf",img_data)
        cv2.waitKey(1)

开源地址:

https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/face_detection


三、预测
PaddleHub对于支持一键预测的module,可以调用module的相应预测API,完成预测功能。

In[8]
input_dict = {"image": test_img_path}

# execute predict and print the result
results = module.face_detection(data=input_dict)
for result in results:
    print(result)

# 预测结果展示
img = mpimg.imread("detection_result/test_mask_detection.jpg")
plt.figure(figsize=(10,10))
plt.imshow(img) 
plt.axis('off') 
plt.show()

https://www.paddlepaddle.org.cn/hubdetail?name=pyramidbox_lite_server_mask&en_category=ObjectDetection

pyramidbox_lite_mobile_mask

类别图像 - 目标检测

网络PyramidBox

数据集WIDER FACE数据集 + 百度自采人脸数据集

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

pyramidbox_lite_server_mask

类别图像 - 目标检测

网络PyramidBox

数据集WIDER FACE数据集 + 百度自采人脸数据集

你可能感兴趣的:(深度学习)