Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.

With the rapid development of industrial automation, traditional manual detection methods are inefficient and error-prone, which cannot meet the needs of modern production for high efficiency and high precision. Therefore, it is particularly important to develop a mechanical automatic inspection sys...

Full description

Saved in:
Bibliographic Details
Main Authors: Guanyong Liu, Shuai Zhang, Lixin Wang, Xiaoran Li, Gongchen Li
Format: Article
Language:English
Published: Public Library of Science (PLoS) 2025-01-01
Series:PLoS ONE
Online Access:https://doi.org/10.1371/journal.pone.0321971
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1849311163940077568
author Guanyong Liu
Shuai Zhang
Lixin Wang
Xiaoran Li
Gongchen Li
author_facet Guanyong Liu
Shuai Zhang
Lixin Wang
Xiaoran Li
Gongchen Li
author_sort Guanyong Liu
collection DOAJ
description With the rapid development of industrial automation, traditional manual detection methods are inefficient and error-prone, which cannot meet the needs of modern production for high efficiency and high precision. Therefore, it is particularly important to develop a mechanical automatic inspection system that can automatically identify food packaging defects. In this study, aiming at the limitations of existing technologies in identifying small targets and subtle defects, an enhanced YOLOv5-based model for detecting food packaging flaws is introduced. Firstly, we integrated a Convolutional Attention module (CBAM) to enhance the model's attention on crucial image features. This mechanism prioritizes significant features by weighting the feature map in channel and spatial dimensions, which improves accuracy in detecting minor defects and small objects. Secondly, feature fusion across scales is achieved with pyramid and aggregation networks, so that the model can capture defects of different sizes at the same time, which enhances the recognition ability of diverse defects in food packaging. In addition, this study also optimizes the backbone network structure of YOLOv5. By integrating the streamlined YOLOv5s model and adding an Adaptive Spatial Feature Fusion module (ASFF), the model's ability to blend features from different scales was enhanced. In this study, 7400 images with 512×512 resolutions were applied to develop the proposed model. The experimental results show that the improved model outperforms the original YOLOv5 model in terms of Accuracy (Ac), Recall (Re), and F1 score, with values of 0.96, 0.94, and 0.94, respectively, effectively improving the automation and accuracy of food packaging defect detection when compared with YOLOv5+ASFF (Ac=0.94, Re=0.95, and F1=0.94), original YOLOv5 (Ac=0.82, Re=0.85, and F1=0.88), and YOLOv5+CBAM (Ac=0.88, Re=0.9, and F1=0.89). Additionally, the present performance of an improved YOLOv5 model (CBAM+Fusion Pyramid Network (FPN)+Path Aggregation network (PANet)+ASFF) was significantly comparable to the related research works.
format Article
id doaj-art-6fcd93d4fa7e4e8bbc8e733bbceda249
institution Kabale University
issn 1932-6203
language English
publishDate 2025-01-01
publisher Public Library of Science (PLoS)
record_format Article
series PLoS ONE
spelling doaj-art-6fcd93d4fa7e4e8bbc8e733bbceda2492025-08-20T03:53:31ZengPublic Library of Science (PLoS)PLoS ONE1932-62032025-01-01204e032197110.1371/journal.pone.0321971Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.Guanyong LiuShuai ZhangLixin WangXiaoran LiGongchen LiWith the rapid development of industrial automation, traditional manual detection methods are inefficient and error-prone, which cannot meet the needs of modern production for high efficiency and high precision. Therefore, it is particularly important to develop a mechanical automatic inspection system that can automatically identify food packaging defects. In this study, aiming at the limitations of existing technologies in identifying small targets and subtle defects, an enhanced YOLOv5-based model for detecting food packaging flaws is introduced. Firstly, we integrated a Convolutional Attention module (CBAM) to enhance the model's attention on crucial image features. This mechanism prioritizes significant features by weighting the feature map in channel and spatial dimensions, which improves accuracy in detecting minor defects and small objects. Secondly, feature fusion across scales is achieved with pyramid and aggregation networks, so that the model can capture defects of different sizes at the same time, which enhances the recognition ability of diverse defects in food packaging. In addition, this study also optimizes the backbone network structure of YOLOv5. By integrating the streamlined YOLOv5s model and adding an Adaptive Spatial Feature Fusion module (ASFF), the model's ability to blend features from different scales was enhanced. In this study, 7400 images with 512×512 resolutions were applied to develop the proposed model. The experimental results show that the improved model outperforms the original YOLOv5 model in terms of Accuracy (Ac), Recall (Re), and F1 score, with values of 0.96, 0.94, and 0.94, respectively, effectively improving the automation and accuracy of food packaging defect detection when compared with YOLOv5+ASFF (Ac=0.94, Re=0.95, and F1=0.94), original YOLOv5 (Ac=0.82, Re=0.85, and F1=0.88), and YOLOv5+CBAM (Ac=0.88, Re=0.9, and F1=0.89). Additionally, the present performance of an improved YOLOv5 model (CBAM+Fusion Pyramid Network (FPN)+Path Aggregation network (PANet)+ASFF) was significantly comparable to the related research works.https://doi.org/10.1371/journal.pone.0321971
spellingShingle Guanyong Liu
Shuai Zhang
Lixin Wang
Xiaoran Li
Gongchen Li
Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
PLoS ONE
title Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
title_full Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
title_fullStr Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
title_full_unstemmed Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
title_short Research on mechanical automatic food packaging defect detection model based on improved YOLOv5 algorithm.
title_sort research on mechanical automatic food packaging defect detection model based on improved yolov5 algorithm
url https://doi.org/10.1371/journal.pone.0321971
work_keys_str_mv AT guanyongliu researchonmechanicalautomaticfoodpackagingdefectdetectionmodelbasedonimprovedyolov5algorithm
AT shuaizhang researchonmechanicalautomaticfoodpackagingdefectdetectionmodelbasedonimprovedyolov5algorithm
AT lixinwang researchonmechanicalautomaticfoodpackagingdefectdetectionmodelbasedonimprovedyolov5algorithm
AT xiaoranli researchonmechanicalautomaticfoodpackagingdefectdetectionmodelbasedonimprovedyolov5algorithm
AT gongchenli researchonmechanicalautomaticfoodpackagingdefectdetectionmodelbasedonimprovedyolov5algorithm