Welcome to Journal of Graphics share: 

Journal of Graphics ›› 2023, Vol. 44 ›› Issue (1): 16-25.DOI: 10.11996/JG.j.2095-302X.2023010016

• Image Processing and Computer Vision • Previous Articles     Next Articles

Mask detection algorithm based on YOLOv5 integrating attention mechanism


  1. 1. Department of Computer Technology and Applications, Qinghai University, Xining Qinghai 810016, China; 

    2. State Key Laboratory of Plateau Ecology and Agriculture, Qinghai University, Xining Qinghai 810016, China

  • Online:2023-02-28 Published:2023-02-16
  • Supported by:
    National Natural Science Foundation of China (61962051); Independent Project of the State Key Laboratory of Plateau Ecology and Agriculture (2021-ZZ-2)


Wearing masks correctly during the COVID-19 pandemic can effectively prevent the spread of the virus. In response to the detection challenge posed by dense crowds and small detection targets in public places, a mask wearing detection algorithm based on the YOLOv5s model and integrating an attention mechanism was proposed. Four attention mechanisms were introduced into the backbone network of the YOLOv5s model to respectively suppress irrelevant information, enhance the ability of the feature map to express information, and improve the modelʹs detection ability for small-scale targets. Experimental results show that the introduction of the convolutional block attention module could increase the mAP value by 6.9 percentage points compared with the original network, with the greatest improvement among the four attention mechanisms. The normalization-based attention module also showed excellent performance, with the least quantity of parameters while losing a small amount of mAP. Through comparative experiments, the GIoU loss function was selected to calculate the bounding box regression loss, resulting in further improvements to positioning accuracy, resulting in an mAP value that was improved by 8.5 percentage points compared to the original network. The detection results of the improved model in different scenarios prove the accuracy and practicability of the algorithm for small target detection. 

Key words: mask detection, YOLOv5, attention mechanism, feature fusion, small target detection

CLC Number: