梁晓婷, 庞琦, 杨一, 文朝武, 李友丽, 黄文倩, 张驰, 赵春江. 基于YOLOv4模型剪枝的番茄缺陷在线检测[J]. 农业工程学报, 2022, 38(6): 283-292. DOI: 10.11975/j.issn.1002-6819.2022.06.032
    引用本文: 梁晓婷, 庞琦, 杨一, 文朝武, 李友丽, 黄文倩, 张驰, 赵春江. 基于YOLOv4模型剪枝的番茄缺陷在线检测[J]. 农业工程学报, 2022, 38(6): 283-292. DOI: 10.11975/j.issn.1002-6819.2022.06.032
    Liang Xiaoting, Pang Qi, Yang Yi, Wen Chaowu, Li Youli, Huang Wenqian, Zhang Chi, Zhao Chunjiang. Online detection of tomato defects based on YOLOv4 model pruning[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(6): 283-292. DOI: 10.11975/j.issn.1002-6819.2022.06.032
    Citation: Liang Xiaoting, Pang Qi, Yang Yi, Wen Chaowu, Li Youli, Huang Wenqian, Zhang Chi, Zhao Chunjiang. Online detection of tomato defects based on YOLOv4 model pruning[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(6): 283-292. DOI: 10.11975/j.issn.1002-6819.2022.06.032

    基于YOLOv4模型剪枝的番茄缺陷在线检测

    Online detection of tomato defects based on YOLOv4 model pruning

    • 摘要: 为解决番茄缺陷检测过程中的精确性和实时性问题,该研究提出一种基于模型剪枝的番茄表面缺陷实时检测方法。采用模型剪枝的方法在YOLOv4网络模型基础上进行模型优化,首先将3个连续检测工位采集的RGB图像拼接生成YOLOv4网络的输入图像,然后采用通道剪枝和层剪枝的方法压缩YOLOv4网络模型,从而减少模型参数,提高检测速度,最后提出一种基于L1范数的非极大值抑制方法,用于在模型微调后去除冗余预测框,从而精准定位图像中的缺陷位置,并将模型部署到分级系统上进行实时检测试验。结果表明,该研究提出的YOLOv4P网络与原YOLOv4网络相比,网络模型尺寸和推理时间分别减少了232.40 MB和10.11 ms,平均精度均值(Mean Average Precision,mAP)从92.45%提高到94.56%,能满足实际生产中针对缺陷番茄进行精准、实时检测的要求,为番茄分级系统提供了高效的实时检测方法。

       

      Abstract: Abstract: Surface defects have posed a negative impact on the quality and yield in the process of tomato growth. A post-harvest grading treatment can normally be utilized before tomato marketing. It is necessary to accurately and rapidly detect the defective tomato in the process of post-harvest grading. In this study, a real-time detection was proposed for the tomato surface defects using YOLOv4 model pruning. A diffuse light box was used to improve the acquisition system. High resolution images of tomatoes were then acquired to reduce the reflection of tomato surface under the direct exposure. Parallel computing and images combination were also selected for the high speed of image processing. The input images of the YOLOv4 network were generated to stitch the RGB images collected from three continuous detection stations. In addition, the channel pruning was selected to simplify the network parameters and structure in the YOLOv4 network model. There were a complex network structure and a large number of parameters in the original YOLOv4, leading to too large calculation and low inference speed of the model. The layer pruning was also used to further compress the depth of the network model on the basis of compressing the network width, in order to improve the detection speed for the real-time detection. A non-maximum suppression with the L1 norm was proposed to remove the redundant prediction box after fine-tuning network model, thereby accurately locating the defect location in the images. The detection performance of the improved model was evaluated using the YOLOv4 training data at the pruning rates under various target detection models. The maximum Mean Average Precision (mAP) value was taken as the pruning rate, indicating the minimum model size and inference time for the requirements of real-time performance. Therefore, the channel pruning rate of the YOLOv4 network was finally set to 80%, where the obtained model was named YOLOv4P. The YOLOv3, YOLOv4, YOLOv4-tiny, YOLOv4PC, and YOLOv4P models were compared to verify the performance of the detection model for the tomato defects. The results showed that the model pruning compression technology can effectively improve the detection speed at the lowest cost of accuracy. The real-time grading system was tested on the tomato experiment data set, including the stem, calyx, and defect types. The improved YOLOv4P network reduced the model size and reasoning time by 232.40 MB and 10.11 ms, respectively, compared with the original YOLOv4 network. In conclusion, the highest mAP and the fastest detection speed were achieved to detect the tomato surface defects using the improved model. The mAP increased from 92.45% to 94.56%, fully meeting the requirements of accurate and real-time detection. The finding can also provide an efficient online detection for the tomato real-time grading system.

       

    /

    返回文章
    返回