贾雪莹,赵春江,周娟,等. 基于改进YOLOv7模型的柑橘表面缺陷在线检测[J]. 农业工程学报,2023,39(23):142-151. DOI: 10.11975/j.issn.1002-6819.202308138
    引用本文: 贾雪莹,赵春江,周娟,等. 基于改进YOLOv7模型的柑橘表面缺陷在线检测[J]. 农业工程学报,2023,39(23):142-151. DOI: 10.11975/j.issn.1002-6819.202308138
    JIA Xueying, ZHAO Chunjiang, ZHOU Juan, et al. Online detection of citrus surface defects using improved YOLOv7 modeling[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2023, 39(23): 142-151. DOI: 10.11975/j.issn.1002-6819.202308138
    Citation: JIA Xueying, ZHAO Chunjiang, ZHOU Juan, et al. Online detection of citrus surface defects using improved YOLOv7 modeling[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2023, 39(23): 142-151. DOI: 10.11975/j.issn.1002-6819.202308138

    基于改进YOLOv7模型的柑橘表面缺陷在线检测

    Online detection of citrus surface defects using improved YOLOv7 modeling

    • 摘要: 柑橘表面缺陷是水果检测分级的重要依据,针对传统柑橘表面缺陷检测方法效率低、精度低等问题,该研究提出一种柑橘表面缺陷的实时检测方法。该方法首先对柑橘图像进行图像增强,然后利用提出的YOLOv7-CACT模型对柑橘表面缺陷进行检测,该模型在YOLOv7模型骨干网络中引入坐标注意力模块(coordinate attention, CA),从而提高模型对缺陷部分的关注度。在网络头部引入CT(contextual transformer,CT)模块,融合静态和动态上下文表征特征,从而增强缺陷部分特征表达能力。通过试验确定CA模块和CT模块的最佳位置。改进后的YOLOv7-CACT模型检测结果平均精度均值(mean average precision,mAP)相较于原始模型增加了4.1个百分点,达到91.1%,满足了实际生产中对柑橘缺陷检测精度的要求。最后将基于YOLOv7-CACT的柑橘检测模型通过TensorRT进行部署,试验结果表明模型的推理时间满足柑橘生产线10个/s的实时分选要求,总体的检测精度达到94.4%,为柑橘表面缺陷在线检测提供了一种精准的实时检测方法。

       

      Abstract: Citrus surface defects play a pivotal role in the fruit inspection and grading during agricultural production. Surface imperfections are also much easier to spot than inside ones, leading to accelerate the deterioration. However, conventional detection of citrus surface defects cannot fully meet the overall quality assessment in the large-scale production in recent years, due to the low efficiency and accuracy. In this study, an accurate, rapid and real-time detection was proposed to consider the diverse and complex nature of surface imperfections observed in citrus fruits. This speed and precision of detection were also enhanced for the quality of surface defects. Firstly, the images of citrus fruits were captured by industrial cameras. The generated images were enhanced to make the region of interest more outstanding. Then, the YOLOv7-CACT model was improved for the defect region in the enhanced citrus image. The coordinate attention (CA) module was introduced in the backbone network, in order to increase the attention to the defective part. The contextual transformer (CT) module was introduced in the head of the network to fuse the static and dynamic contextual representation features, thus enhancing the feature expression of the defective part. The superior performance was achieved in the modified YOLOv7-CACT model, compared with the baseline version. Especially, the detection accuracy was improved by 4.1% in the mean average precision (mAP). Consequently, the modified model was fully met the accuracy requirements for the identification of citrus surface defects in an offline setting. TensorRT was also employed around YOLOv7-CACT for the deployment of improved model, in order to real-time detect in practical scenarios. The results show that the improved YOLOv7-CACT-RT model was performed the best to detect the surface defects on the surface of citrus fruits in the grading and sorting production line with a transition rate of 10 fruits per second. The deployed YOLOv7-CACT-RT model was loaded into the grading software programmed by C++ language, in order to validate the performance. An online detection was conducted on 198 mixed normal and defective citrus fruits on the sorting line, achieving a detection accuracy of 94.4%. The improved model can be directly applied to grade and sort fruit in the production line, according to the external qualities. Meanwhile, this model can also be extended to the real-time surface defects detection of other fruits without specialized knowledge. Our future research will focus on the registration and fusion of RGB and NIR image, in order to improve the detection accuracy of fruit defects.

       

    /

    返回文章
    返回