An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels

Impurity detection is an important link in the chain of food processing. Taking walnut kernels as an example, it is difficult to accurately detect impurities mixed in walnut kernels before the packaging process. In order to accurately identify the small impurities mixed in walnut kernels, this paper...

Full description

Bibliographic Details
Main Authors: Lang Yu, Mengbo Qian, Qiang Chen, Fuxing Sun, Jiaxuan Pan
Format: Article
Language:English
Published: MDPI AG 2023-02-01
Series:Foods
Subjects:
Online Access:https://www.mdpi.com/2304-8158/12/3/624
_version_ 1797624622575779840
author Lang Yu
Mengbo Qian
Qiang Chen
Fuxing Sun
Jiaxuan Pan
author_facet Lang Yu
Mengbo Qian
Qiang Chen
Fuxing Sun
Jiaxuan Pan
author_sort Lang Yu
collection DOAJ
description Impurity detection is an important link in the chain of food processing. Taking walnut kernels as an example, it is difficult to accurately detect impurities mixed in walnut kernels before the packaging process. In order to accurately identify the small impurities mixed in walnut kernels, this paper established an improved impurities detection model based on the original YOLOv5 network model. Initially, a small target detection layer was added in the neck part, to improve the detection ability for small impurities, such as broken shells. Secondly, the Tansformer-Encoder (Trans-E) module is proposed to replace some convolution blocks in the original network, which can better capture the global information of the image. Then, the Convolutional Block Attention Module (CBAM) was added to improve the sensitivity of the model to channel features, which make it easy to find the prediction region in dense objects. Finally, the GhostNet module is introduced to make the model lighter and improve the model detection rate. During the test stage, sample photos were randomly chosen to test the model’s efficacy using the training and test set, derived from the walnut database that was previously created. The mean average precision can measure the multi-category recognition accuracy of the model. The test results demonstrate that the mean average precision (<i>mAP</i>) of the improved YOLOv5 model reaches 88.9%, which is 6.7% higher than the average accuracy of the original YOLOv5 network, and is also higher than other detection networks. Moreover, the improved YOLOv5 model is significantly better than the original YOLOv5 network in identifying small impurities, and the detection rate is only reduced by 3.9%, which meets the demand of real-time detection of food impurities and provides a technical reference for the detection of small impurities in food.
first_indexed 2024-03-11T09:45:07Z
format Article
id doaj.art-9162f1a55aa94af9be6c71327a230ae5
institution Directory Open Access Journal
issn 2304-8158
language English
last_indexed 2024-03-11T09:45:07Z
publishDate 2023-02-01
publisher MDPI AG
record_format Article
series Foods
spelling doaj.art-9162f1a55aa94af9be6c71327a230ae52023-11-16T16:41:59ZengMDPI AGFoods2304-81582023-02-0112362410.3390/foods12030624An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut KernelsLang Yu0Mengbo Qian1Qiang Chen2Fuxing Sun3Jiaxuan Pan4College of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, ChinaCollege of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, ChinaCollege of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, ChinaCollege of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, ChinaCollege of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, ChinaImpurity detection is an important link in the chain of food processing. Taking walnut kernels as an example, it is difficult to accurately detect impurities mixed in walnut kernels before the packaging process. In order to accurately identify the small impurities mixed in walnut kernels, this paper established an improved impurities detection model based on the original YOLOv5 network model. Initially, a small target detection layer was added in the neck part, to improve the detection ability for small impurities, such as broken shells. Secondly, the Tansformer-Encoder (Trans-E) module is proposed to replace some convolution blocks in the original network, which can better capture the global information of the image. Then, the Convolutional Block Attention Module (CBAM) was added to improve the sensitivity of the model to channel features, which make it easy to find the prediction region in dense objects. Finally, the GhostNet module is introduced to make the model lighter and improve the model detection rate. During the test stage, sample photos were randomly chosen to test the model’s efficacy using the training and test set, derived from the walnut database that was previously created. The mean average precision can measure the multi-category recognition accuracy of the model. The test results demonstrate that the mean average precision (<i>mAP</i>) of the improved YOLOv5 model reaches 88.9%, which is 6.7% higher than the average accuracy of the original YOLOv5 network, and is also higher than other detection networks. Moreover, the improved YOLOv5 model is significantly better than the original YOLOv5 network in identifying small impurities, and the detection rate is only reduced by 3.9%, which meets the demand of real-time detection of food impurities and provides a technical reference for the detection of small impurities in food.https://www.mdpi.com/2304-8158/12/3/624YOLOv5walnut kernelsimpurities detectionsmall object detection
spellingShingle Lang Yu
Mengbo Qian
Qiang Chen
Fuxing Sun
Jiaxuan Pan
An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
Foods
YOLOv5
walnut kernels
impurities detection
small object detection
title An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
title_full An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
title_fullStr An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
title_full_unstemmed An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
title_short An Improved YOLOv5 Model: Application to Mixed Impurities Detection for Walnut Kernels
title_sort improved yolov5 model application to mixed impurities detection for walnut kernels
topic YOLOv5
walnut kernels
impurities detection
small object detection
url https://www.mdpi.com/2304-8158/12/3/624
work_keys_str_mv AT langyu animprovedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT mengboqian animprovedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT qiangchen animprovedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT fuxingsun animprovedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT jiaxuanpan animprovedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT langyu improvedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT mengboqian improvedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT qiangchen improvedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT fuxingsun improvedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels
AT jiaxuanpan improvedyolov5modelapplicationtomixedimpuritiesdetectionforwalnutkernels