基于改进YOLOv7的破壳鸡蛋在线实时检测系统

    Online real-time detection system for cracked eggs using improved YOLOv7

    • 摘要: 针对破壳鸡蛋(破口蛋和裂纹蛋)缺陷差异性大,在线检测要求实时,以及人工检测依靠主观经验且检测速度慢、检测精度不高等问题,该研究提出一种基于改进的YOLOv7(You Only Look Once v7)模型的破壳鸡蛋在线实时检测系统。以YOLOv7网络为基础,将YOLOv7网络的损失函数CIoU(complete-IoU)替换为WIoUv2(wise-IoU),在骨干网络(backbone)中嵌入坐标注意力模块(coordinate attention,CA)和添加可变形卷积DCNv2(deformable convnet)模块,同时将YOLOv7网络中的检测头(IDetect)替换为具有隐式知识学习的解耦检测头(IDetect_Decoupled)模块。在PC端的试验结果表明,改进后的模型在测试集上平均精度均值(mean average precision,mAP)为94.0%,单张图片检测时间为13.1 ms,与模型改进之前相比,其mAP提高了2.9个百分点,检测时间仅延长1.0 ms;改进后模型的参数量为3.64×107,较原始模型降低了2.1%。最后通过格式转换并利用ONNXRun time深度学习框架把模型部署至设备端,在ONNXRuntime推理框架下进行在线检测验证。试验结果表明:该算法相较原始YOLOv7误检率降低了3.8个百分点,漏检率不变,并且在线检测平均帧率约为54帧/s,满足在线实时性检测需求。该研究可为破壳鸡蛋在线检测研究提供技术参考。

       

      Abstract: An accurate and rapid detection of eggshell damage has been one of the most important steps in the field of egg processing. Eggshells are prone to mechanical impact and damage during laying and processing, leading to the leakage of egg contents. It has also posed serious bacterial infections and food safety risks on the rest of the intact eggs in the processing line, particularly for the cleaning work and production costs. Furthermore, the current manual detection relies mainly on the subjective experience with slow speed and low accuracy. Therefore, it is of great practical significance to rapidly, accurately, and low-costly detect broken shell eggs in egg processing. In this study, an online real-time detection system was proposed for the broken shell eggs using the improved YOLOv7 (you only look once) model. Significant differences were also presented in the defects between broken shell eggs. Specifically, the YOLOv7 network was selected to replace the loss function CIoU (complete-IoU) with WIoUv2 (wise-IoU). The coordinate attention (CA) modules were added into the deformable convolutional DCNv2 (deformable convnet) in the backbone network. At the same time, the detection head (IDetect) module was replaced in the YOLOv7 network with a decoupled detection head (IDetect-Decoupled) with implicit knowledge learning. Among them, the CA module was used to effectively identify and locate targets of interest for optimal model performance, where the deformable convolution was combined to decouple the detection heads. WIoU loss functions were used to learn the local and global information while improving the accuracy and speed of shell-breaking egg detection with the less missed and false detections. The generalization and robustness of the model were further improved using data augmentation. Various operations were performed on the training set, such as random cropping, 50% probability of random horizontal and vertical flipping, 50% probability of random rotation and scaling, random noise, brightness and color adjustments. The dataset was screened to remove the unqualified data after data augmentation. Finally, a final dataset was obtained with 1729 images, including 3782 intact and 1574 cracked eggs. The experimental results on the PC side show that better performance was achieved in the improved model, with an average precision (mAP) of 94.0% on the test set. The single image detection time of 13.1 ms was 2.9 percentage points higher than before, where the detection time was only extended by 1.0 ms. The parameter quantity of the improved model was 3.64×107, indicating a decrease of 2.1 percentage points, compared with the original model. In addition, the improved YOLOv7 model enhanced the mAP of broken shell eggs by 5.4, 3.4, and 4.5 percentage points, compared with the SSD, Faster R-CNN, and YOLOv5 models, respectively. The best detection accuracy was achieved for the broken shell eggs, indicating the high effectiveness of the improved model. Finally, the model was also deployed to the device side through the format conversion. The ONNXRuntime deep learning was utilized to conduct the online detection and verification under its inference framework. The improved model was reduced by 3.8 percentage points on the false detection rate of broken eggs, whereas, the missed detection rate remained unchanged. The average frame rate was about 54 frames/s for online detection. The strong robustness of the improved model fully met the requirements of online real-time detection. This finding can provide the technical reference for the online detection of broken shell eggs.

       

    /

    返回文章
    返回