欢迎您访问《智慧农业(中英文)》官方网站! English

Smart Agriculture ›› 2024, Vol. 6 ›› Issue (5): 128-138.doi: 10.12133/j.smartag.SA202406012

• 技术方法 • 上一篇    下一篇

基于改进YOLOv8的苹果叶病害轻量化检测算法

罗友璐, 潘勇浩(), 夏顺兴, 陶友志   

  1. 四川农业大学 信息工程学院,四川 雅安 625014,中国
  • 收稿日期:2024-06-25 出版日期:2024-09-30
  • 基金项目:
    四川省科技厅区域创新合作项目(24QYCX0185); 雅安市数字农业工程中心建设项目
  • 作者简介:

    罗友璐,研究方向为计算机应用、深度学习和图像处理。E-mail:

  • 通信作者:
    潘勇浩,副教授,研究方向为计算机应用和农业信息化。E-mail:

Lightweight Apple Leaf Disease Detection Algorithm Based on Improved YOLOv8

LUO Youlu, PAN Yonghao(), XIA Shunxing, TAO Youzhi   

  1. College of Information Engineering, Sichuan Agricultural University, Ya'an 625014, China
  • Received:2024-06-25 Online:2024-09-30
  • Foundation items:Regional Innovation Cooperation Project of the Sichuan Provincial Department of Science and Technology(24QYCX0185); Ya'an Digital Agriculture Engineering Center Construction Project
  • About author:

    LUO Youlu, E-mail:

  • Corresponding author:
    PAN Yonghao, E-mail:

摘要:

【目的/意义】 苹果是中国重要的农产品,为了保障苹果的健康生长,降低其患病率,研发苹果叶病害检测技术具有重要意义。本研究旨在应对苹果生长过程中出现的病害快速检测问题,提出一种基于改进YOLOv8的苹果叶病害检测算法。 【方法】 选用YOLOv8n模型对苹果在生长期间的多种病害(褐腐病、褐纹病、黑星病和锈病)进行识别。引入SPD-Conv替代传统卷积层,降低模型参数量和运算量的同时提高检测精度。在Neck层中添加多尺度空洞注意力机制(Multi-Scale Dilated Attention, MSDA),使模型通过动态感受野自适应地聚焦于图像中的关键区域,增强病害特征提取能力。此外,参考重参数化卷积神经网络(Reparameterized Convolutional Neural Network, RepVGG)架构,优化了原有检测头,实现检测和推理过程的架构分离,加快了模型的推理速度,提升了其特征学习能力。最后,构建了一个包含上述病害的苹果叶片数据集,并在此数据集上进行试验。 【结果和讨论】 改进后的模型在运算量降低0.1 G的同时,mAP50和mAP50∶95分别达到了88.2%和37.0%,较原模型分别提高了2.7%和1.3%,模型大小仅为7.8 MB。准确率和召回率分别为83.1%和80.2%,较原模型分别提升了0.9%和1.1%。分别与YOLOv7-tiny、YOLOv9-c、RetinaNet、Faster-RCNN等多个模型进行对比试验,结果表明,提出的YOLOv8n-SMR模型表现出优异性能,有效控制了计算复杂度和参数量。优化后的网络结构在模型大小,浮点运算次数和参数量上均保持较低水平,适合在无人机系统等硬件资源受限设备上高效部署。 【结论】 改进后的模型能够实现对苹果叶病害的准确检测,该方法不仅提高了检测精度,还通过轻量化设计有效减少了模型的运算量,为后续的苹果生长和果实收集提供可靠的数据支持,并为进一步苹果叶病害研究和探索提供了有利的参考。

关键词: 深度学习, YOLOv8, 苹果叶病害检测, MSDA, SPD-Conv

Abstract:

[Objective] As one of China's most important agricultural products, apples hold a significant position in cultivation area and yield. However, during the growth process, apples are prone to various diseases that not only affect the quality of the fruit but also significantly reduce the yield, impacting farmers' economic benefits and the stability of market supply. To reduce the incidence of apple diseases and increase fruit yield, developing efficient and fast apple leaf disease detection technology is of great significance. An improved YOLOv8 algorithm was proposed to identify the leaf diseases that occurred during the growth of apples. [Methods] YOLOv8n model was selected to detect various leaf diseases such as brown rot, rust, apple scab, and sooty blotch that apples might encounter during growth. SPD-Conv was introduced to replace the original convolutional layers to retain fine-grained information and reduce model parameters and computational costs, thereby improving the accuracy of disease detection. The multi-scale dilated attention (MSDA) attention mechanism was added at appropriate positions in the Neck layer to enhance the model's feature representation capability, which allowed the model to learn the receptive field dynamically and adaptively focus on the most representative regions and features in the image, thereby enhancing the ability to extract disease-related features. Finally, inspired by the RepVGG architecture, the original detection head was optimized to achieve a separation of detection and inference architecture, which not only accelerated the model's inference speed but also enhanced feature learning capability. Additionally, a dataset of apple leaf diseases containing the aforementioned diseases was constructed, and experiments were conducted. [Results and Discussions] Compared to the original model, the improved model showed significant improvements in various performance metrics. The mAP50 and mAP50:95 achieved 88.2% and 37.0% respectively, which were 2.7% and 1.3% higher than the original model. In terms of precision and recall, the improved model increased to 83.1% and 80.2%, respectively, representing an improvement of 0.9% and 1.1% over the original model. Additionally, the size of the improved model was only 7.8 MB, and the computational cost was reduced by 0.1 G FLOPs. The impact of the MSDA placement on model performance was analyzed by adding it at different positions in the Neck layer, and relevant experiments were designed to verify this. The experimental results showed that adding MSDA at the small target layer in the Neck layer achieved the best effect, not only improving model performance but also maintaining low computational cost and model size, providing important references for the optimization of the MSDA mechanism. To further verify the effectiveness of the improved model, various mainstream models such as YOLOv7-tiny, YOLOv9-c, RetinaNet, and Faster-RCNN were compared with the propoed model. The experimental results showed that the improved model outperformed these models by 1.4%, 1.3%, 7.8%, and 11.6% in mAP50, 2.8%, 0.2%, 3.4%, and 5.6% in mAP50:95. Moreover, the improved model showed significant advantages in terms of floating-point operations, model size, and parameter count, with a parameter count of only 3.7 MB, making it more suitable for deployment on hardware-constrained devices such as drones. In addition, to assess the model's generalization ability, a stratified sampling method was used, selecting 20% of the images from the dataset as the test set. The results showed that the improved model could maintain a high detection accuracy in complex and variable scenes, with mAP50 and mAP50:95 increasing by 1.7% and 1.2%, respectively, compared to the original model. Considering the differences in the number of samples for each disease in the dataset, a class balance experiment was also designed. Synthetic samples were generated using oversampling techniques to increase the number of minority-class samples. The experimental results showed that the class-balanced dataset significantly improved the model's detection performance, with overall accuracy increasing from 83.1% to 85.8%, recall from 80.2% to 83.6%, mAP50 from 88.2% to 88.9%, and mAP50:95 from 37.0% to 39.4%. The class-balanced dataset significantly enhanced the model's performance in detecting minority diseases, thereby improving the overall performance of the model. [Conclusions] The improved model demonstrated significant advantages in apple leaf disease detection. By introducing SPD-Conv and MSDA attention mechanisms, the model achieved noticeable improvements in both precision and recall while effectively reducing computational costs, leading to more efficient detection capabilities. The improved model could provide continuous health monitoring throughout the apple growth process and offer robust data support for farmers' scientific decision-making before fruit harvesting.

Key words: deep learning, YOLOv8, apple leaf disease detection, MSDA, SPD-Conv

中图分类号: