Method for rapid detection of rice leaf disease spots in complex scene based on mobile device computing power
By introducing a ternary attention mechanism and a C3CBAM module into the YOLOv5 model, and using lightweight convolution GhostConv, combined with data augmentation techniques, the real-time and accuracy issues of rice leaf disease detection were solved, achieving efficient detection on mobile devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUZHOU INST OF ZHEJIANG UNIV
- Filing Date
- 2024-12-02
- Publication Date
- 2026-04-21
AI Technical Summary
Existing technologies lack real-time performance and accuracy in detecting rice leaf diseases in complex scenarios. The models are large and unsuitable for deployment on mobile devices, making it difficult to meet the real-time detection requirements in practical applications.
Using YOLOv5 as the base model, we introduce a ternary attention mechanism and a C3CBAM module, replace ordinary convolutions with lightweight convolution GhostConv, and combine data augmentation techniques such as Gaussian blur and random occlusion. The model is then trained and deployed on mobile devices.
It achieves high accuracy (mAP 98.3%) and high inference speed (1.79 FPS) for rice leaf disease detection on mobile devices, improving detection efficiency and speed.
Smart Images

Figure CN119723166B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for rapid and accurate detection of major leaf diseases in rice under complex conditions. Background Technology
[0002] Leaf diseases are a major factor affecting rice growth and rice quality. Rice blast, rice false smut, whitehead, sesame leaf spot, red blight, and rice stem nematode are common diseases in rice fields, often occurring in clusters and impacting rice quality. Therefore, timely detection and identification of rice leaf diseases are crucial for improving rice growth and rice quality.
[0003] In existing research on crop disease detection, Yao Qing et al. proposed an improved RetinaNet-based automatic detection model for rice canopy pest damage. They used ResNet101 as the feature extraction network and group normalization as the normalization method to improve the feature pyramid network structure. Experiments verified that the improved RetinaNet model achieved an average accuracy of 93.76% in detecting two types of pest damage regions. Li et al. used eight common image classification networks to classify and identify four types of rice diseases. They selected the ResNet50 network as the feature extraction network and proposed an enhanced feature fusion and target adaptation network (EFFTAN), achieving an average detection accuracy of 95.3% and effectively detecting dense light spot features.
[0004] These existing methods achieve high accuracy in crop disease diagnosis, but they fail to consider the computing power of mobile devices in research, nor do they simulate or conduct field detection on mobile devices. This makes it difficult for the improved models to simultaneously meet the accuracy and real-time requirements of plant leaf disease detection in real-world scenarios. Cui et al. proposed introducing a convolutional block attention module into the autoencoder and using image reconstruction technology to enhance the interpretability of maize leaf disease features. Experiments verified that the improved model showed good recognition performance on the Plant Village public maize dataset, but it failed to simulate or conduct field detection on mobile devices. Li et al. proposed an improved YOLOv5 algorithm based on shallow feature layers. This algorithm increases the receptive field in the feature pyramid by adding a quadruple downsampling method to improve the detection ability of small targets. Experimental results trained on a dataset in a complex farmland scenario showed that the average detection accuracy of the improved algorithm was improved by 2.4%, which can better overcome field environmental noise and meet the practical requirements of wheat ear detection and counting, but it failed to simulate or conduct field detection on mobile devices.
[0005] The existing literature on the detection and identification of rice leaf diseases still has limitations: (1) It mainly focuses on solving the problem of detection accuracy of crop leaf diseases, without considering the real-time nature of disease detection in actual applications. (2) The model size is large, which is not conducive to deployment on mobile devices. Real-time detection tasks often have higher requirements for model size. (3) It does not conduct simulation on mobile devices or field detection, which is not conducive to dealing with sudden problems in actual applications. Summary of the Invention
[0006] The purpose of this invention is to address the problems of low real-time efficiency and accuracy in detecting major rice leaf diseases using mobile devices in complex scenarios, as well as slow model inference speed. This invention proposes a rapid and accurate method for detecting common rice leaf diseases based on the computing power of mobile devices. This method achieves a mAP of 98.3% for detecting different types of rice leaf diseases, and the inference speed on a Raspberry Pi mobile device reaches 1.79 FPS, an improvement of 73.8% compared to the previous method, achieving both high accuracy and high inference speed.
[0007] To solve the above problems, the technical solution of the present invention is as follows:
[0008] A method for detecting leaf disease spots in rice based on the computing power of mobile devices, characterized by the following steps:
[0009] (1) Collect images of common rice leaf disease lesions and perform image preprocessing to obtain a rice leaf disease image sample dataset, wherein the common rice leaf diseases include whitehead, rice blast, rice false smut and sesame spot;
[0010] (2) Perform sample data augmentation on the rice leaf disease image sample dataset in step (1), increase the number of samples and highlight the target features of the samples to obtain the rice leaf disease lesion image sample dataset.
[0011] (3) Use image annotation software to annotate the rice leaf disease lesions in the rice leaf disease lesion image sample dataset of step (2) with rectangular boxes to obtain the final sample dataset of rice leaf disease lesion images.
[0012] (4) Use the final sample dataset of rice leaf disease lesion images from step (3) to train the detection model. The detection model is based on the target detection algorithm YOLOv5. A three-element attention mechanism is introduced to strengthen the attention feature extraction module in the target detection algorithm YOLOv5. The C3 module of the backbone network in the target detection algorithm YOLOv5 is replaced by the C3CBAM module, and the convolution Conv in the target detection algorithm YOLOv5 is replaced by the lightweight convolution GhostConv, to obtain the final detection model.
[0013] (5) Deploy the final detection model obtained in step (4) onto a mobile Raspberry Pi and accelerate it with MNN to detect the input rice leaf image and obtain the detection result.
[0014] Furthermore, in the rice leaf disease image sample dataset of step (1), the collected common rice diseases include four types: whitehead disease (RWE), rice blast (RB), rice false smut (RFS), and sesame spot disease (BS). After data augmentation of all rice leaf disease samples, the lesions in the images are labeled with rectangular boxes using Labelme image annotation software.
[0015] Furthermore, in the specific method of sample data augmentation, the horizontal flipping is to mirror the image along the horizontal direction;
[0016] The Gaussian blurring process, which involves convolving image pixels with a Gaussian distribution, includes the following steps:
[0017] Calculate the weighted average of each pixel and its eight surrounding pixels. The weighting method uses a normal distribution, i.e., a two-dimensional Gaussian function. The Gaussian formula is as follows:
[0018]
[0019] Where x represents the horizontal coordinate of a pixel in the image coordinate system, and y represents the vertical coordinate of a pixel in the image coordinate system. The standard deviation represents the weight allocation pattern in Gaussian blur processing; Preferably 3.0
[0020] Adding Gaussian noise involves adding noise points to the image to interfere with it. The probability density P(x,y) follows a normal distribution, i.e., a two-dimensional Gaussian function. The Gaussian formula is as follows:
[0021]
[0022] The standard deviation of the probability density in Gaussian noise processing is represented by the expression. For each input pixel, the output pixel is obtained by adding it to a random number that conforms to a Gaussian distribution. This effectively simulates the noise interference environment encountered when shooting with a mobile device and expands the sample size of the dataset. In this invention, Preferably 35.0
[0023] The random occlusion refers to occluding an indefinite number of square regions of fixed size at random locations in the image, and filling the region with a constant value (such as 0) or a random value. This can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the sample size of the dataset. The occlusion number is set in the range of 1-5 in this invention.
[0024] Each sample data augmentation method augments each sample, blends it with the original image, and splits it into training and validation sets.
[0025] Furthermore, the specific steps for obtaining the final detection model are as follows:
[0026] 1) Select the detection network architecture and choose the YOLOv5 object detection algorithm as the base model;
[0027] 2) A ternary attention mechanism is incorporated into the initial part of the backbone network to strengthen the network's feature connections to leaf disease information on the previous layer's input image in the dimensions of height, width, and channel. The feature map refers to the output generated after the input image has been processed by the previous layer. The feature information refers to rice leaf disease lesions.
[0028] 3) In the neck network, the original C3 module of the base model is replaced with the C3CBAM module. While extracting feature information from images of different dimensions, the neck network's attention to edge feature information is enhanced. The different dimensions refer to height, width, and channel dimensions.
[0029] 4) Replace the original ordinary convolution of the base model with the lightweight convolution GhostConv module and train it on the training set to obtain the final detection model.
[0030] Furthermore, the implementation principle of the final YOLOv5 detection model is as follows:
[0031] 1) Given an input feature map tensor Where H, W, and C represent the height, width, and number of channels of the feature map, respectively, and R indicates that it is a matrix. When passing through the Backbone stage of the YOLOv5 model, χ is first replaced by a lightweight GhostConv module with a stride of, for example, 2, to reduce the number of model parameters. Then, a Triplet Attention module is incorporated after the GhostConv layer. This module captures the interaction between the spatial and channel dimensions of the input tensor through a three-branch structure and rotation operations, allowing the image to be read by the network with complete information even in the shallow network stage. Subsequently, the information from the feature map is output to the next layer, where the C3 feature extractor extracts information from the feature map in both channel and spatial dimensions, and the Spatial Pyramid Pooling (SPP) module extracts local and global feature information from the feature map.
[0032] 2) The tensor information of the feature map obtained after the above operations enters the Head part of the neck network. First, it extracts features through a convolutional layer with a kernel size of, for example, 3×3 and a stride of 1. Then, the image is upsampled to double the resolution and combined with the feature layer of the same resolution from the Backbone stage in terms of channel dimension. Finally, the feature information is processed through different C3CBAM layers to output the features. In the C3CBAM layer, multiple convolutional operations in the C3 module perform preliminary extraction of the newly assembled feature information from the previous layer. The kernel size can be 3×3 with a stride of 1. The BatchNorm operation normalizes the distribution of the feature map, and the ReLU function is used as the activation function to reduce the computational cost of the model.
[0033] Furthermore, the final detection model detects input rice leaf images. The detection results are jointly evaluated by the number of parameters, average precision (AP), mean detection precision (mAP), CPU-FPS on the Raspberry Pi, and MNN-FPS after accelerated inference. The number of parameters is an indicator of the complexity of the detection model. The AP value is an approximation of the area under the precision-recall curve for a certain type of rice lesion. mAP is obtained by averaging the AP values of detected rice leaf lesions of various types. The calculation formula is as follows: Where N represents the number of types of rice leaf disease lesions; CPU-FPS refers to the inference speed used to run the detection model on the Raspberry Pi; MNN-FPS refers to the inference speed used to accelerate and run the detection model using the Raspberry Pi MNN engine, and the higher the value, the faster the inference speed of the detection model.
[0034] When performing target detection on mobile devices, the device's computing power must be considered. This invention uses a lightweight, optimized model and accelerates it for mobile devices, enabling the model to maintain high accuracy while reducing computing resource requirements and improving operational efficiency. In rice field detection, there is a reality of "complex backgrounds," meaning that in target detection tasks, the visual features of the background are very similar to the target itself, making the detection task difficult. This invention performs Gaussian blurring, adds Gaussian noise, and performs random occlusion processing on the collected images of common rice leaf diseases to highlight the target features of the samples. Therefore, this invention not only achieves the aforementioned application suitable for the computing power of mobile devices but also enables accurate detection of rice leaf images under "complex backgrounds."
[0035] In summary, the present invention provides a method for rapid and accurate detection of major rice leaf diseases in complex scenarios. The collected rice leaf disease image sample dataset includes whitehead disease, rice blast, rice false smut, and sesame spot disease. Data augmentation methods are used to expand the number of samples in the dataset and highlight target features. After annotation, the final sample dataset of rice leaf disease lesion images is obtained. A detection model is trained on this dataset. The detection model is based on the YOLOv5 target detection algorithm, and a ternary attention mechanism is introduced to enhance the attention feature extraction module in the YOLOv5 target detection algorithm. The C3 module of the backbone network in the YOLOv5 target detection algorithm is replaced with the C3CBAM module, and the lightweight convolutional GhostConv is replaced with the convolutional Conv in the YOLOv5 target detection algorithm. Experiments were conducted on the validation set of the final sample dataset of rice leaf disease lesion images. The mAP of the detection dataset reached 98.3%, and the inference speed on the Raspberry Pi mobile device reached 1.79 FPS, an improvement of 73.8% compared to the original, achieving high accuracy and high inference speed. Attached Figure Description
[0036] Figure 1 This is an overall flowchart of the rice leaf disease lesion detection method of the present invention.
[0037] Figure 2-1 These are actual pictures of lesions from four major rice leaf diseases. Figure 2-2 The images show lesions of four major rice leaf diseases, labeled with Labelme.
[0038] Figure 3 This invention illustrates the data augmentation of a dataset of rice leaf disease lesion images. The data is presented in the following order from top to bottom: Gaussian blurring, adding Gaussian noise, and random occlusion. The data also shows the following diseases from left to right: rice white spot (RWE), rice blast (RB), rice false smut (RFS), and sesame spot (BS).
[0039] Figure 4 This is the final detection model structure diagram obtained in this invention, consisting of three main modules: an input module, a backbone network module, a neck module, and an output detection module. In the backbone network, the original YOLOv5 convolutional module is replaced with a lightweight GhostConv module before the C3 module, reducing model complexity and size. A Triplet Attention module is introduced before the first GhostConv module to extract the relationship between feature map tensor information in the width, height, and number of channels. In the neck network, four C3CBAM modules replace the original YOLOv5 C3 module, significantly improving the model's accuracy in detecting common rice leaf diseases while maintaining a fast inference speed on a mobile Raspberry Pi.
[0040] Figure 5 This is a visualization of the ablation experiment of the Triplet Attention and different attention mechanisms of this invention on a rice dataset. From left to right, the modules are SE attention mechanism, CBAM attention mechanism, C3CBAM module, and Triplet Attention module. From top to bottom, the modules are rice white spot disease (RWE), rice blast (RB), rice false smut (RFS), and sesame leaf spot (BS).
[0041] Figure 6 This is a structural diagram of the C3CBAM module of the present invention in the final detection model.
[0042] Figure 7 This invention compares the detection accuracy and loss value of the final detection model obtained in this invention with other models on rice leaf disease lesion image sample datasets. Detailed implementation method:
[0043] To make the description of the objectives, technical solutions, and advantages of this invention clearer and more accurate, the invention will be further described below in conjunction with embodiments and accompanying drawings. It should be specifically noted that the illustrative embodiments and descriptions of this invention are only for explaining the invention, but the embodiments of this invention are not limited thereto:
[0044] The present invention provides a method for rapid and accurate detection of common rice leaf diseases in complex scenarios based on the computing power of mobile devices. The method trains a model on a dataset of rice leaf disease lesion images taken in real farmland scenarios, and continuously optimizes the algorithm to address the problems of limited computing power and difficulty in reasoning on mobile devices, resulting in the final detection model.
[0045] In this embodiment, refer to the appendix Figure 1 This paper describes a method for detecting rice leaf disease lesions in a dataset of images. The specific implementation process is as follows: First, rice leaf disease lesion images are collected from real farmland and preprocessed to obtain a dataset. Then, data augmentation and annotation are performed on the dataset to obtain the final dataset of rice leaf disease lesion images (hereinafter referred to as the dataset). Object detection is then performed on this dataset using the YOLOv5 object detection algorithm as the base model. A ternary attention mechanism and a C3CBAM feature fusion module are introduced, and the GhostConv lightweight module replaces the ordinary convolution module to obtain the final detection model. The detection results are evaluated by the mean accuracy (mAP) and frame rate (FPS). mAP is the average of the AP values of all detected rice leaf disease lesions. The AP value is an approximation of the area under the precision and recall curve, and its calculation formula is... Where N represents the number of types of rice leaf disease lesions; FPS is the rate at which continuous images are captured or displayed; a higher FPS indicates a faster inference speed. CPU-FPS refers to the inference speed used when running the model on a Raspberry Pi, and MNN-FPS refers to the inference speed using the Raspberry Pi for detection and accelerated by the MNN engine. Dataset preprocessing involves using OpenCV to directly crop the redundant parts of the collected images of common rice leaf disease lesions, and uniformly resizing the images to 3024×3024 pixels to obtain the rice leaf disease image sample dataset.
[0046] In this embodiment, the data augmentation of the rice leaf disease image sample dataset includes: from left to right, the images are whitehead (RWE), rice blast (RB), rice false smut (RFS), and sesame spot (BS); from top to bottom, the images are: original image, Gaussian blur processing, addition of Gaussian noise, and random occlusion. These data augmentation methods are completed before training, and the number of image samples after augmentation is expanded to 2108.
[0047] The Gaussian blurring process involves convolving the image with a Gaussian distribution and calculating the weighted average of each pixel with its eight surrounding pixels. This softens the color transitions and achieves a blurring effect. The Gaussian formula is as follows:
[0048]
[0049] Where x represents the horizontal coordinate of a pixel in the image coordinate system, and y represents the vertical coordinate of a pixel in the image coordinate system. The standard deviation represents the weight allocation pattern in Gaussian blur processing;
[0050] Adding Gaussian noise involves adding noise points to the image to interfere with it. The probability density P(x,y) follows a normal distribution, i.e., a two-dimensional Gaussian function. The Gaussian formula is as follows:
[0051]
[0052] The standard deviation of the probability density in Gaussian noise processing is represented by the sum of the input pixel and a random number that conforms to a Gaussian distribution. This can effectively simulate the noise interference environment encountered when shooting with mobile devices and expand the sample size of the dataset.
[0053] The random occlusion refers to occluding an indefinite number of fixed-size square regions at random locations in the image and filling the region with a constant value (such as 0) or a random value. This can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the sample size of the dataset.
[0054] In this embodiment, each sample is enhanced using each data augmentation method, and then mixed with the original image to obtain a rice leaf disease lesion image sample dataset. The purpose is to better evaluate the model's performance and generalization ability. Then, Labelme image annotation software is used to annotate the lesions in the rice leaf disease lesion image sample dataset with rectangular boxes, ultimately resulting in a rice leaf disease image sample dataset containing 2108 images of whitehead disease (RWE), rice blast (RB), rice false smut (RFS), and sesame spot (BS). This dataset is then divided into training and validation sets in an 8:2 ratio. Images of whitehead disease, rice blast, rice false smut, and sesame spot are used as references. Figure 2-1 ;Labelme annotation example reference Figure 2-2 .
[0055] In this embodiment, refer to Figure 4 The model consists of four main modules: an input module, a backbone network module, a neck module, and an output detection module. In the backbone network, the original ordinary convolutional module is replaced with a lightweight GhostConv module before the C3 module, reducing model complexity and size. A TripletAttention module is introduced before the first GhostConv module to extract the relationship between feature map tensor information in the width, height, and number of channels. In the neck network, the original C3 module is replaced with a C3CBAM module, significantly improving the model's accuracy in detecting common rice leaf diseases.
[0056] In this embodiment, Figure 5 Visualizations of the ablation experiments on a rice dataset using Triplet Attention and different attention mechanisms are presented. From top to bottom, the images depict rice white spot (RWE), rice blast (RB), rice false smut (RFS), and rice leaf spot (BS). From left to right, the images represent the original image, SE attention, CBAM attention, C3CBAM module, and Triplet Attention mechanism. The bright red areas in the images represent regions of interest for the model. It can be seen that the addition of the C3CBAM module and Triplet Attention mechanism helps the model focus on rice leaf disease lesion regions, aiding in target localization and regression, thereby improving the model's detection accuracy.
[0057] In this embodiment, Figure 6The structure diagram of the C3CBAM module in the final YOLOv5 detection model is given. When the feature information generated by the neck network passes through the C3CBAM module, it is first split into two branches and convolved separately to extract feature values. Then, one branch passes through N Bottleneck modules and is concatenated with the feature map from the other branch along the channel dimension to obtain feature map B. The parameters of feature map B are then shared as input to the CBAM module, and successively passed through the channel attention module and the spatial attention module to output a feature map emphasizing edge features. The C3CBAM module can help the final YOLOv5 detection model promote feature fusion of feature map information from different dimensions within the network with only a small increase in computation.
[0058] In this embodiment, Figure 7 The comparison of the detection accuracy and loss value of the final detection model with other models on the dataset is presented. Other models (YOLOv5, MobileNetV3, ShuffleNetV2, XceptionNet, and the final detection model (named TG_YOLOv5)) showed different mAP values for the four types of rice leaf disease spots. It can be seen that the final YOLOv5 detection model significantly improves the detection accuracy of rice leaf disease spots, with an accuracy higher than YOLOv5, MobileNetV3, ShuffleNetV2, and XceptionNet. This indicates that the model effectively improves the network's recognition accuracy by incorporating the TripletAttention mechanism and the C3CBAM attention module. Regarding the loss value, it is lower than YOLOv5, MobileNetV3, ShuffleNetV2, and XceptionNet, indicating that the final detection model is gradually learning and adapting to the training data, and its prediction accuracy for detecting the four types of rice leaf disease spots is improved compared to the original YOLOv5.
[0059] Experimental results show that these improvements are effective in enhancing model performance. Table 1 presents a performance comparison of different models on the dataset. The table shows that the models with the Triplet and C3CBAM modules respectively improved mAP by 0.7% and 0.8% compared to the original YOLOv5 model; the model replacing the GhostConv module reduced the number of parameters by 10.7% compared to the original YOLOv5 model. In Table 1, the "Model" column lists the names of the different models improved during the experiment. The overall experimental procedure for model improvement includes:
[0060] Starting from the base model YOLOv5, a Triplet Attention mechanism is introduced to improve the model's feature extraction capability, resulting in a 0.7% improvement in detection mAP, while the number of parameters increases by 0.9%. Then, to address the issue of low detection performance for edge features of different dimensions, a fusion of the C3 module and the CBAM mechanism is proposed, resulting in a 0.8% improvement in detection mAP compared to YOLOv5, a 0.7% increase in the number of parameters compared to YOLOv5, but a 0.6% reduction compared to directly adding the CBAM mechanism. Finally, the original ordinary convolutional module is replaced with the GhostConv lightweight module before the C3 module in the network backbone, reducing the number of parameters by 10.7%, reducing the model size, and only slightly decreasing the accuracy.
[0061] Table 1 shows the performance comparison results of different models on four rice leaf disease lesion datasets during the improvement process.
[0062]
[0063] Table 2 shows the performance comparison results of different models on the dataset during the experiment. The overall experimental process for model improvement includes:
[0064] The YOLOv5 model, the YOLOv5 model with lightweight networks (including MobilenetV3, ShufflenetV2, and XceptionNet), and the TG_YOLOv5 model were validated on a rice dataset. Finally, the frame rate was tested on a Raspberry Pi. The final detection model achieved a 1.2% improvement in mAP compared to YOLOv5, and 9.1%, 48.3%, and 4.9% higher accuracy than MobilenetV3, ShufflenetV2, and XceptionNet, respectively. The number of parameters was reduced by 0.7M compared to YOLOv5. Regarding inference speed on the Raspberry Pi, the TG_YOLOv5 model achieved 0.42 FPS higher than YOLOv5, and this was further improved by 0.34 FPS after acceleration using the MNN engine. In conclusion, compared to YOLOv5, the proposed TG_YOLOv5 detection model achieved a 1.2% improvement in mAP, reaching 98.3%, while increasing FPS from 1.03 to 1.79, maintaining a relatively fast inference speed.
[0065] Table 2 shows the performance comparison results of different models on four rice leaf disease lesion datasets.
[0066]
[0067] The above description is merely a further embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitution or partial modification made by those skilled in the art within the scope of the technology disclosed in the present invention, according to the technical process and method steps of the present invention, and the resulting functions and effects do not exceed the information covered by the specification and drawings, shall fall within the scope of protection of the present invention.
Claims
1. A method for detecting leaf disease spots in rice based on the computing power of mobile devices, characterized in that, Includes the following steps: (1) Collect images of common rice leaf disease lesions and perform image preprocessing to obtain a rice leaf disease image sample dataset, wherein the common rice leaf diseases include whitehead, rice blast, rice false smut and sesame spot; (2) Perform sample data augmentation on the rice leaf disease image sample dataset in step (1), increase the number of samples and highlight the target features of the samples to obtain the rice leaf disease lesion image sample dataset. (3) Use image annotation software to annotate the rice leaf disease lesions in the rice leaf disease lesion image sample dataset of step (2) with rectangular boxes to obtain the final sample dataset of rice leaf disease lesion images. (4) The detection model is trained using the final sample dataset of rice leaf disease lesion images from step (3). The detection model is based on the target detection algorithm YOLOv5. A three-element attention mechanism is introduced to enhance the attention feature extraction capability of the target detection algorithm YOLOv5. The C3 module of the neck network in the target detection algorithm YOLOv5 is replaced by the C3CBAM module, and the convolution Conv in the backbone network of the target detection algorithm YOLOv5 is replaced by the lightweight convolution GhostConv, so as to obtain the final detection model. (5) Deploy the final detection model obtained in step (4) onto a mobile Raspberry Pi and accelerate it with MNN to detect the input rice leaf image and obtain the detection result. The implementation principle of the detection model is as follows: 1) Given an input feature map tensor Where H, W, and C represent the height, width, and number of channels of the feature map, respectively, and R represents a multidimensional matrix; when χ passes through the backbone network of the basic model, it first uses GhostConv lightweight convolution to replace the original convolution Conv, reducing the number of model parameters; then, after the GhostConv layer, a Triplet Attention module is introduced to capture the interaction between feature information in the spatial and channel dimensions, so that the image can be read by the network in a state that retains complete information in the shallow network stage; subsequently, the feature information is input to the next layer, and the C3 feature extractor completes the extraction of feature information in the channel and spatial dimensions, and the spatial pyramid pooling module SPP completes the extraction of local and global feature information of the feature map; 2) When the feature map obtained after the above operations enters the neck network, it first extracts features through convolution Conv, and then the image is upsampled to increase the resolution of the feature map and combine it with the feature map of the same resolution in the backbone network in terms of channel dimension. Then, it outputs features after passing through C3CBAM layers of different dimensions. The BatchNorm operation is used to normalize the distribution of the feature map tensor, and the ReLU function is used as the activation function to reduce the computation of the model.
2. The method according to claim 1, characterized in that, The specific methods for sample data enhancement in step (2) include Gaussian blurring, adding Gaussian noise, and random occlusion: The Gaussian blurring process, which involves convolving image pixels with a Gaussian distribution, includes the following steps: Calculate the weighted average of each pixel and its eight surrounding pixels. The weighting method uses a normal distribution, i.e., a two-dimensional Gaussian function. The Gaussian formula is as follows: Where x represents the horizontal coordinate of a pixel in the image coordinate system, and y represents the vertical coordinate of a pixel in the image coordinate system. The standard deviation represents the weight allocation pattern in Gaussian blurring. Adding Gaussian noise involves adding noise points to the image to interfere with it. The probability density P(x,y) follows a normal distribution, i.e., a two-dimensional Gaussian function. The Gaussian formula is as follows: The standard deviation of the probability density in Gaussian noise processing is represented by the sum of the input pixel and a random number that conforms to a Gaussian distribution. This can effectively simulate the noise interference environment encountered when shooting with mobile devices and expand the sample size of the dataset. The random occlusion refers to occluding an indefinite number of square regions of fixed size at random locations in the image and filling the region with a constant or random value. This can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the sample size of the dataset. Each data augmentation method augments each sample, and the augmented samples are then mixed with the rice leaf disease image sample dataset to create a training set and a validation set.
3. The method according to claim 1, characterized in that, The specific steps to obtain the detection model are as follows: 1) Select the detection network architecture and choose the YOLOv5 object detection algorithm as the base model; 2) Introduce a ternary attention mechanism into the initial part of the backbone network of the basic model to strengthen the feature connection of the backbone network to the feature information in the feature map in the dimensions of height, width and channel. 3) In the neck network, the original C3 module in the neck network of the basic model is replaced with the C3CBAM module. While extracting feature information from images of different dimensions, the neck network's attention to edge feature information of the feature map is enhanced. The different dimensions refer to height, width, and channel dimensions. 4) Replace the original Conv convolutions in the backbone network of the base model with lightweight convolution GhostConv, and train on the training set to obtain the final detection model.
4. The method according to claim 1, characterized in that, The final detection model obtained in step (4) is used to detect the input rice leaf images. The detection results are jointly evaluated by the number of parameters, average precision (AP), mean detection precision (mAP), the detection frame rate (CPU-FPS) on the Raspberry Pi, and the detection frame rate (MNN-FPS) after accelerated inference. The number of parameters is an indicator of the complexity of the detection model. The AP value is an approximation of the area under the precision and recall curve for a certain type of rice lesion. mAP is obtained by averaging the AP values of various types of rice leaf lesions detected. The calculation formula is as follows: Where N represents the number of types of rice leaf disease lesions; CPU-FPS refers to the inference speed used to run the detection model on the Raspberry Pi; MNN-FPS refers to the inference speed used to accelerate and run the detection model using the Raspberry Pi MNN engine, and the higher the value, the faster the inference speed of the detection model.
Citation Information
Patent Citations
Improved YOLOv5 lightweight community scene pedestrian detection method
CN115862066A
Mung bean leaf spot disease spot detection method and device based on LS-YOLOv5 network
CN116030348A
Glass bead defect detection method based on improved spatial pyramid pooling
CN118485631A
Method for identifying multiple types of scattered and stacked parts based on improved yov5
CN118781400A