Lightweight detection of small target diseases in apple leaf using improved YOLOv5s
-
摘要:
为解决自然环境中苹果叶片病害检测场景复杂、小目标病害检测难度高以及模型参数大无法在移动端和嵌入式设备部署等问题,提出一种基于YOLOv5s的苹果叶片小目标病害轻量化检测方法。该方法将YOLOv5s的骨干网络更改为ShuffleNet v2轻量化网络,引入CBAM(convolutional block attention module)注意力模块使模型关注苹果叶片小目标病害,添加改进RFB-s(receptive field block-s)支路获取多尺度特征,提高苹果叶片病害检测精度,并更改边界框回归损失函数为SIoU(scylla-intersection over union),增强病斑定位能力。试验表明改进后的YOLOv5s模型在IoU大于0.5时的平均精度均值(mean average precision,mAP0.5)和每秒传输帧数(frame per second,FPS)分别达到90.6%和175帧/s,对小目标的平均检测准确率为38.2%,与基准模型YOLOv5s相比,其mAP0.5提升了0.8个百分点,参数量减少了6.17 MB,计算量减少了13.8 G,对小目标的检测准确率提高了3个百分点。改进后的YOLOv5s目标检测模型与Faster R-CNN、SSD、YOLOv5m、YOLOv7、YOLOv8和YOLOv5s目标检测模型相比,具有最小的参数量和计算量,对小目标病害叶斑病和锈病的检测准确率分别提高了1.4、4.1、0.5、5.7、3.5、3.9和1.5、4.3、1.2、2.1、4.0、2.6个百分点,该方法为真实自然环境下苹果叶片病害尤其是小目标病害的轻量化检测提供参考依据。
Abstract:Leaf diseases have seriously threatened the quality and yield of apple fruits. Efficient and accurate identification of apple leaf diseases is of great significance for refined orchard management. However, it is difficult to detect apple leaf disease at the early stage, due to the small target disease lesion and complex scenarios. Furthermore, the parameters of the detection model are too large to deploy on mobile terminals or embedded devices. In this study, a lightweight detection was proposed to detect the small apple leaf disease using improved You Only Look Once Version 5s (YOLOv5s). Firstly, the ShuffleNet v2 lightweight network was employed as the backbone network of YOLOv5s, in order to reduce the parameters and float-point operations per second (FLOPs) of the new network. Secondly, the Convolutional Block Attention Module (CBAM) was adopted to focus on the features of the small target disease of apple leaves. High performance was improved in the network information transmission and the sensitivity of the model to features, and then combined the spatial and channels to enhance the cross-channel interaction of the model. Thirdly, an improved Receptive Field Block-s (RFB-s) branch was added to obtain the multi-scale features for the high feature extraction of the model and the detection accuracy of apple leaf disease. Finally, SCYLLA-Intersection over Union (SIoU) was selected as the loss function of the bounding box regression. The performance of disease spot localization was enhanced for the high accuracy and training speed of the model. The experimental results demonstrated that the mAP0.5 and FPS of the improved YOLOv5s reached 90.6% and 175 frames/s, respectively. The mAP0.5 of the improved model increased by 0.8%, while the number of parameters was reduced by 6.17 MB, and the calculation amount was reduced by 13.8 G FLOPs, compared with the baseline model YOLOv5s. Particularly, the average precision of small disease targets was up to 38.2%, indicating the high efficiency and robustness of the model. Moreover, the mAP0.5 were 2.0, 1.4, 2.0 and 9.4 percentage points higher in the improved model YOLOv5s, respectively, and the average accuracy rate of small disease targets increased by 1.5, 2.0, 1.8 and 2.1 percentage points, respectively, compared with Squeeze-and-Excitation (SE), Efficient Channel Attention (ECA), CoordAttention (CA), and Non-local neural network in the CBAM attention module. The SIoU bounding box loss function presented the highest detection accuracy, compared with the DIoU, CIoU, and GIoU. In addition, the improved YOLOv5 object detection model displayed the minimum number of parameters and calculations. Specifically, the detection accuracy of frog eye leaf spot and rust diseases increased by 1.4, 4.1, 0.5, 5.7, 3.5, 3.9 and 1.5, 4.3, 1.2, 2.1, 4.0, 2.6 percentage points, respectively, compared with similar object detection models, such as Faster R-CNN, SSD, YOLOv5m, YOLOv7, YOLOv8, and YOLOv5s. The improved model can be expected to detect the small target diseases in complex environments of the actual field, particularly for a variety of diseases in apple leaves at the same time. The findings can provide a strong reference for the lightweight detection of apple leaf diseases in real natural environments, especially small-target diseases.
-
Keywords:
- disease /
- deep learning /
- object detection /
- apple leaf /
- YOLOv5s
-
-
图 2 改进YOLOv5s网络
注:Conv为卷积操作,BN为批标准化,SiLU和ReLU为激活函数,add为像素相加函数,Concat为通道数相加函数,Upsample为上采样操作,Shuffle_CBAM是包含CBAM的ShuffleNet模块,Shuffle_Block是基本的ShuffleNet模块,RFB-s为添加的模块。
Figure 2. Improved YOLOv5s network
Note: Conv is a convolution operation, BN is batch normalization, SiLU and ReLU are activation functions, add represents element-wise addition, Concat is channel-wise addition, Upsample stands for feature upsample, Shuffle_CBAM is a ShuffleNet module containing CBAM, Shuffle_Block is the basic ShuffleNet module, RFB-s indicates the newly added module.
图 7 基于 YOLOv5s 与本文检测苹果叶片病害结果对比
注:方框内为检测到的病害,方框上方为检测到的病害名称及病害概率,箭头指向的病害为YOLOv5s未检测到的病害。
Figure 7. Comparison of test results of apple leaf diseases based on YOLOv5s and our paper
Note:The boxes indicate the detected diseases, the top of the box indicates the name and probability of the detected diseases, and the diseases pointed by the arrows are those not detected by YOLOv5s.
表 1 苹果叶片病害数据集
Table 1 The dataset of apple leaf disease
病害种类
Disease type图片数量
Number of images来源
Source of images训练集
Training set增强后的训练集
Enhanced training set验证集
Validation set测试集
Test set黑星病Scab 915 CVPR2021 FGVC8 733 733 91 91 叶斑病 Frogeye leaf spot 952 CVPR2021 FGVC8 762 762 95 95 锈病 Rust 928 CVPR2021 FGVC8 743 743 93 92 白粉病 Powdery mildew 903 CVPR2021 FGVC8 723 723 90 90 花叶病 Mosaic 378 拍照+飞桨AI Studio 190 760 94 94 黑星病+叶斑病Scab + frogeye leaf spot 54 CVPR2021 FGVC8 33 66 11 10 锈病+叶斑病Rust + frogeye leaf spot 52 CVPR2021 FGVC8 32 64 10 10 总计 Total number 4 182 3 216 3 851 484 482 表 2 数据集中小目标的计算
Table 2 Calculation of small targets in the dataset
尺度比值
Ratio of scale黑星病
Scab叶斑病
Frogeye
leaf spot锈病
Rust白粉病
Powdery
mildew花叶病 Mosaic 病害目标宽度与原
始图像宽度的比值
Ratio of the disease target width
to the original image width0.75 0.04 0.05 0.61 0.61 病害目标高度与原
始图像高度的比值
Ratio of the disease target
height to the original image height0.71 0.07 0.08 0.59 0.68 注:病害目标指感兴趣的病害。 Note: The disease target refers to the disease of interest. 表 3 网络轻量化及小目标消融试验
Table 3 Network lightweight and small target ablation experiment
ShuffleNet v2
轻量化网络
ShuffleNet v2
lightweight
networkCBAM
注意力模块
CBAM
attention
module改进的
RFB-s结构
Improved
RFB-s
structureSIoU损
失函数
SIoU loss
functionmAP0.5/% 参数量
Parameters/
MB浮点计算数
Floating-point
operations
per second,
FLOPs/G网络
层数
Network
layers帧率
Frames
per second,
FPS/
(帧·s−1)小目标的
平均精度
Average
precision for
small targets
APS/%中目标的
平均精度
Average
precision
for medium
targets
APM/%大目标的
平均精度
Average
precision
for large
targets
APL /%− − − − 89.8 7.02 15.8 157 185 35.2 39.5 59.6 √ − − − 88.1 0.84 1.8 169 232 35.9 49.5 51.8 √ √ − − 89.6 0.82 1.7 187 196 37.5 36.0 52.4 √ − √ − 88.4 0.87 2.2 225 192 35.6 46.5 50.1 √ √ √ − 90.3 0.85 2.0 243 172 38.1 40.6 53.6 √ √ √ √ 90.6 0.85 2.0 243 175 38.2 48.3 52.9 注:“√” 表示使用此模块,“−” 表示不使用此模块,mAP0.5表示IoU大于0.5时预测正确的平均精度均值。
Note:"√" represents use this module, "−" represents do not use this module, mAP0.5 represents the mean average precision obtained from the correct prediction when IoU is greater than 0.5.表 4 不同注意力机制的消融试验
Table 4 Ablation experiment of different attention mechanisms
注意力机制
Attention mechanismsmAP0.5/% 准确率
Precision/%召回率
Recall/%F1值
F1 score/%参数量
Parameters/MBFLOPs/G FPS/(帧·s−1) APS/% APM/% APL/% SE 88.6 79.9 84.8 82 0.83 2.0 192 36.7 40.2 51.5 ECA 89.2 81.0 86.3 83 0.82 2.0 192 36.2 48.4 47.1 CA 88.6 80.0 86.2 83 0.83 2.0 172 36.4 39.0 50.0 Non-local 81.2 71.9 84.3 77 0.91 2.5 94 36.1 45.4 38.1 CBAM 90.6 81.8 86.5 84 0.85 2.0 175 38.2 48.3 52.9 表 5 不同检测模型性能对比
Table 5 Performance comparison of different detection models
模型
ModelmAP0.5/% 参数量
Parameters /MBFLOPs/G 准确率precision/% 叶斑病Frogeye leaf spot 白粉病Powdery mildew 锈病识Rust 黑星病Scab 花叶病Mosaic Faster R-CNN 90.9 60.14 121.45 85.8 98.8 82.9 95.0 92.0 SSD 88.9 24.28 137.97 83.1 96.4 80.1 93.8 91.1 YOLOv5m 91.1 20.86 47.90 86.7 98.2 83.2 94.7 92.7 YOLOv7 88.1 6.02 6.56 81.5 92.9 82.3 94.7 88.9 YOLOv8 88.0 11.13 14.28 83.7 94.5 80.4 92.2 88.9 YOLOv5s 89.8 7.02 15.80 83.3 98.0 81.8 94.4 91.6 改进模型
Improved YOLOv590.6 0.85 2.0 87.2 96.2 84.4 94.0 91.3 -
[1] 陈学森,韩明玉,苏桂林,等. 当今世界苹果产业发展趋势及我国苹果产业优质高效发展意见[J]. 果树学报,2010,27(4):598-604. CHEN Xuesen, HAN Mingyu, SU Guilin, et al. Discussion on today’s world apple industry trends and the suggestions on sustainable and efficient development of apple industry in China[J]. Journal of Fruit Science, 2010, 27(4): 598-604. (in Chinese with English abstract)
[2] 王树桐,王亚南,曹克强. 近年我国重要苹果病害发生概况及研究进展[J]. 植物保护,2018,44(5):13-25. WANG Shutong, WANG Ya’nan, CAO Keqiang. Occurrence of and research progress in important apple diseases in China in recent years[J]. Plant Protection, 2018, 44(5): 13-25. (in Chinese with English abstract)
[3] 邵明月,张建华,冯全,等. 深度学习在植物叶部病害检测与识别的研究进展[J]. 智慧农业(中英文),2022,4(1):29-46. SHAO Mingyue, ZHANG Jianhua, FENG Quan, et al. Research Progress of deep learning in detection and recognition of plant leaf diseases[J]. Smart Agriculture, 2022, 4(1): 29-46. (in Chinese with English abstract)
[4] 党满意,孟庆魁,谷芳,等. 基于机器视觉的马铃薯晚疫病快速识别[J]. 农业工程学报,2020,36(2):193-200. DANG Manyi, MENG Qingkui, GU Fang, et al. Rapid recognition of potato late blight based on machine vision[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2020, 36(2): 193-200. (in Chinese with English abstract)
[5] SHRIVASTAVA V K, PRADHAN M K. Rice plant disease classification using color features: A machine learning paradigm[J]. Journal of Plant Pathology, 2021, 103: 17-26. doi: 10.1007/s42161-020-00683-3
[6] YANG N, QIAN Y, El-MESERY H S, et al. Rapid detection of rice disease using microscopy image identification based on the synergistic judgment of texture and shape features and decision tree-confusion matrix method[J]. Journal of the Science of Food and Agriculture, 2019, 99: 6589-6600. doi: 10.1002/jsfa.9943
[7] LI Z, GUO R, LI M, et al. A review of computer vision technologies for plant phenotyping[J]. Computers and Electronics in Agriculture, 2020, 176: 105672. doi: 10.1016/j.compag.2020.105672
[8] 郭文娟,冯全,李相周. 基于农作物病害检测与识别的卷积神经网络模型研究进展[J]. 中国农机化学报,2022,43(10):157-166. GUO Wenjuan, FENG Quan, LI Xiangzhou. Research progress of convolutional neural network model based on crop disease detection and recognition[J]. Journal of Chinese Agricultural Mechanization, 2022, 43(10): 157-166. (in Chinese with English abstract)
[9] 李柯泉,陈燕,刘佳晨,等. 基于深度学习的目标检测算法综述[J]. 计算机工程,2022,48(7):1-12. LI Kequan, CHEN Yan, LIU Jiachen, et al. Survey of deep learning-based object detection algorithms[J]. Computer Engineering, 2022, 48(7): 1-12. (in Chinese with English abstract)
[10] GIRSHICK R, DONAHUE J, DARRELL T, et al. Rich feature hierarchies for accurate object detection and semantic segmentation[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Columbus, 2014: 24–27.
[11] GIRSHICK R. Fast R-CNN[C]//Proceedings of the IEEE International Conference on Computer Vision, Santiago, 2015: 1440-1448.
[12] REN S, HE K, GIRSHICK R, et al. Faster R-CNN: Towards real-time object detection with region proposal networks[J]. Advances in Neural Information Processing Systems, 2015, 28: 91-99.
[13] REDMON J, DIVVALA S, GIRSHICK R, et al. You only look once: Unified, real-time object detection[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, 2016: 779-788.
[14] REDMON J, FARHADI A. YOLO9000: Better, faster, stronger[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, 2017: 6517-6525.
[15] REDMON J, FARHADI A. YOLOv3: An incremental improvement [EB/OL]. (2018-04-08) [2023-06-10]https://arxiv.org/abs/1804.02767.
[16] ALEXEY B, WANG C, LIAO H. YOLOv4: Optimal speed and accuracy of object detection [EB/OL]. (2020-04-23) [2023-06-10]https://arxiv.org/abs/2004.10934.
[17] LIU W, ANGUELOV D, ERHAN D, et al. SSD: Single shot multibox detector[C]//Cham: European Conference on Computer Vision. Cham. 2016: 21-37.
[18] 李就好,林乐坚,田凯,等. 改进Faster R-CNN的田间苦瓜叶部病害检测[J]. 农业工程学报,2020,36(12):179-185. LI Jiuhao, LIN Lejian, TIAN Kai. Detection of leaf diseases of balsam pear in the field based on improved Faster R-CNN[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2020, 36(12): 179-185. (in Chinese with English abstract)
[19] XIE X, MA Y, LIU B, et al. A deep-learning-based real-time detector for grape leaf diseases using improved convolutional neural networks[J]. Frontiers in Plant Science, 2020, 11: 751. doi: 10.3389/fpls.2020.00751
[20] MATHEW M P, MAHESH T Y. Leaf-based disease detection in bell pepper plant using YOLO v5[J]. Signal, Image, and Video Processing, 2022, 16: 841-847. doi: 10.1007/s11760-021-02024-y
[21] 孙钰,周焱,袁明帅,等. 基于深度学习的森林虫害无人机实时监测方法[J]. 农业工程学报,2018,34(21):74-81. SUN Yu, ZHOU Yan, YUAN Mingshuai, et al. UAV real-time monitoring for forest pest based on deep learning[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2018, 34(21): 74-81. (in Chinese with English abstract)
[22] 李红光,于若男,丁文锐. 基于深度学习的小目标检测研究进展[J]. 航空学报,2021,42(7):024691. LI Hongguang, YU Ruonan, DING Wenrui. Research development of small object traching based on deep learning[J]. Acta Aeronautica et Astronautica Sinica, 2021, 42(7): 024691. (in Chinese with English abstract)
[23] 薛卫,程润华,康亚龙,等. 基于GC-Cascade R-CNN的梨叶病斑计数方法[J]. 农业机械学报,2022,53(5):237-245. XUE Wei, CHEN Runhua, KANG Yalong, et al. Pear leaf disease spot counting method based on GC-Cascade R-CNN[J]. Transactions of the Chinese Society for Agricultural Machinery, 2022, 53(5): 237-245. (in Chinese with English abstract)
[24] ZHAO S, LIU J, WU S. Multiple disease detection method for greenhouse-cultivated strawberry based on multiscale feature fusion Faster R-CNN[J]. Computers and Electronics in Agriculture, 2022, 199: 107176. doi: 10.1016/j.compag.2022.107176
[25] 刘双印,范文婷,邓皓,等. 采用改进RetinaNet的笼养肉鸽繁育期个体检测模型[J]. 农业工程学报,2022,38(13):184-193. LIU Shuangyin, FAN Wenting, DENG Hao, et al. Individual detection model for caged meat pigeons during breeding period based on improved RetinaNet[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(13): 184-193. (in Chinese with English abstract)
[26] THAPA R, ZHANG K, SNAVELY N, et al. Plant Pathology 2021-FGVC8[EB/OL]. (2021-03-16) [2023-06-10].https://kaggle.com/competitions/plant-pathology-2021-fgvc8.
[27] AI S. Pathological image of apple leaf [EB/OL]. (2021-08-18) [2023-06-10]https://aistudio.baidu.com/aistudio/datasetdetail/11591.
[28] CHEN C, LIU M Y, TUZEL O, et al. RCNN for small object detection[C]//Proceeding of Asian Conference on Computer Vision. Cham: Springer, 2016: 214230.
[29] JOCHER G. Ultralytics/yolov5 [EB/OL]. (2022-11-22) [2023-06-10]https://github.com/ultralytics/yolov5.
[30] MA N, ZHANG X, ZHENG H T, et al. Shufflenet v2: Practical guidelines for efficient cnn architecture design[C]//Proceedings of the European Conference on Computer Vision, Munich, 2018: 116-131.
[31] ZHANG X, ZHOU X, LIN M, et al. Shufflenet: An extremely efficient convolutional neural network for mobile devices[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, 2018: 6848-6856.
[32] ZHORA G. SIoU Loss: More powerful learning for bounding box regression [EB/OL]. (2022-05-25) [2023-06-10]https://arxiv.org/ftp/arxiv/papers/2205/2205.12740.pdf.