diff --git a/demo/mask_detection/README.md b/demo/mask_detection/README.md index d9e47a666ed3efd9e5d35e1e650ae266f5d6a226..f27ad8b9c982da500e154ba65259de9ffd48676e 100644 --- a/demo/mask_detection/README.md +++ b/demo/mask_detection/README.md @@ -8,7 +8,7 @@ - [3. 高性能C++部署方案](#3-高性能c部署方案) ## 1. 搭建视频流场景WebDemo -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/BB6BC87A45D146CEBA7BF237B5383835?ynotemdtimestamp=1582271320612) +![image](./images/web1.jpg) ### [>点击查看视频链接<](https://www.bilibili.com/video/av88962128) @@ -19,7 +19,7 @@ ### 效果分析 可以看到识别率在80~90%之前,稍小的人脸有误识别的情况,有些挡住嘴的场景也被误识别成了戴口罩,一个人带着口罩,鼻子漏出来识别成没有戴口罩,这个是合理的因为的鼻子漏出来是佩戴不规范。这个模型应用在门口,狭长通道,人脸识别机所在位置都是可以的。 -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/7E12DBD91D1D4AB5B33C84786D519065?ynotemdtimestamp=1582271320612)![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/2BD974FB990C4C448B30B04194545054?ynotemdtimestamp=1582271320612)![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/E49E34A071F8484D948511430FAB0360?ynotemdtimestamp=1582271320612) +![image](./images/mask1.jpg)![image](./images/mask2.jpg)![image](./images/mask3.jpg) ### 1.1 部署环境 参考: https://www.paddlepaddle.org.cn/install/quick @@ -32,7 +32,7 @@ #### 加载预训练模型 ```python import paddlehub as hub -module = hub.Module(name="pyramidbox_lite_server_mask", version='1.1.0') #口罩检测模型 +module = hub.Module(name="pyramidbox_lite_server_mask") #口罩检测模型 ``` >以上语句paddlehub会自动下载口罩检测模型 "pyramidbox_lite_mobile_mask" 不需要提前下载模型 @@ -108,7 +108,7 @@ for result in results: cv2.rectangle(frame, (left, top), (right, bottom), color, 3) cv2.putText(frame, label + ":" + str(confidence), (left, top-10), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2) ``` -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/F85FCBCA17994C8691024381CBDAFCA7?ynotemdtimestamp=1582271320612) +![image](./images/maskdetection_1.jpg) >原DEMO中是英文+置信度显示在框的上面,尝试改为中文,遇到字体问题,以下是解决办法 @@ -144,7 +144,7 @@ for result in results: # cv2.putText(frame, label + ":" + str(confidence), (left, top-10), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2) frame = paint_chinese_opencv(frame, label_cn + ":" + str(confidence), (left, top-36), 24, color) ``` -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/4F75E5C6F42F4C3CBE1341742D032847?ynotemdtimestamp=1582271320612) +![image](./images/maskdetection_2.jpg) #### 提取头像文件 @@ -171,10 +171,10 @@ with open("./result/2-mask_detection.json","w") as f: #### python 导出的数据 使用上面的 python 文件完整执行后会有3个种类的数据输出,放到`web/video/result`目录下 -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/329AC9C2D89447EABE6B8C45D620441E?ynotemdtimestamp=1582271320612) +![image](./images/result.jpg) #### json数据结构 -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/5D46F32061B047D4AB0AC016FE2A63A5?ynotemdtimestamp=1582271320612) +![image](./images/json.jpg) #### 使用数据渲染网页 @@ -182,7 +182,7 @@ with open("./result/2-mask_detection.json","w") as f: - 根据时间点换算为帧(1秒30帧),遍历 json 数据中的数据 - 把数据中对应的数据输出到网页右侧 "信息区" -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/6329B326216A4950BF35E0CB37CDC58F?ynotemdtimestamp=1582271320612) +![image](./images/web2.jpg) ## 2. 高性能Python部署方案 @@ -196,6 +196,6 @@ with open("./result/2-mask_detection.json","w") as f: **百度飞桨合作伙伴:** -![image](https://note.youdao.com/yws/public/resource/b0a4695bc7d58aed3b1ff797409aee1e/DC72DE1CF51747138871BB0E3D54E20D?ynotemdtimestamp=1582271320612) +![image](./images/logo.jpg) 北京奇想天外科技有限公司 diff --git a/demo/mask_detection/images/json.jpg b/demo/mask_detection/images/json.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b8510aa9d218767f742d2970d0c6b23e7749a714 Binary files /dev/null and b/demo/mask_detection/images/json.jpg differ diff --git a/demo/mask_detection/images/logo.jpg b/demo/mask_detection/images/logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f57b7f11992ad53cf4d1460b6787e79566ee378a Binary files /dev/null and b/demo/mask_detection/images/logo.jpg differ diff --git a/demo/mask_detection/images/mask1.jpg b/demo/mask_detection/images/mask1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..137007049f17e83d967ecdf6a5c97e68da6aaa19 Binary files /dev/null and b/demo/mask_detection/images/mask1.jpg differ diff --git a/demo/mask_detection/images/mask2.jpg b/demo/mask_detection/images/mask2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8ab234aea50b2983f4fc151c51de8ead3f8a370c Binary files /dev/null and b/demo/mask_detection/images/mask2.jpg differ diff --git a/demo/mask_detection/images/mask3.jpg b/demo/mask_detection/images/mask3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..69e000c93373f13d0a36aef60b9fbb7575b79ca0 Binary files /dev/null and b/demo/mask_detection/images/mask3.jpg differ diff --git a/demo/mask_detection/images/maskdetection_1.jpg b/demo/mask_detection/images/maskdetection_1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e9aa821715c8eb37c5dd1030363e5463bf34141a Binary files /dev/null and b/demo/mask_detection/images/maskdetection_1.jpg differ diff --git a/demo/mask_detection/images/maskdetection_2.jpg b/demo/mask_detection/images/maskdetection_2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9d68708e838a0c0721adfa9f0bf3bdf08b1cdfd7 Binary files /dev/null and b/demo/mask_detection/images/maskdetection_2.jpg differ diff --git a/demo/mask_detection/images/result.jpg b/demo/mask_detection/images/result.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3a1e6105d77433a8d6ccbba3ec9c7bf7586a81c4 Binary files /dev/null and b/demo/mask_detection/images/result.jpg differ diff --git a/demo/mask_detection/images/web1.jpg b/demo/mask_detection/images/web1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0a351f5ae161c909d90f92a1acb6b7f2d2386a2d Binary files /dev/null and b/demo/mask_detection/images/web1.jpg differ diff --git a/demo/mask_detection/images/web2.jpg b/demo/mask_detection/images/web2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4d49ecb542a1242a76a01527da20a51e56f44808 Binary files /dev/null and b/demo/mask_detection/images/web2.jpg differ diff --git a/demo/mask_detection/mask_detection.py b/demo/mask_detection/mask_detection.py index 1eaaee0c773f76e60ae7da2022df2f1850bd50c5..6e6e827520240409ec7982920fa6fc3e28f0dd5c 100644 --- a/demo/mask_detection/mask_detection.py +++ b/demo/mask_detection/mask_detection.py @@ -6,15 +6,16 @@ import numpy as np import json import os -module = hub.Module(name="pyramidbox_lite_server_mask", version='1.1.0') +module = hub.Module(name="pyramidbox_lite_server_mask") # opencv输出中文 def paint_chinese(im, chinese, position, fontsize, color_bgr): # 图像从OpenCV格式转换成PIL格式 img_PIL = Image.fromarray(cv2.cvtColor(im, cv2.COLOR_BGR2RGB)) - font = ImageFont.truetype( - 'SourceHanSansSC-Medium.otf', fontsize, encoding="utf-8") + font = ImageFont.truetype('SourceHanSansSC-Medium.otf', + fontsize, + encoding="utf-8") #color = (255,0,0) # 字体颜色 #position = (100,100)# 文字输出位置 color = color_bgr[::-1]