计算机工程与应用 ›› 2023, Vol. 59 ›› Issue (7): 232-241.DOI: 10.3778/j.issn.1002-8331.2209-0013

• 图形图像处理 • 上一篇    下一篇

改进YOLOv5的轻量化口罩检测算法

刘翀豪,潘理虎,杨帆,张睿   

  1. 1.太原科技大学 计算机科学与技术学院,太原 030024
    2.山西迅龙科技有限公司,太原 030024
  • 出版日期:2023-04-01 发布日期:2023-04-01

Improved YOLOv5 Lightweight Mask Detection Algorithm

LIU Chonghao, PAN Lihu, YANG Fan, ZHANG Rui   

  1. 1.College of Computer Science and Technology, Taiyuan University of Science and Technology, Taiyuan 030024, China
    2.Shanxi Xunlong Technology Corporation Limited, Tayuan 030024, China
  • Online:2023-04-01 Published:2023-04-01

摘要: 为了提高现有口罩检测算法检测效率,降低算法参数量以及模型大小,提出了一种改进的轻量化口罩检测算法YOLOv5-MBF。用GELU激活函数替换MobileNetV3深层网络的hard-swish激活函数,优化了模型收敛效果,将改进的MobileNetV3网络替换YOLOv5s主干网络,降低计算量提高模型检测速度。增加BiFPN特征金字塔结构与不同特征层融合,提高了检测精度。在数据处理方面使用Mosaic和Mixup数据增强提高该模型的泛化性和鲁棒性。边框回归损失函数使用Focal-Loss EIoU,优化了模型训练收敛速度且提高了口罩和人脸边框定位精度。最后添加CBAM注意力机制使得模型更关注重要特征抑制不显著特征提高检测性能。实验结果表明,该算法在佩戴口罩目标和无佩戴口罩目标上的平均精度均值达到了89.5%,模型推理速度提升了43%,模型参数了减少了49%,模型大小降低了48%,满足口罩检测任务的实时性和检测精度要求。

关键词: 口罩检测, YOLOv5, MobileNetv3, BiFPN, Focal-Loss EIoU, 注意力机制

Abstract: In order to improve the detection efficiency of existing mask detection algorithms, and reduce the parameters and model size, an improved lightweight mask detection algorithm YOLOv5-MBF is proposed. Firstly, the GELU activation function replaces the hard-swish activation function of MobileNetV3 deep network, which optimizes the convergence effect of the model, and the improved MobileNetV3 network replaces the YOLOv5s backbone network, which reduces the calculation amount and improves the speed of model detection. Secondly, the feature pyramid structure of BiFPN is added to fuse with different feature layers, which improves the detection accuracy. At the same time, Mosaic and Mixup data enhancement are used in data processing to improve the generalization and robustness of the model. Focal-Loss EIoU is used as the regression loss function, which optimizes the convergence speed of model training and improves the positioning accuracy of mask and face border. Finally, CBAM attention mechanism is added to make the model pay more attention to important features, suppress insignificant features and improve the detection performance. The experimental results show that the average accuracy of the algorithm is 89.5% on the mask-wearing target and the mask-not-wearing target, the model reasoning speed is increased by 43%, the model parameters are reduced by 49%, and the model size is reduced by 48%, which meets the real-time and detection accuracy requirements of mask detection tasks.

Key words: mask detection, YOLOv5, MobileNetv3, BiFPN, Focal-Loss EIoU, attention mechanis