Yu Lang, Qian Mengbo, Chen Qiang, Sun Fuxing, Pan Jiaxuan
College of Optical Mechanical and Electrical Engineering, Zhejiang A & F University, Hangzhou 311300, China.
Foods. 2023 Feb 1;12(3):624. doi: 10.3390/foods12030624.
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 () 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.
杂质检测是食品加工链条中的重要环节。以核桃仁为例,在包装前很难准确检测出混入核桃仁中的杂质。为了准确识别混入核桃仁中的微小杂质,本文基于原始的YOLOv5网络模型建立了一种改进的杂质检测模型。首先,在颈部添加了一个小目标检测层,以提高对碎壳等小杂质的检测能力。其次,提出了Transformer-Encoder(Trans-E)模块来替换原始网络中的一些卷积块,这样可以更好地捕捉图像的全局信息。然后,添加了卷积块注意力模块(CBAM)以提高模型对通道特征的敏感度,便于在密集物体中找到预测区域。最后,引入了GhostNet模块以使模型更轻并提高模型检测率。在测试阶段,从先前创建的核桃数据库中随机选择样本照片,使用训练集和测试集来测试模型的效果。平均精度均值可以衡量模型的多类别识别准确率。测试结果表明,改进后的YOLOv5模型的平均精度均值(mAP)达到88.9%,比原始YOLOv5网络的平均准确率高6.7%,也高于其他检测网络。此外,改进后的YOLOv5模型在识别小杂质方面明显优于原始YOLOv5网络,检测率仅降低了3.9%,满足了食品杂质实时检测的需求,为食品中小杂质的检测提供了技术参考。