Real-Time Face Mask Detection Using YOLOv8n with Performance Optimization
DOI:
https://doi.org/10.22399/ijcesen.5330Keywords:
Face mask detection, YOLOv8, Deep learning, Computer vision, Real-time inferenceAbstract
The COVID-19 pandemic has highlighted the practical limitations of manual monitoring in high-density population and emphasized the importance of complying with face mask rules in public places. The aim of this study is to present a full design, implementation, and systematic evaluation of a binary face mask identification system based on the YOLOv8n deep learning model. The dataset used for training was taken from Roboflow and labeled with two classes and 929 annotated instances. It includes 120 training shots and 128 validation images. The model was trained using the Ultralytics YOLOv8 framework on a cloud-based GPU environment for five epochs. The model was trained using this dataset. The trained model has attained a precision of 0.681, recall of 0.582, mean Average Precision at IoU threshold 0.5 (mAP50) of 0.655 and mAP50-95 of 0.490. Per-class analysis showed that the mask class achieved a mAP50 of 0.777, while the no-mask class achieved a mAP50 of 0.534. This asymmetry is attributed to the class imbalance in the training data. As per confusion matrix evaluation, 434 correct mask classifications and 216 appropriate no mask classifications are made out of total 929 validation cases. It was proven that near real-time inference can be done on standard GPU hardware at 154 milliseconds per image (~ 6.3 frames per second). In this work we provide a fully repeatable baseline, with the whole training pipeline running in 0.241 hours and using just publicly available technology. The findings are competitive to those of published systems including FMD-YOLO (66.4% VOC mAP) but with far lower implementation complexity. This shows that YOLOv8n, in conjunction with Roboflow and Ultralytics, provides an accessible and efficient pipeline for automated public health compliance monitoring.
References
[1] World Health Organization. Advice on the Use of Masks in the Context of COVID-19: Interim Guidance; WHO: Geneva, Switzerland, 2020.
[2] Hu, Y.; Xu, Y.; Zhuang, H.; Weng, Z.; Lin, Z. Machine learning techniques and systems for mask-face detection: Survey and a new OOD-mask approach. Appl. Sci. 2022, 12, 9171. https://doi.org/10.3390/app12189171.
[3]Vibhuti, Jindal, N., Singh, H., & Rana, P. S. (2022). Face mask detection in COVID-19: a strategic review. Multimedia tools and applications, 81(28), 40013-40042.
[4] Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You only look once: Unified, real-time object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, June 2016; pp. 779–788.
[5] Wang, J.; Zhang, T.; Cheng, Y.; Al-Nabhan, N. Deep learning for object detection: A survey. Comput. Syst. Sci. Eng. 2021, 38, 165–182. https://doi.org/10.32604/csse.2021.017016
[6] Jocher, G.; Chaurasia, A.; Qiu, J. Ultralytics YOLOv8; Ultralytics: 2023. Available online: https://github.com/ultralytics/ultralytics (accessed on 1 January 2025).
[7] Tamang, S.; Sen, B.; Pradhan, A.; Sharma, K.; Singh, V.K. Enhancing COVID-19 safety: Exploring YOLOv8 object detection for accurate face mask classification. Int. J. Intell. Syst. Appl. Eng. 2023, 11, 892–897.
[8] Sayed, G.M.; Alsahafi, Y.S.; Elmezain, A. Deep learning-based face mask recognition system with YOLOv8. In Proceedings of the IEEE International Conference on Computing (ICACS), 2024. https://doi.org/10.1109/ICACS60943.2024.10569507
[9] Loey, M.; Manogaran, G.; Taha, M.H.N.; Khalifa, N.E.M. Fighting against COVID-19: A novel deep learning model based on YOLO-v2 with ResNet-50 for medical face mask detection. Sustain. Cities Soc. 2021, 65, 102600. https://doi.org/10.1016/j.scs.2020.102600
[10] Nagrath, P.; Jain, R.; Madan, A.; Arora, R.; Kataria, P.; Hemanth, D.J. SSDMNV2: A real-time DNN-based face mask detection system using single shot multibox detector and MobileNetV2. Sustain. Cities Soc. 2021, 66, 102692. https://doi.org/10.1016/j.scs.2020.102692
[11] Liu, W.; et al. SSD: Single shot multibox detector. In Proceedings of the ECCV, Amsterdam, Netherlands, October 2016; pp. 21–37.
[12] Howard, A.; et al. MobileNets: Efficient convolutional neural networks for mobile vision applications. arXiv 2017, arXiv:1704.04861.
[13] Wu, P.; Li, H.; Zeng, N.; Li, F. FMD-YOLO: An efficient face mask detection method for COVID-19 prevention and control in public. Image Vis. Comput. 2022, 117, 104341. https://doi.org/10.1016/j.imavis.2021.104341
[14] Kumar, A.; Kalia, A.; Verma, K.; Sharma, A.; Kaushal, M. Scaling up face masks detection with YOLO on a novel dataset. Optik 2021, 239, 166744. https://doi.org/10.1016/j.ijleo.2021.166744
[15] Jiang, X.; Gao, T.; Zhu, Z.; Zhao, Y. Real-time face mask detection method based on YOLOv3. Electronics 2021, 10, 837. https://doi.org/10.3390/electronics10070837
[16] Redmon, J.; Farhadi, A. YOLOv3: An incremental improvement. arXiv 2018, arXiv:1804.02767.
[17] Bochkovskiy, A.; Wang, C.-Y.; Liao, H.-Y.M. YOLOv4: Optimal speed and accuracy of object detection. arXiv 2020, arXiv:2004.10934.
[18] Wang, C.-Y.; Bochkovskiy, A.; Liao, H.-Y.M. YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. In Proceedings of the IEEE/CVF CVPR, Vancouver, Canada, June 2023; pp. 7464–7475.
[19] Yaseen, M. What is YOLOv8: An in-depth exploration of the internal features of the next-generation object detector. arXiv 2024, arXiv:2408.15857.
[20] He, K.; Zhang, X.; Ren, S.; Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE/CVF CVPR, Las Vegas, NV, USA, June 2016; pp. 770–778
[21] Shorten, C.; Khoshgoftaar, T.M. A survey on image data augmentation for deep learning. J. Big Data 2019, 6, 60. https://doi.org/10.1186/s40537-019-0197-0
[22] Nelson, J.; Dwyer, B. Roboflow: Give Your Software the Power to See Objects in Images and Video; Roboflow Inc.: 2021. Available online: https://roboflow.com (accessed on 1 January 2025).
[23] Ge, S.; Li, J.; Ye, Q.; Luo, Z. Detecting masked faces in the wild with LLE-CNNs. In Proceedings of the IEEE/CVF CVPR, Honolulu, HI, USA, July 2017. https://doi.org/10.1109/CVPR.2017.53
[24] Lin, T.-Y.; Goyal, P.; Girshick, R.; He, K.; Dollár, P. Focal loss for dense object detection. In Proceedings of the IEEE/CVF ICCV, Venice, Italy, October 2017; pp. 2980–2988.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 International Journal of Computational and Experimental Science and Engineering

This work is licensed under a Creative Commons Attribution 4.0 International License.