├── .gitignore ├── K210固件 ├── maixpy_v0.6.2_77_g11806960d.bin ├── maixpy_v0.6.2_77_g11806960d_minimum_with_ide_support.bin ├── maixpy_v0.6.2_77_g11806960d_minimum_with_kmodel_v4_support.bin ├── maixpy_v0.6.2_77_g11806960d_openmv_kmodel_v4_with_ide_support.bin ├── maixpy_v0.6.2_78_g469c985e6_minimum.bin ├── readme.md └── with_ovm.bin ├── LICENSE ├── README.md ├── dataset ├── labels.zip ├── pics │ ├── with_correct_mask.7z │ ├── with_incorrect_mask.7z │ └── without_mask.7z └── readme.md ├── labelImg.exe ├── pics ├── 产品内部结构.jpg ├── 产品外观.jpg ├── 图 3.10音频模块.png ├── 图 4.4.2 音频模块.jpg ├── 图4.1.1 摄像头模块(pyAI-K210 CAM).png ├── 图4.1.2摄像头连接方式(金手指朝下) .png ├── 图4.1.3 摄像头模块流程图.png ├── 图4.2.1 测温模块(MLX90614).png ├── 图4.2.2 测温模块连接方式.png ├── 图4.2.3 测温模块流程图.png ├── 图4.3.1 K210芯片主图.png ├── 图4.3.2 K210电脑连接方式.png ├── 图4.4.1 LCD显示屏.png ├── 图4.4.3 舵机模块1.png ├── 图4.4.3 舵机模块2.png └── 系统结构图 .jpg ├── 《MicroPython从0到1》基于K210平台_v1.0--01Studio编著(1).pdf ├── 主要控制代码 ├── mlx90614.py └── summary.py ├── 模型文件 ├── 1 │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test1.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt ├── 2 │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test2.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt ├── 3 │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test3.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt ├── 4 │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test4.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt ├── 5 │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test5.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt ├── TinyYolo │ ├── Loss.html │ ├── Loss.jpg │ ├── anchors.txt │ ├── lable.txt │ ├── test6.kmodel │ ├── yolov2.h5 │ ├── yolov2.tflite │ └── 新建文本文档.txt └── readme.md ├── 测试用代码 ├── LcdDisplayTest.py ├── audio.py ├── camera.py ├── test.py ├── threading.py ├── 测温模块.py └── 舵机.py └── 用到的语音文件和图片 ├── abnormal_temp.mp3 ├── abnormal_temp.wav ├── audio_readme.txt ├── get_temp_error.jpg ├── model_load_error.jpg ├── normal_temp.mp3 ├── normal_temp.wav ├── readme.md ├── with_correct_mask.mp3 ├── with_correct_mask.wav ├── with_incorrect_mask.mp3 ├── with_incorrect_mask.wav ├── without_mask.mp3 └── without_mask.wav /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /K210固件/maixpy_v0.6.2_77_g11806960d.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/maixpy_v0.6.2_77_g11806960d.bin -------------------------------------------------------------------------------- /K210固件/maixpy_v0.6.2_77_g11806960d_minimum_with_ide_support.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/maixpy_v0.6.2_77_g11806960d_minimum_with_ide_support.bin -------------------------------------------------------------------------------- /K210固件/maixpy_v0.6.2_77_g11806960d_minimum_with_kmodel_v4_support.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/maixpy_v0.6.2_77_g11806960d_minimum_with_kmodel_v4_support.bin -------------------------------------------------------------------------------- /K210固件/maixpy_v0.6.2_77_g11806960d_openmv_kmodel_v4_with_ide_support.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/maixpy_v0.6.2_77_g11806960d_openmv_kmodel_v4_with_ide_support.bin -------------------------------------------------------------------------------- /K210固件/maixpy_v0.6.2_78_g469c985e6_minimum.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/maixpy_v0.6.2_78_g469c985e6_minimum.bin -------------------------------------------------------------------------------- /K210固件/readme.md: -------------------------------------------------------------------------------- 1 | ## 固件说明 2 | #### 不同的固件根据命名不同,里面有的含有的功能也不同。 3 | #### 要想让K210开发板可以插电直接运行,就必须刷不带ide支持的固件 4 | #### 因为板载内存比较小,但是要运行人工智能模型的话会自动将模型加载到内存里, 5 | #### 要是固件比较大,可能会加载模型不成功,可以多次尝试刷不同固件 6 | 7 | ## 固件下载网址是:http://cn.dl.sipeed.com/shareURL/MAIX/MaixPy/release/master 8 | ## 或者在官网可以定制固件 9 | -------------------------------------------------------------------------------- /K210固件/with_ovm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/K210固件/with_ovm.bin -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | - [项目介绍](#项目介绍) 2 | - [演示视频](#演示视频) 3 | - [系统框图](#系统框图) 4 | - [数据集及标注](#数据集及标注) 5 | - [1. 数据集获取](#1-数据集获取) 6 | - [2. 标注](#2-标注) 7 | - [3. 标注好的数据集](#3-标注好的数据集) 8 | - [训练过程及模型转换](#训练过程及模型转换) 9 | - [硬件模块介绍](#硬件模块介绍) 10 | - [总体控制代码](#总体控制代码) 11 | - [遇到问题的解决](#创新之处和遇到问题的解决) 12 | - [1. 研发过程中遇到的问题](#1-研发过程中遇到的问题) 13 | - [1)测温模块在程序运行中一直返回温度值,是测得的环境温度](#1测温模块在程序运行中一直返回温度值是测得的环境温度) 14 | - [2) 口罩识别模型会对摄像头采集的每一帧图像进行识别,如果对模型输出的每一个预测结果做出反应的话,会造成系统过于混乱](#2-口罩识别模型会对摄像头采集的每一帧图像进行识别如果对模型输出的每一个预测结果做出反应的话会造成系统过于混乱) 15 | - [3) 由于K210开发板可用接口有限,在正常的插上测温模块后就不能插舵机模块了。](#3-由于k210开发板可用接口有限在正常的插上测温模块后就不能插舵机模块了) 16 | - [2. 测试阶段遇到的问题](#2-测试阶段遇到的问题) 17 | - [1) 语音播报模块在播放完音频后会有一声比较短暂刺耳的爆音](#1-语音播报模块在播放完音频后会有一声比较短暂刺耳的爆音) 18 | - [2) 模型对测试数据集预测效果不好,准确率较低](#2-模型对测试数据集预测效果不好准确率较低) 19 | - [不足待改进之处](#不足待改进之处) 20 | - [1. 弱光条件下识别准备率有待提升](#1-弱光条件下识别准备率有待提升) 21 | - [1) 原因](#1-原因) 22 | - [2) 建议改进措施](#2-建议改进措施) 23 | - [2. 远距离识别准确率不高](#2-远距离识别准确率不高) 24 | - [1) 原因](#1-原因-1) 25 | - [2) 建议改进措施](#2-建议改进措施-1) 26 | - [3. 测温模块精度不高](#3-测温模块精度不高) 27 | - [1) 原因](#1-原因-2) 28 | - [2) 建议改进措施](#2-建议改进措施-2) 29 | - [产品图](#产品图) 30 | - [1. 内部结构](#1-内部结构) 31 | - [2. 产品外观图](#2-产品外观图) 32 | - [参考资料](#参考资料) 33 | 34 | ### 项目介绍 35 | 36 | ​ 人脸口罩佩戴识别监测系统是一款集口罩识别、体温检测、语音播报和门闸开合于一体的智能识别反馈系统,它利用yolov2神经网络训练生成的模型进行人脸识别,具有较高的准确性、较低的时延等特性。 37 | 38 | ​ 该设备能够针对口罩佩戴情况进行不同的内容反馈,并且语音提示,如果符合通过条件,可以控制闸机进行人员分流,非常适合当前后疫情时代的公共场所的疫情防控需求。 39 | 40 | ### 演示视频 41 | [![演示视频](https://res.cloudinary.com/marcomontalbano/image/upload/v1653838400/video_to_markdown/images/youtube--jPf7qErI8BM-c05b58ac6eb4c4700831b2b3070cd403.jpg)](https://www.youtube.com/watch?v=jPf7qErI8BM "演示视频") 42 | 43 | ### 系统框图 44 | 45 | #### 1. 系统框图 46 | 47 | ![系统框图](https://github.com/the-light011/Face-Mask-detction-DeepLearning/blob/main/pics/%E7%B3%BB%E7%BB%9F%E7%BB%93%E6%9E%84%E5%9B%BE%20.jpg) 48 | 49 | **注:** 系统框图与最终实现有所差别 50 | 51 | ### 数据集及标注 52 | 53 | #### 1. 数据集获取 54 | 55 | 训练的数据集是来自互联网的公开数据集,链接如下: 56 | 57 | https://github.com/cabani/MaskedFace-Net,里面有正确佩戴口罩和不正确佩戴口罩的数据集,各有20Gb左右。 58 | 59 | https://github.com/balajisrinivas/Face-Mask-Detection/tree/master/dataset,里面有未佩戴口罩的数据集 60 | 61 | 我们用到的K210开发板在运行图像识别的时候,模型只能输入224*224大小的图片,所以需要先将数据集大小调整为**224\*224**. 62 | 63 | #### 2. 标注 64 | 65 | 用到的标注软件为 **labelImg**,下载链接为:https://wwt.lanzoul.com/iAXAG05bnjxc, 66 | 67 | 或其他标注软件也可以,需要把标注结果导出为xml格式 68 | 69 | #### 3. 标注好的数据集 70 | 71 | 下载链接如下, 72 | 73 | pics: https://www.aliyundrive.com/s/cRFP1YaU9WM 74 | 75 | labels: https://www.aliyundrive.com/s/uMY9xoWPovu 76 | 77 | pics文件夹里存放图片,分为三类:with_correct_mask/with_incorrect_mask/without_mask 78 | 79 | labels文件夹中存放标签,为xml格式 80 | 81 | **注:** 用开发板的摄像头拍摄多张照片多为数据集的一部分可以提高模型的识别精度 82 | 83 | ### 训练过程及模型转换 84 | 85 | 由于K210开发板只支持YOLOV2和V3,我们采用YOLOV2框架来进行训练 86 | 87 | 环境配置及训练方法见链接: 88 | 89 | [Mx-yolov3+Maixpy+ K210进行本地模型训练和目标检测_我与nano的博客-CSDN博客_k210芯片](https://blog.csdn.net/qq_51963216/article/details/121044449?utm_source=app&app_version=5.1.1) 90 | 91 | [[人工智能\]更新:Mx-yolov3 3.0版本 (qq.com)](https://mp.weixin.qq.com/s/OpFfBedx2MrLX7QeQBJPrw) 92 | 93 | K210开发板只能运行kmodel格式的模型文件,所以需要将训练好的tilite、pt、h5等格式的模型转换成kmodel格式的模型。我们采用的是**NCC**工具箱,上面的链接中有提到。 94 | 95 | ### 硬件模块介绍 96 | #### 用到的开发板是K210开发板,详细介绍见稚晖君在知乎上的这篇文章:https://zhuanlan.zhihu.com/p/81969854 介绍的很详细 97 | 98 | 99 | ### 总体控制代码 100 | #### 总体控制代码见: 主要控制代码/summary.py 101 | 其中还有一个py文件叫 mlx90614,是红外测温模块的底层代码,需要复制到sd卡根目录,或者用maxpyide发送到开发板上 102 | 其中模型文件、音频文件和各种提示图片需要自己准备。将各种文件存到SD卡中,插在K210开发板上即可运行 103 | 104 | ### 创新之处和遇到问题的解决 105 | 106 | #### 1. 研发过程中遇到的问题 107 | 108 | ##### 1)测温模块在程序运行中一直返回温度值,是测得的环境温度 109 | 110 | **解决办法**:经过分析后可得在程序的循环中,测温模块一直在测量温度。将控制程序改为只有在识别到正确佩戴口罩后才会测量温度。设定[34.5 37.9]的温度区间,低于最低值是认为测得的是环境温度,测温失败;高于该区间的最大值后认为体温异常,播放声音提醒。并且在5秒内没有测得大于温度区间最小值的温度后,视为放弃测温,程序进入下一次循环。 111 | 112 | ##### 2) 口罩识别模型会对摄像头采集的每一帧图像进行识别,如果对模型输出的每一个预测结果做出反应的话,会造成系统过于混乱 113 | 114 | **解决办法**:我们在发现这个问题后,认为模型对摄像头采集的每一帧进行预测并作出后续反应的话,会造成系统混乱,因为模型有小概率会识别不稳定。经过几天的仔细思考,发现可以利用模型识别的累积效果,引入状态列表和状态和变量,将模型识别10的结果存入状态列表中,并在状态列表长度为10时计算状态和。模型识别结果0为without_mask, 1为with_correct_mask, 2为with_incorrect_mask. 若状态和小于3,则认为这10次中多数都是without_mask,识别为正确佩戴口罩;若状态和在7到13之间,则认为10次中多数都是with_correct_mask,识别为正确佩戴口罩;若状态和大于17,则认为10次中多数是with_incorrect_mask,识别为口罩佩戴不正确。 115 | 116 | ​ 经过这样的累计效果后,系统可以正常工作,识别精度也有提升,但是正确佩戴口罩和口罩佩戴不正确会识别错误,分析原因是,由于模型预测结果2被认为是with_incorrect_mask,所以10次中有少数的with_incorrect_mask和多数的with_correct_mask也会被判定为口罩配得不正确。将模型预测结果1改为with_incoeerct_mask,2改为with_correct_mask后,这个问题有很大改善,识别精度进一步提高。 117 | 118 | ##### 3) 由于K210开发板可用接口有限,在正常的插上测温模块后就不能插舵机模块了。 119 | 120 | **解决方法**:比较容易的解决方案是再买一个pybase拓展板来接舵机,但是由于财力有限,不能支付得起拓展板的钱。在深入研究测温模块的排线结构后发现测温模块可以不用全部接在K210开发板上,只需4条线接入即可,这样给舵机模块留下了接口。可以把测温模块固定到其他地方,用几根杜邦线就把测温模块和舵机模块接到K210开发板上。 121 | 122 | 123 | 124 | #### 2. 测试阶段遇到的问题 125 | 126 | ##### 1) 语音播报模块在播放完音频后会有一声比较短暂刺耳的爆音 127 | 128 | **解决方法**: 在语音播报的测试程序中,播放完声音序列后加上100ms的短暂延时,使程序不要过快的结束掉,可以解决爆音问题 129 | 130 | ##### 2) 模型对测试数据集预测效果不好,准确率较低 131 | 132 | **解决方法**:经过排查,是测试程序中anchors值不对,anchors需要有训练时的数据集计算得到。在更改anchors值后,测试精度有了很大提高 133 | 134 | ### 不足待改进之处 135 | 136 | #### 1. 弱光条件下识别准备率有待提升 137 | 138 | ##### 1) 原因 139 | 140 | 受摄像头硬件性能限制,在弱光条件下摄像头采集的图像较模糊,使模型不能正确判断口罩佩戴情况,造成识别正确率下降和延迟上升。 141 | 142 | ##### 2) 建议改进措施 143 | 144 | + 更换拍摄质量更好、像素更高的摄像头 145 | 146 | + 在摄像头附近增加补光灯和光敏传感器,在光敏传感器检测到光照条件低于一定阈值后,在识别口罩的时候打开补光灯补光;在光照良好的情况下不开补光灯。 147 | 148 | #### 2. 远距离识别准确率不高 149 | 150 | ##### 1) 原因 151 | 152 | 受摄像头设置所限,在距离较远时采集的图像模糊,使模型不能正确判断口罩佩戴情况,造成识别正确率下降和延迟上升。 153 | 154 | ##### 2) 建议改进措施 155 | 156 | + 更换拍摄质量更好、像素更高的摄像头 157 | 158 | #### 3. 测温模块精度不高 159 | 160 | ##### 1) 原因 161 | 162 | + 财力有限,并且目前K210只能支持这样的测温模块,导致测温模块质量不好,精度不高,目前为 +- 0.3℃ 163 | 164 | ##### 2) 建议改进措施 165 | 166 | + 有条件就更换精度更高的测温模块, 167 | + 或者自己根据K210的引脚接口设计一款测温模块 168 | 169 | ### 产品图 170 | 171 | #### 1. 内部结构 172 | 173 | ![内部结构](https://github.com/the-light011/Face-Mask-detction-DeepLearning/blob/main/pics/%E4%BA%A7%E5%93%81%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84.jpg) 174 | 175 | #### 2. 产品外观图 176 | 177 | ![产品外观图](https://github.com/the-light011/Face-Mask-detction-DeepLearning/blob/main/pics/%E4%BA%A7%E5%93%81%E5%A4%96%E8%A7%82.jpg) 178 | 179 | ### 参考资料 180 | 181 | + [《MicroPython从0到1》基于K210平台](https://www.aliyundrive.com/s/hwAWwdLGmvT) 182 | + [固件及开发软件IDE下载]([下载站 - Sipeed](http://cn.dl.sipeed.com/MAIX/MaixPy/ide/_/v0.2.4)) 183 | + [官方文档]([MaixPy 文档简介 - Sipeed Wiki](https://wiki.sipeed.com/soft/maixpy/zh/index.html)) 184 | + [Sipeed MaixHub – sipeed AI 模型平台](https://www.maixhub.com/) 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /dataset/labels.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/dataset/labels.zip -------------------------------------------------------------------------------- /dataset/pics/with_correct_mask.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/dataset/pics/with_correct_mask.7z -------------------------------------------------------------------------------- /dataset/pics/with_incorrect_mask.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/dataset/pics/with_incorrect_mask.7z -------------------------------------------------------------------------------- /dataset/pics/without_mask.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/dataset/pics/without_mask.7z -------------------------------------------------------------------------------- /dataset/readme.md: -------------------------------------------------------------------------------- 1 | ## 标签: 2 | ### 0 --> with_correct_mask 3 | ### 1 --> with_incorrect_mask 4 | ### 2 --> without_mask 5 | -------------------------------------------------------------------------------- /labelImg.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/labelImg.exe -------------------------------------------------------------------------------- /pics/产品内部结构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/产品内部结构.jpg -------------------------------------------------------------------------------- /pics/产品外观.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/产品外观.jpg -------------------------------------------------------------------------------- /pics/图 3.10音频模块.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图 3.10音频模块.png -------------------------------------------------------------------------------- /pics/图 4.4.2 音频模块.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图 4.4.2 音频模块.jpg -------------------------------------------------------------------------------- /pics/图4.1.1 摄像头模块(pyAI-K210 CAM).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.1.1 摄像头模块(pyAI-K210 CAM).png -------------------------------------------------------------------------------- /pics/图4.1.2摄像头连接方式(金手指朝下) .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.1.2摄像头连接方式(金手指朝下) .png -------------------------------------------------------------------------------- /pics/图4.1.3 摄像头模块流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.1.3 摄像头模块流程图.png -------------------------------------------------------------------------------- /pics/图4.2.1 测温模块(MLX90614).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.2.1 测温模块(MLX90614).png -------------------------------------------------------------------------------- /pics/图4.2.2 测温模块连接方式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.2.2 测温模块连接方式.png -------------------------------------------------------------------------------- /pics/图4.2.3 测温模块流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.2.3 测温模块流程图.png -------------------------------------------------------------------------------- /pics/图4.3.1 K210芯片主图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.3.1 K210芯片主图.png -------------------------------------------------------------------------------- /pics/图4.3.2 K210电脑连接方式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.3.2 K210电脑连接方式.png -------------------------------------------------------------------------------- /pics/图4.4.1 LCD显示屏.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.4.1 LCD显示屏.png -------------------------------------------------------------------------------- /pics/图4.4.3 舵机模块1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.4.3 舵机模块1.png -------------------------------------------------------------------------------- /pics/图4.4.3 舵机模块2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/图4.4.3 舵机模块2.png -------------------------------------------------------------------------------- /pics/系统结构图 .jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/pics/系统结构图 .jpg -------------------------------------------------------------------------------- /《MicroPython从0到1》基于K210平台_v1.0--01Studio编著(1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/《MicroPython从0到1》基于K210平台_v1.0--01Studio编著(1).pdf -------------------------------------------------------------------------------- /主要控制代码/mlx90614.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 要求: 3 | i2c = SoftI2C(scl=x, sda=x) 4 | temp = mlx90614.MLX90614(i2c) 5 | temp.ObjectTemp() #返回物体温度 6 | temp.AmbientTemp() #返回周围温度 7 | 作者:01Studio用户:jd3096 8 | 技术社区:bbs.01studio.cc 9 | ''' 10 | 11 | import ustruct,utime 12 | from micropython import const 13 | 14 | _TA_ADDRESS = const(0x06) 15 | _TOBJ1_ADDRESS = const(0x07) 16 | _TOBJ2_ADDRESS = const(0x08) 17 | 18 | class MLX90614: 19 | def __init__(self, i2c): 20 | self.i2c = i2c 21 | self.address = 0x5a 22 | 23 | def readdata(self, register): 24 | try: 25 | data = self.i2c.readfrom_mem(self.address, register, 2) 26 | return ustruct.unpack('= recognition_number: 157 | state_sum = sum(state_flag) 158 | if state_sum < offset: # 如果和小于offset,则表明都是第一类,即classid为0 159 | check_sum = state_sum 160 | state_flag = [] 161 | state_sum = 0 162 | return True, state_flag, state_sum, check_sum 163 | elif state_sum > (recognition_number-offset) and state_sum < (recognition_number+offset): 164 | check_sum = state_sum 165 | state_flag = [] 166 | state_sum = 0 167 | return True, state_flag, state_sum, check_sum 168 | elif state_sum > (2*recognition_number-offset): 169 | check_sum = state_sum 170 | state_flag = [] 171 | state_sum = 0 172 | return True, state_flag, state_sum, check_sum 173 | else: 174 | state_flag = [] 175 | state_sum = 0 176 | return False, state_flag, state_sum, check_sum 177 | 178 | 179 | # 舵机开门-延时-关门 180 | def servo_control(): 181 | """开始舵机处于复位状体,也就是关门状态""" 182 | Servo(S1, -90) 183 | time.sleep_ms(3000) 184 | Servo(S1, 0) 185 | 186 | 187 | 188 | # ==========正式控制流程============= 189 | # 开机画面 190 | start_up() 191 | 192 | # 摄像头开始拍摄 193 | sensor.run(1) 194 | 195 | # 舵机复位 196 | Servo(S1, 0) # 舵机复位成关门状态 197 | 198 | # 加载模型 199 | try: 200 | task = load_model(model_addr, anchors) 201 | except: 202 | display_signal_pic(model_load_error) 203 | time.sleep_ms(10000) 204 | # 退出程序 205 | sys.exit() 206 | 207 | state_flag = [] # 状态标志列表 208 | state_sum = 0 # 状态和 209 | check_sum = 0 # 记录每次判断的状态和,将清零前的最后一次用作状态的判断 210 | flag = True 211 | while flag: 212 | # 摄像头抓取图像 213 | img = sensor.snapshot() 214 | # 调用模型识别 215 | objects = kpu.run_yolo2(task, img) 216 | if objects: 217 | # 设只检测出一个脸,所以取objects中第一个元素 218 | obj = objects[0] 219 | state, state_flag, state_sum, check_sum = determine_final_state(obj, state_flag, state_sum, check_sum) 220 | if state: 221 | classid = int(check_sum / recognition_number + 0.5) # 取整数 222 | display_rectangle_str(position=obj.rect(), label=labels[classid], 223 | color=rectangle_colors[classid], scale=2, img=img) 224 | lcd.display(img) 225 | # 播放声音 226 | audio_play(audio_list[classid]) 227 | if classid == 2: # 即正确佩戴口罩 228 | # 测温部分 229 | temp = get_temp(i2c) 230 | if temp == None: 231 | img.draw_string(50, 200, 'get temop failed!!!', scale=2, color=(255, 0, 0)) # 测温失败,显示为红色 232 | lcd.display(img) 233 | time.sleep_ms(500) 234 | elif temp >= normal_temp[1]: 235 | img.draw_string(140, 200, str(temp)+" C", scale=2, color=(255, 0, 0)) # 温度较高,显示为红色 236 | lcd.display(img) 237 | time.sleep_ms(300) 238 | audio_play('audio/abnormal_temp.wav') 239 | else: 240 | img.draw_string(140, 200, str(temp)+" C", scale=2, color=(0, 255, 0)) # 温度正常显示为绿色 241 | lcd.display(img) 242 | audio_play('audio/normal_temp.wav') 243 | # 舵机符合条件后转动 244 | servo_control() 245 | continue 246 | else: 247 | state_flag = [] 248 | lcd.display(img) 249 | 250 | -------------------------------------------------------------------------------- /模型文件/1/Loss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Awesome-pyecharts 6 | 7 | 8 | 9 | 10 |
11 | 919 | 920 | 921 | -------------------------------------------------------------------------------- /模型文件/1/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/1/Loss.jpg -------------------------------------------------------------------------------- /模型文件/1/anchors.txt: -------------------------------------------------------------------------------- 1 | 1.8125, 5.2812, 6.3818, 6.303, 6.4549, 5.4601, 6.6285, 5.9705, 6.7067, 6.6418 -------------------------------------------------------------------------------- /模型文件/1/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/1/test1.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/1/test1.kmodel -------------------------------------------------------------------------------- /模型文件/1/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/1/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/1/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/1/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/1/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 16 2 | ALpha 0.25 3 | train numbers 73 -------------------------------------------------------------------------------- /模型文件/2/Loss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Awesome-pyecharts 6 | 7 | 8 | 9 | 10 |
11 | 959 | 960 | 961 | -------------------------------------------------------------------------------- /模型文件/2/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/2/Loss.jpg -------------------------------------------------------------------------------- /模型文件/2/anchors.txt: -------------------------------------------------------------------------------- 1 | 1.8125, 5.2812, 6.3818, 6.303, 6.4549, 5.4601, 6.6285, 5.9705, 6.7067, 6.6418 -------------------------------------------------------------------------------- /模型文件/2/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/2/test2.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/2/test2.kmodel -------------------------------------------------------------------------------- /模型文件/2/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/2/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/2/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/2/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/2/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 16 2 | ALpha 0.5 3 | train numbers 80 -------------------------------------------------------------------------------- /模型文件/3/Loss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Awesome-pyecharts 6 | 7 | 8 | 9 | 10 |
11 | 775 | 776 | 777 | -------------------------------------------------------------------------------- /模型文件/3/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/3/Loss.jpg -------------------------------------------------------------------------------- /模型文件/3/anchors.txt: -------------------------------------------------------------------------------- 1 | 1.8125, 5.2812, 6.3818, 6.303, 6.4549, 5.4601, 6.6285, 5.9705, 6.7067, 6.6418 -------------------------------------------------------------------------------- /模型文件/3/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/3/test3.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/3/test3.kmodel -------------------------------------------------------------------------------- /模型文件/3/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/3/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/3/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/3/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/3/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 16 2 | ALpha 0.75 3 | train numbers 58 -------------------------------------------------------------------------------- /模型文件/4/Loss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Awesome-pyecharts 6 | 7 | 8 | 9 | 10 |
11 | 959 | 960 | 961 | -------------------------------------------------------------------------------- /模型文件/4/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/4/Loss.jpg -------------------------------------------------------------------------------- /模型文件/4/anchors.txt: -------------------------------------------------------------------------------- 1 | 2.8438, 2.5, 6.2135, 6.1797, 6.4688, 5.5125, 6.6108, 6.5142, 6.6581, 5.983 -------------------------------------------------------------------------------- /模型文件/4/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/4/test4.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/4/test4.kmodel -------------------------------------------------------------------------------- /模型文件/4/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/4/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/4/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/4/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/4/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 16 2 | ALpha 1.0 3 | train numbers 80 -------------------------------------------------------------------------------- /模型文件/5/Loss.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Awesome-pyecharts 6 | 7 | 8 | 9 | 10 |
11 | 1095 | 1096 | 1097 | -------------------------------------------------------------------------------- /模型文件/5/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/5/Loss.jpg -------------------------------------------------------------------------------- /模型文件/5/anchors.txt: -------------------------------------------------------------------------------- 1 | 2.8438, 2.5, 6.2135, 6.1797, 6.4688, 5.5125, 6.6108, 6.5142, 6.6581, 5.983 -------------------------------------------------------------------------------- /模型文件/5/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/5/test5.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/5/test5.kmodel -------------------------------------------------------------------------------- /模型文件/5/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/5/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/5/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/5/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/5/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 8 2 | ALpha 0.25 3 | train numbers 100 -------------------------------------------------------------------------------- /模型文件/TinyYolo/Loss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/TinyYolo/Loss.jpg -------------------------------------------------------------------------------- /模型文件/TinyYolo/anchors.txt: -------------------------------------------------------------------------------- 1 | 2.3281, 3.8906, 6.3527, 6.3051, 6.4821, 5.4985, 6.6224, 5.9826, 6.7188, 6.5769 -------------------------------------------------------------------------------- /模型文件/TinyYolo/lable.txt: -------------------------------------------------------------------------------- 1 | without_mask, with_correct_mask, with_incorrect_mask -------------------------------------------------------------------------------- /模型文件/TinyYolo/test6.kmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/TinyYolo/test6.kmodel -------------------------------------------------------------------------------- /模型文件/TinyYolo/yolov2.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/TinyYolo/yolov2.h5 -------------------------------------------------------------------------------- /模型文件/TinyYolo/yolov2.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/模型文件/TinyYolo/yolov2.tflite -------------------------------------------------------------------------------- /模型文件/TinyYolo/新建文本文档.txt: -------------------------------------------------------------------------------- 1 | Batch Size 8 2 | ALpha 0.25 3 | train numbers 100 4 | 5 | Tiny_yolo -------------------------------------------------------------------------------- /模型文件/readme.md: -------------------------------------------------------------------------------- 1 | ## 用yoloV2框架训练的深度学习模型,并用NCC工具箱将tflite格式的模型转换为Kmodel格式的模型 2 | ## 模型可以识别三种口罩佩戴情况: with_correct_mask/with_incorrect_mask/without_mask 3 | -------------------------------------------------------------------------------- /测试用代码/LcdDisplayTest.py: -------------------------------------------------------------------------------- 1 | import lcd, image 2 | import os 3 | import time 4 | 5 | 6 | print(os.listdir()) 7 | 8 | lcd.init(type=1) 9 | lcd.clear(lcd.WHITE) 10 | lcd.rotation(3) 11 | 12 | img_addr = 'pics/vegetable.jpg' 13 | img = image.Image(img_addr, copy_to_fb=True) 14 | #img = image.Image(size=(320, 240)) 15 | img.draw_string(50, 120, "welcome!", color=(255, 0, 0), scale=3) #255,255,255白色 16 | 17 | lcd.display(img) 18 | 19 | 20 | 21 | # 显示纯色背景和文字, 用于显示错误和警告信息 22 | def display_purepic_str(position, string, color, scale): 23 | img = image.Image(size=(320, 240), color = (255, 200, 0)) 24 | img.draw_string(position[0], position[1], string, color=color, scale=scale) 25 | lcd.display(img) 26 | 27 | # 显示背景图片和文字, 用于开机欢迎界面 28 | def display_pic_str(position, string, color, scale, pic_addr): 29 | img = image.Image(pic_addr, copy_to_fb=True) 30 | img.draw_string(position[0], position[1], string, color=color, scale=scale) 31 | lcd.display(img) 32 | 33 | 34 | 35 | # 画框并标注 36 | def display_rectangle_str(position, string, color, scale, img, temp): 37 | img.draw_rectangle(position[0], position[1],color=color,thickness=4) # 画框 38 | img.draw_string(position[0], position[1], string, scale=scale, color=color) #标明类别 39 | img.draw_string(0, 200, '%.2f' %temp, scale=2, color=(255, 0, 0)) # 显示温度 40 | 41 | 42 | 43 | 44 | display_pic_str(position=[1, 2], string='KALLO!!!', color=(0, 200, 255), scale=3, pic_addr='pics/vegetable.jpg') 45 | 46 | time.sleep_ms(10000) 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /测试用代码/audio.py: -------------------------------------------------------------------------------- 1 | from Maix import I2S, GPIO 2 | import audio 3 | from fpioa_manager import * 4 | import time 5 | 6 | fm.register(32, fm.fpioa.GPIO1, force=True) 7 | wifi_en=GPIO(GPIO.GPIO1, GPIO.OUT) 8 | wifi_en.value(1) 9 | fm.register(34, fm.fpioa.I2S0_OUT_D1, force=True) 10 | fm.register(35, fm.fpioa.I2S0_SCLK, force=True) 11 | fm.register(33, fm.fpioa.I2S0_WS, force=True) 12 | 13 | 14 | # init i2s(i2s0) 15 | wav_dev = I2S(I2S.DEVICE_0) 16 | wav_dev.channel_config(wav_dev.CHANNEL_1, I2S.TRANSMITTER, resolution=I2S.RESOLUTION_16_BIT, 17 | cycles=I2S.SCLK_CYCLES_32, align_mode=I2S.RIGHT_JUSTIFYING_MODE) 18 | 19 | def audio_play(audio_addr): 20 | # init audio 21 | player = audio.Audio(path=audio_addr) 22 | player.volume(40) 23 | 24 | # read audio info 25 | wav_info = player.play_process(wav_dev) 26 | 27 | # config i2s according to audio info 28 | 29 | wav_dev.set_sample_rate(wav_info[1]) 30 | 31 | # loop to play audio 32 | while True: 33 | ret = player.play() 34 | if ret == None: 35 | print("format error") 36 | break 37 | elif ret == 0: 38 | print("end") 39 | break 40 | 41 | time.sleep_ms(100) 42 | player.finish() 43 | 44 | 45 | def func(i): 46 | print(i) 47 | 48 | i = 0 49 | audio_list = ["/sd/1.wav", "/sd/2.wav", "/sd/3.wav"] 50 | while True: 51 | i += 1 52 | audio_play(audio_list[i]) 53 | if i == 3: 54 | i = 0 55 | 56 | -------------------------------------------------------------------------------- /测试用代码/camera.py: -------------------------------------------------------------------------------- 1 | import sensor, image, time, lcd 2 | 3 | lcd.init(freq=15000000) #初始化 LCD 4 | lcd.rotation(3) # 旋转方向 5 | sensor.reset() #复位和初始化摄像头,执行 sensor.run(0)停止。 6 | 7 | # sensor.set_vflip(1) #将摄像头设置成后置方式(所见即所得) 8 | 9 | sensor.set_pixformat(sensor.RGB565) # 设置像素格式为彩色 RGB565 (或灰色) 10 | sensor.set_framesize(sensor.QVGA) # 设置帧大小为 QVGA (320x240) 11 | #sensor.skip_frames(time = 2000) # 等待设置生效. 12 | sensor.run(1) 13 | 14 | 15 | 16 | 17 | img = sensor.snapshot() # 拍摄一个图片并保存. 18 | lcd.display(img) # 在 LCD 上显示 19 | -------------------------------------------------------------------------------- /测试用代码/test.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /测试用代码/threading.py: -------------------------------------------------------------------------------- 1 | import _thread 2 | import time 3 | 4 | 5 | 6 | def func1(name): 7 | while True: 8 | print("Hello World") 9 | time.sleep(1) 10 | 11 | def func2(name): 12 | while True: 13 | print("你好") 14 | time.sleep(1) 15 | 16 | _thread.start_new_thread(func1,("1",)) #开启线程 1,参数必须是元组 17 | _thread.start_new_thread(func2,("2",)) #开启线程 2,参数必须是元组 18 | 19 | while True: 20 | pass 21 | 22 | -------------------------------------------------------------------------------- /测试用代码/测温模块.py: -------------------------------------------------------------------------------- 1 | import mlx90614, time 2 | from machine import I2C # 创建I2C用来处理测温对象 3 | 4 | # 红外测温初始化 5 | i2c = I2C(I2C.I2C0,freq=100000,sda=6, scl=7) #引进测温通信I2C 6 | 7 | # 获取测温值 8 | def get_temp(i2c): 9 | temp = mlx90614.MLX90614(i2c) # 运行测温模块返回温度值 10 | return round(temp.ObjectTemp(), 2) 11 | 12 | normal_temp = [34.5, 38.0] 13 | def get_temp(i2c): 14 | cunt = 0 15 | temp = 0.0 16 | while temp < normal_temp[0]: # 当测得的温度一直小于最低温度值时则一直测温 17 | temp = mlx90614.MLX90614(i2c).ObjectTemp() # 运行测温模块返回温度值 18 | cunt += 1 19 | if cunt == 30000: 20 | return '测温失败' 21 | return round(temp, 2) 22 | temp = get_temp(i2c) 23 | 24 | print(temp) 25 | 26 | 27 | -------------------------------------------------------------------------------- /测试用代码/舵机.py: -------------------------------------------------------------------------------- 1 | from machine import Timer,PWM 2 | import time 3 | 4 | #PWM 通过定时器配置,接到 IO17 引脚 5 | tim = Timer(Timer.TIMER0, Timer.CHANNEL0, mode=Timer.MODE_PWM) 6 | S1 = PWM(tim, freq=50, duty=0, pin=17) 7 | ''' 8 | 说明:舵机控制函数 9 | 功能:180 度舵机:angle:-90 至 90 表示相应的角度 10 | 360 连续旋转度舵机:angle:-90 至 90 旋转方向和速度值。 11 | 【duty】占空比值:0-100 12 | ''' 13 | 14 | def Servo(servo,angle): 15 | S1.duty((angle+90)/180*10+2.5) 16 | i = 0 17 | while True: 18 | #-90 度 19 | Servo(S1, -90) 20 | time.sleep_ms(500) 21 | Servo(S1, 0) 22 | time.sleep_ms(500) 23 | Servo(S1, 90) 24 | time.sleep_ms(500) 25 | Servo(S1, -90) 26 | time.sleep_ms(500) 27 | print(i) 28 | 29 | -------------------------------------------------------------------------------- /用到的语音文件和图片/abnormal_temp.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/abnormal_temp.mp3 -------------------------------------------------------------------------------- /用到的语音文件和图片/abnormal_temp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/abnormal_temp.wav -------------------------------------------------------------------------------- /用到的语音文件和图片/audio_readme.txt: -------------------------------------------------------------------------------- 1 | abnormal_temp : 体温异常,禁止入内 2 | normal_temp: 体温正常,请进 3 | with_correct_mask: 口罩佩戴正确,请测量体温 4 | with_incorrect_mask: 请正确佩戴口罩 5 | without_mask: 请佩戴口罩 6 | start: 欢迎使用蓝跃科技 口罩智能识别系统,祝您健康生活每一天 -------------------------------------------------------------------------------- /用到的语音文件和图片/get_temp_error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/get_temp_error.jpg -------------------------------------------------------------------------------- /用到的语音文件和图片/model_load_error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/model_load_error.jpg -------------------------------------------------------------------------------- /用到的语音文件和图片/normal_temp.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/normal_temp.mp3 -------------------------------------------------------------------------------- /用到的语音文件和图片/normal_temp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/normal_temp.wav -------------------------------------------------------------------------------- /用到的语音文件和图片/readme.md: -------------------------------------------------------------------------------- 1 | ## 对于用到的语音文件和图片的说明 2 | 3 | #### K210开发板的语音播报模块只支持wav格式的音频文件,所以要转格式 4 | ##### 语音制作用的是微软官方出的人工智能仿人类声音,用的油猴脚本下载的mp3,然后将mp3转换为了wav 5 | 6 | #### 由于显示屏比较小,所以图片大小是 **320\* 240** 7 | 8 | 9 | -------------------------------------------------------------------------------- /用到的语音文件和图片/with_correct_mask.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/with_correct_mask.mp3 -------------------------------------------------------------------------------- /用到的语音文件和图片/with_correct_mask.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/with_correct_mask.wav -------------------------------------------------------------------------------- /用到的语音文件和图片/with_incorrect_mask.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/with_incorrect_mask.mp3 -------------------------------------------------------------------------------- /用到的语音文件和图片/with_incorrect_mask.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/with_incorrect_mask.wav -------------------------------------------------------------------------------- /用到的语音文件和图片/without_mask.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/without_mask.mp3 -------------------------------------------------------------------------------- /用到的语音文件和图片/without_mask.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lightyLi/Face-Mask-detction-DeepLearning/9b6b32dc9bf7fa8967d7717a8fe04f25bed94ca0/用到的语音文件和图片/without_mask.wav --------------------------------------------------------------------------------