Method for rapidly detecting rice leaf disease spots in complex scene based on computing power of mobile equipment

By using the improved YOLOv5 detection model on mobile devices, combined with the ternary attention mechanism, C3CBAM module and lightweight convolution GhostConv, the problems of low real-time efficiency and low accuracy of rice leaf disease detection in complex scenarios are solved, and the detection effect of high accuracy and fast inference speed is achieved.

CN119723166AActive Publication Date: 2025-03-28HUZHOU INST OF ZHEJIANG UNIV

Patent Information

Application Number
CN202411752906.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-28
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

The prior art uses mobile devices to detect major leaf diseases of rice in complex scenarios with low real-time efficiency and low accuracy, and the model reasoning speed is slow.

Method used

Using the detection model based on YOLOv5, a ternary attention mechanism and C3CBAM module are introduced, and the ordinary convolution module is replaced with lightweight convolution GhostConv, and data enhancement and annotation are performed, and deployed to the mobile Raspberry Pi for acceleration.

Benefits of technology

High accuracy (mAP reaches 98.3%) and high inference speed (up to 1.79 FPS on Raspberry Pi, an increase of 73.8% from the original one).

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723166A_ABST
    Figure CN119723166A_ABST
Patent Text Reader

Abstract

The invention discloses a method for detecting rice leaf disease scabs based on computing power of a mobile device, detection of rice diseases is completed through an improved detection model based on YOLOv5, a ternary attention mechanism is introduced into the detection model to enhance attention feature extraction ability in YOLOv5, a C3CBAM module is used for replacing a C3 module of a neck network in YOLOv5, and the C3CBAM module is used for detecting the disease scabs of the rice leaf disease. And a lightweight convolution GhostConv is used to replace a convolution Conv in a backbone network in the YOLOv5, the lightweight convolution GhostConv is deployed to a mobile terminal Raspberry Pi and mnn acceleration is carried out, an input rice leaf image is detected, and a detection result is obtained. According to the method, the detection accuracy of the common rice leaf diseases is kept, and meanwhile, the relatively high reasoning speed can be kept on the Raspberry Pi of the mobile terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for quickly and accurately detecting major rice leaf diseases in complex scenarios. Background Art

[0002] Crop leaf diseases are one of the main factors affecting rice growth and rice quality. Rice blast, rice false smut, white panicle, sesame spot, red blight and stem tip nematode are all common diseases of rice in farmland. They often occur in clusters and affect the quality of rice. Therefore, timely detection and identification of rice leaf diseases is the key to improving rice growth and rice quality.

[0003] In the existing research on crop disease detection, Yao Qing et al. proposed an improved RetinaNet model for automatic detection of rice canopy pests. ResNet101 was used as the feature extraction network, and group normalization was used as the normalization method to improve the feature pyramid network structure. Experimental verification showed that the average accuracy of the improved RetinaNet model for detecting two pest-damaged areas reached 93.76%. Li et al. used 8 common image classification networks to classify and identify four rice diseases. ResNet50 network was selected as the feature extraction network, and an enhanced feature fusion and target adaptation network (EFFTAN) was proposed. The final average detection accuracy was 95.3%, and effective detection of dense spot features was achieved.

[0004] These existing methods can achieve high accuracy in crop disease diagnosis, but they fail to consider the computing power of mobile devices in the research, nor simulate or test on mobile devices, making it difficult for the improved models to simultaneously meet the accuracy and real-time requirements of plant leaf disease detection in actual scenarios. Cui et al. proposed to introduce a convolutional block attention module in the autoencoder and use image reconstruction technology to enhance the interpretability of corn leaf disease features. Experimental verification shows that the improved model shows good recognition effect on the Plant Village public corn dataset, but it fails to simulate or test on mobile devices. Li et al. proposed an improved YOLOv5 algorithm based on a shallow feature layer. The algorithm increases the perception field by adding a quadruple downsampling method in the feature pyramid to improve the detection ability of small targets. The experimental results of training on a dataset under complex farmland scenes show that the average detection accuracy of the improved algorithm is improved by 2.4%, which can better overcome field environmental noise and meet the actual requirements of wheat ear detection and counting, but it fails to simulate or test on mobile devices.

[0005] The above existing literature still has limitations in the methods of rice leaf disease detection and identification: (1) They mainly focus on solving the problem of crop leaf disease detection accuracy, without considering the real-time nature of disease detection in practical 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) No simulation or field detection on mobile devices is performed, which is not conducive to dealing with unexpected problems in practical applications. Summary of the invention

[0006] The purpose of the present invention is to solve the problems of low real-time efficiency and low accuracy of detecting major rice leaf diseases using mobile devices in complex scenarios, as well as slow model inference speed, and propose a method for rapid and accurate detection of common rice leaf diseases based on the computing power of mobile devices. The mAP of this method for detecting different types of rice leaf diseases reached 98.3%, and the inference speed reached 1.79FPS on the mobile device Raspberry Pi, which was 73.8% higher than the original, achieving higher accuracy and higher inference speed.

[0007] To solve the above problems, the technical solutions of the present invention are as follows:

[0008] A method for detecting rice leaf disease spots based on the computing power of a mobile device, characterized in that it comprises the following steps:

[0009] (1) Collecting common rice leaf disease spot image samples and performing image preprocessing to obtain a rice leaf disease image sample dataset, wherein the common rice leaf diseases include white panicle, rice blast, rice false smut and sesame spot;

[0010] (2) performing sample data enhancement on the rice leaf disease image sample dataset in step (1), increasing the number of samples and highlighting the sample target features, to obtain a rice leaf disease spot image sample dataset;

[0011] (3) using image annotation software to annotate the rice leaf disease spots in the rice leaf disease spot image sample data set of step (2) with rectangular frames to obtain a final sample data set of rice leaf disease spot images;

[0012] (4) using the final sample data set of the rice leaf disease spot image in step (3) to train a detection model, wherein the detection model is based on the target detection algorithm YOLOv5, introduces a ternary attention mechanism to strengthen the attention feature extraction module in the target detection algorithm YOLOv5, uses the C3CBAM module to replace the C3 module of the backbone network in the target detection algorithm YOLOv5, and uses the lightweight convolution GhostConv to replace the convolution Conv in the target detection algorithm YOLOv5, to obtain the final detection model;

[0013] (5) The final detection model obtained in step (4) is deployed on the mobile Raspberry Pi and MNN acceleration is performed to detect the input rice leaf image and obtain the detection result.

[0014] Furthermore, in the rice leaf disease image sample data set of step (1), the common rice diseases collected include four types: white spike disease (RWE), rice blast (RB), rice false smut (RFS) and sesame spot (BS). After data enhancement of all rice leaf disease samples, the disease spots in the image are annotated with rectangular frames using Labelme image annotation software.

[0015] Furthermore, in the specific method of sample data enhancement, the horizontal flipping is to mirror-transform the image along the horizontal direction;

[0016] The Gaussian blur processing, i.e., convolution of image pixels with Gaussian distribution, comprises the following steps:

[0017] Calculate the weighted average of each pixel and the surrounding 8 pixels. The weight distribution mode adopts the normal distribution, that is, the two-dimensional Gaussian function. The Gaussian formula is as follows:

[0018]

[0019] Among them, x represents the horizontal axis coordinate value of the pixel point in the image coordinate system, and y represents the vertical axis coordinate value of the pixel point in the image coordinate system. Represents the standard deviation of the weight distribution pattern in Gaussian blur processing; Preferably 3.0

[0020] Adding Gaussian noise is to add noise points to the image to interfere with the image. The probability density P(x, y) obeys the normal distribution, that is, the two-dimensional Gaussian function. The Gaussian formula is as follows:

[0021]

[0022] Represents the standard deviation of the probability density in Gaussian noise processing. For each input pixel, the output pixel is obtained by adding a random number that conforms to the Gaussian distribution. This can effectively simulate the noise interference environment encountered when shooting with a mobile device and expand the number of samples in the data set. In the present invention, Preferably 35.0

[0023] The random occlusion, i.e., occluding an indefinite number of square areas of fixed size at random positions of the image and filling the area with a constant value (such as 0) or a random value, can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the number of samples in the data set. The occlusion number setting range of the present invention is 1-5;

[0024] Each sample data augmentation method enhances each sample, mixes it with the original image, and divides it into a training set and a validation set.

[0025] Furthermore, the specific steps of obtaining the final detection model are as follows:

[0026] 1) Select the detection network architecture and choose the target detection algorithm YOLOv5 as the basic model;

[0027] 2) Incorporating a ternary attention mechanism into the initial part of the backbone network to strengthen the network’s feature connection of leaf disease information in the previous layer’s input image in terms of height, width, and channel dimensions; the feature map refers to the output generated after the input image is processed by the previous layer; the feature information refers to rice leaf disease spots;

[0028] 3) In the neck network, the C3CBAM module is used to replace the original C3 module of the basic model, so as to enhance the attention of the neck network to the edge feature information while extracting the feature information of images of different dimensions; the different dimensions refer to the height, width, and channel dimensions;

[0029] 4) Use the lightweight convolution GhostConv module to replace the original ordinary convolution of the basic model 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, C are the height, width, and number of channels of the feature map, respectively, and R indicates that it is mostly a matrix. When passing through the Backbone stage of the YOLOv5 model, the original Conv module is first replaced with a GhostConv lightweight module with a step size of 2, for example, to reduce the number of model parameters. Then, the Triplet Attention module is integrated after the GhostConv layer. The interaction between the input tensor in the spatial dimension and the channel dimension is captured through a three-branch structure and rotation operations, so that the image can be read by the network in a state where complete information is retained in the shallow network stage. Subsequently, the information on the feature map is output to the next layer, and the C3 feature extractor is used to complete the extraction of the feature map information in the channel and spatial dimensions, and the spatial pyramid pooling (SPP) module is used to complete the extraction of local and global feature information of the feature map.

[0032] 2) The tensor information of the feature map obtained after the above operation enters the Head part of the neck network. First, it passes through a convolution layer with a convolution kernel size of, for example, 3×3 and a step size of 1 to extract features. Then the image is upsampled to double the resolution and combined with the feature layer of the same resolution in the Backbone stage in terms of the channel dimension. Finally, the feature information enters different C3CBAM layers for operation and outputs the features. Among them, in the C3CBAM layer, multiple convolution operations in the C3 module will perform preliminary extraction of the newly assembled feature information of the previous layer. The convolution kernel size can be 3×3 with a step size 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 amount of model calculation.

[0033] Furthermore, the final detection model obtained detects the input rice leaf image, and the detection result is jointly evaluated by the parameter quantity, average precision AP, mean detection precision mAP, frame rate CPU-FPS detected on the Raspberry Pi, and detection frame rate MNN-FPS after accelerated reasoning; the parameter quantity is an indicator to measure the complexity of the detection model, the value of AP is the approximation of the area under the precision and recall curve of a certain type of rice lesions, and mAP is obtained by averaging the AP values ​​of various types of rice leaf disease lesions detected, and the calculation formula is N represents the number of types of rice leaf disease spots; CPU-FPS refers to the inference speed used to run the detection model on the Raspberry Pi, and MNN-FPS refers to the inference speed used to accelerate and run the detection model using the Raspberry Pi MNN engine. The higher the value, the faster the inference speed of the detection model.

[0034] When performing target detection on a mobile device, it is necessary to consider the computing power of the device. The present invention uses a lightweight, optimized model and accelerates the engine of the mobile device, so that the model can reduce the demand for computing resources and improve operating efficiency while maintaining a high accuracy rate. In the field detection of rice, there is an actual situation of "complex background", that is, in the target detection task, the visual characteristics of the background are very close to the target itself, which makes the detection task difficult. The present invention performs Gaussian blur processing, adds Gaussian noise and random occlusion processing on the collected images of common rice leaf diseases to highlight the sample target characteristics. Therefore, the present invention can not only realize the above-mentioned application suitable for the computing power of mobile devices, but also can accurately detect rice leaf images under "complex background".

[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 data set includes white spike, rice blast, rice false smut and sesame spot. The data enhancement method is used to expand the number of data set samples and highlight the sample target features. After labeling, the final sample data set of rice leaf disease spot images is obtained. The detection model is trained on the data set. The detection model uses the target detection algorithm YOLOv5 as the basic model, introduces the ternary attention mechanism to strengthen the attention feature extraction module in the target detection algorithm YOLOv5, uses the C3CBAM module to replace the C3 module of the backbone network in the target detection algorithm YOLOv5, and uses the lightweight convolution GhostConv to replace the convolution Conv in the target detection algorithm YOLOv5. Experimental verification is carried out on the validation set in the final sample data set of rice leaf disease spot images. The mAP of the data set detection reaches 98.3%, and the inference speed reaches 1.79FPS on the mobile device Raspberry Pi, which is 73.8% higher than the original, achieving a higher accuracy and a higher inference speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 The present invention is an overall flow chart of the rice leaf disease spot detection method.

[0037] Figure 2-1 These are actual pictures of lesions on four major rice leaf diseases. Figure 2-2 These are the 4 main rice leaf disease spots labeled using Labelme.

[0038] Figure 3 It is a data enhancement diagram of the sample data set of rice leaf disease spot images performed by the present invention, which includes Gaussian blur processing, adding Gaussian noise and random occlusion in order from top to bottom, and Rare white spike (RWE), rice blast (RB), rice false smut (RFS) and sesame spot (BS) in order from left to right.

[0039] Figure 4 This is the structural diagram of the detection model finally obtained by the present invention, which has three modules: input module, backbone network module, neck module and output detection module. In front of the C3 module in the backbone network, the GhostConv lightweight module is used to replace the original ordinary convolution module of YOLOv5 to reduce the complexity of the model and reduce the model size; the Triplet Attention module is introduced before the first GhostConv module to extract the connection of the feature map tensor information in three dimensions: width, height and number of channels; in the neck network, 4 C3CBAM modules are used to replace the original C3 module of YOLOv5, so that the model's detection accuracy of common rice leaf diseases is significantly improved, while maintaining a faster reasoning speed on the mobile Raspberry Pi.

[0040] Figure 5 This is a visualization of the effect of the Triplet Attention and different attention mechanisms on the rice dataset after the ablation test. From left to right, they are SE attention mechanism, CBAM attention mechanism, C3CBAM module and Triplet Attention module, and from top to bottom, they are Rice Head Disease (RWE), Rice Blast (RB), Rice False Smut (RFS) and Sesame Spot (BS).

[0041] Figure 6 It is a structural diagram of the C3CBAM module of the present invention in the final detection model.

[0042] Figure 7 The detection accuracy and loss value of the detection model finally obtained by the present invention are compared with other models for the rice leaf disease spot image sample data set. DETAILED DESCRIPTION

[0043] In order to make the description of the purpose, technical solution, advantages, etc. of the present invention clearer and more accurate, the present invention is further described below in conjunction with embodiments and drawings. It is particularly noted that the exemplary embodiments of the present invention and their descriptions are only used to explain the present invention, but the embodiments of the present invention are not limited thereto:

[0044] The method provided by the present invention is based on the computing power of mobile devices and can quickly and accurately detect common rice leaf diseases in complex scenarios. Model training is performed on a sample data set of rice leaf disease spot images taken in real farmland scenes, and the algorithm is continuously optimized to address problems such as limited inference difficulties due to the limited computing power of mobile devices, to obtain the final detection model.

[0045] In this embodiment, refer to the attached Figure 1 , to detect diseases in a rice leaf disease spot image sample dataset, and the specific implementation process is as follows: first, rice leaf disease spot image samples are collected in a real farmland environment and image preprocessing is performed to obtain a rice leaf disease image sample dataset; then data enhancement and sample annotation are performed on the rice leaf disease image sample dataset to obtain the final sample dataset of rice leaf disease spot images (hereinafter referred to as the dataset); target detection is performed on the dataset, and the YOLOv5 target detection algorithm is used as the basic model, the ternary attention mechanism and the C3CBAM feature fusion module are introduced, and the GhostConv lightweight module is used to replace the ordinary convolution module to obtain the final detection model; the quality of the detection result is jointly evaluated by the mean detection accuracy mAP and the frame rate FPS; mAP is obtained by averaging the AP values ​​of various types of rice leaf disease spots detected. The AP value is an approximation of the area under the precision and recall curves, and the calculation formula is Where N represents the number of rice leaf disease spots; FPS is the rate of capturing or displaying continuous images. The higher the FPS, the faster the model's inference speed. CPU-FPS refers to the inference speed used to run the model on a Raspberry Pi, and MNN-FPS refers to the inference speed detected by a Raspberry Pi and accelerated by the MNN engine. Dataset preprocessing, that is, using the opencv tool to directly cut the redundant parts of the collected rice common leaf disease spot image samples, and unify the image size into 3024×3024 pixels to obtain the rice leaf disease image sample dataset.

[0046] In this embodiment, data enhancement of a rice leaf disease image sample dataset includes: from left to right, white spike disease (RWE), rice blast (RB), rice false smut (RFS) and sesame spot (BS); from top to bottom, the original image, Gaussian blur processing, adding Gaussian noise and random occlusion. These data enhancement methods are completed before training, and the image samples after enhancement processing are expanded to 2108;

[0047] The Gaussian blur processing is to convolve the image with the Gaussian distribution, calculate the weighted average of each pixel and the surrounding 8 pixels, so that the image color transition is soft and the blur effect is achieved. The Gaussian formula is as follows:

[0048]

[0049] Among them, x represents the horizontal axis coordinate value of the pixel point in the image coordinate system, and y represents the vertical axis coordinate value of the pixel point in the image coordinate system. Represents the standard deviation of the weight distribution pattern in Gaussian blur processing;

[0050] Adding Gaussian noise is to add noise points to the image to interfere with the image. The probability density P(x, y) obeys the normal distribution, that is, the two-dimensional Gaussian function. The Gaussian formula is as follows:

[0051]

[0052] Represents the standard deviation of the probability density in Gaussian noise processing. For each input pixel, the output pixel is obtained by adding a random number that conforms to the Gaussian distribution. This can effectively simulate the noise interference environment encountered when shooting with a mobile device and expand the number of samples in the data set.

[0053] The random occlusion, i.e., occluding an indefinite number of square areas of fixed size at random positions in the image and filling the area with a constant value (such as 0) or a random value, can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the number of samples in the data set;

[0054] In this embodiment, each sample data enhancement method is used to enhance each sample, and the samples are mixed with the original images to obtain a rice leaf disease spot image sample dataset, the purpose of which is to better evaluate the performance and generalization ability of the model. Then, the lesions in the rice leaf disease spot image sample dataset are annotated with rectangular frames using Labelme image annotation software, and finally a rice leaf disease image sample dataset containing 2108 images of white spike disease (RWE), rice blast (RB), rice false smut (RFS) and sesame spot (BS) is obtained, and the images are divided into training set and validation set in a ratio of 8:2. Image reference of white spike disease, rice blast, rice false smut and sesame spot Figure 2-1 ; Labelme annotation sample reference Figure 2-2 .

[0055] In this embodiment, refer to Figure 4 There are four modules in total: input module, backbone network module, neck module and output detection module. In front of the C3 module of the backbone network, the GhostConv lightweight module is used to replace the original ordinary convolution module to reduce the complexity and size of the model; the TripletAttention module is introduced before the first GhostConv module to extract the connection of the feature map tensor information in three dimensions: width, height and number of channels; the C3CBAM module is used to replace the original C3 module in the neck network, which significantly improves the detection accuracy of the model for common rice leaf diseases.

[0056] In this embodiment, Figure 5 The visualization effect diagram of Triplet Attention and different attention mechanisms after ablation test on the rice dataset is given. From top to bottom, they are white spike disease (RWE), rice blast (RB), rice false smut (RFS), and sesame spot (BS). From left to right, they are original image, SE attention, CBAM attention, C3CBAM module, and Triplet Attention mechanism. The red bright spots in the figure indicate the areas of interest of the model. It can be seen that the addition of C3CBAM module and Triplet Attention mechanism helps the model focus on the rice leaf disease spot area, which helps with the positioning and regression of the target, thereby improving the detection accuracy of the model.

[0057] In this embodiment, Figure 6The structural 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 divided into two branches and extracted by convolution. Then one of them passes through N Bottleneck modules and is concatenated with the feature map after convolution of the other branch in the channel dimension to obtain feature map B. The parameters of feature map B are then shared as the input of the CBAM module, and pass through the channel attention module and the spatial attention module in turn to output a feature map that emphasizes edge feature information. The C3CBAM module can help the final YOLOv5 detection model to promote the feature fusion of feature map information of different dimensions within the network while only increasing the amount of calculation.

[0058] In this embodiment, Figure 7 The detection accuracy and loss value comparison of the final detection model and other models on the data set are given. The mAPs of other models (YOLOv5, MobileNetV3, ShuffleNetV2, XceptionNet, and the final detection model (named TG_YOLOv5)) for the four rice leaf disease spots are different. It can be seen that the final YOLOv5 detection model has greatly improved the detection accuracy of rice leaf disease spots, and the accuracy is higher than that of YOLOv5, MobilenetV3, ShufflenetV2, and XceptionNet models. This shows that the model can effectively improve the recognition accuracy of the network by incorporating the TripletAttention mechanism and C3CBAM attention module; in terms of 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 is higher than that of the original YOLOv5 for the detection of the four rice leaf disease spots.

[0059] The experimental results show that these improvements are effective in improving the performance of the model. At the same time, Table 1 gives the performance comparison results of different models on the data set. It can be seen from the table that the models with the Triplet module and the C3CBAM module respectively improve the mAP by 0.7% and 0.8% compared with the original YOLOv5 model; the model with the GhostConv module has 10.7% fewer parameters than the original YOLOv5 model. In Table 1, the model column gives the names of the different models improved during the experiment. The experimental process of overall model improvement includes:

[0060] Starting from the basic model YOLOv5, the Triplet Attention mechanism is introduced to improve the feature extraction ability of the model. As a result, the detection mAP is improved by 0.7%, and the parameters are increased by 0.9%; then, in order to solve the problem that the model has low detection effect on edge feature information of different dimensions, the fusion of C3 module and CBAM mechanism is proposed. As a result, the detection mAP is improved by 0.8% compared with YOLOv5, and the number of parameters is increased by 0.7% compared with YOLOv5, but it is reduced by 0.6% compared with directly adding the CBAM mechanism; the GhostConv lightweight module is used in front of the C3 module in the backbone part of the network to replace the original ordinary convolution module, which reduces the number of parameters by 10.7%, reduces the model size, and only slightly reduces the accuracy.

[0061] Table 1 Performance comparison results of different models on four rice leaf disease spot datasets during the improvement process.

[0062]

[0063] In Table 2, the model column gives the performance comparison results of different models on the data set during the experiment. The experimental process of overall model improvement includes:

[0064] YOLOv5, the model after YOLOv5 was inserted into a lightweight network (including MobilenetV3, ShufflenetV2, and XceptionNet), and the TG_YOLOv5 model were verified on the rice data set, and the frame rate was finally tested on the Raspberry Pi. The mAP of the final detection model was improved by 1.2% compared with YOLOv5, and the accuracy was 9.1%, 48.3%, and 4.9% higher than that of MobilenetV3, ShufflenetV2, and XceptionNet, respectively; the number of parameters was reduced by 0.7M compared with YOLOv5; in terms of the inference speed of the model on the Raspberry Pi, the TG_YOLOv5 model was 0.42FPS higher than YOLOv5, and after using the MNN engine to accelerate, it was improved by 0.34FPS. Finally, compared with YOLOv5, the mAP of the TG_YOLOv5 detection model proposed in the present invention was improved by 1.2% to 98.3%, and the FPS was increased from 1.03 to 1.79, maintaining a faster inference speed.

[0065] Table 2 Performance comparison results of different models on four rice leaf disease spot datasets.

[0066]

[0067] The above is only a further embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician who belongs to or is familiar with the technical field can make equivalent substitutions or partial modifications in the concept according to the technical process and method steps of the present invention within the technical scope disclosed by the present invention, and the functions and effects produced by them still do not exceed the information covered by the description and drawings. They are all within the protection scope of the present invention.

Claims

1. A method for detecting rice leaf disease spots based on the computing power of mobile devices, characterized in that: The steps include: (1) Collecting common rice leaf disease spot image samples and performing image preprocessing to obtain a rice leaf disease image sample dataset, wherein the common rice leaf diseases include white panicle, rice blast, rice false smut and sesame spot; (2) performing sample data enhancement on the rice leaf disease image sample dataset in step (1), increasing the number of samples and highlighting the sample target features, to obtain a rice leaf disease spot image sample dataset; (3) using image annotation software to annotate the rice leaf disease spots in the rice leaf disease spot image sample data set of step (2) with rectangular frames to obtain a final sample data set of rice leaf disease spot images; (4) using the final sample data set of the rice leaf disease spot image in step (3) to train a detection model, the detection model is based on the target detection algorithm YOLOv5, introduces a ternary attention mechanism to enhance the attention feature extraction capability in the target detection algorithm YOLOv5, uses the C3CBAM module to replace the C3 module of the neck network in the target detection algorithm YOLOv5, and uses the lightweight convolution GhostConv to replace the convolution Conv in the backbone network in the target detection algorithm YOLOv5, to obtain the final detection model; (5) The final detection model obtained in step (4) is deployed on the mobile Raspberry Pi and MNN acceleration is performed to detect the input rice leaf image and obtain the detection result.

2. The method according to claim 1, characterized in that The specific method of enhancing the sample data in step (2) includes Gaussian blur processing, adding Gaussian noise, and random occlusion: The Gaussian blur processing, i.e., convolution of image pixels with Gaussian distribution, comprises the following steps: Calculate the weighted average of each pixel and the surrounding 8 pixels. The weight distribution mode adopts the normal distribution, that is, the two-dimensional Gaussian function. The Gaussian formula is as follows: Among them, x represents the horizontal axis coordinate value of the pixel point in the image coordinate system, and y represents the vertical axis coordinate value of the pixel point in the image coordinate system. Represents the standard deviation of the weight distribution pattern in Gaussian blur processing; Adding Gaussian noise is to add noise points to the image to interfere with the image. The probability density P(x, y) obeys the normal distribution, that is, the two-dimensional Gaussian function. The Gaussian formula is as follows: Represents the standard deviation of the probability density in Gaussian noise processing. For each input pixel, the output pixel is obtained by adding a random number that conforms to the Gaussian distribution. This can effectively simulate the noise interference environment encountered when shooting with a mobile device and expand the number of samples in the data set. The random occlusion, i.e., occluding an indefinite number of square areas of fixed size at random positions in the image and filling the area with a constant value or a random value, can effectively simulate the object occlusion problem encountered when shooting with a mobile device and expand the number of samples in the data set; Each data enhancement method performs data enhancement on each sample, and the data-enhanced samples are mixed with the rice leaf disease image sample dataset to divide the data into training set and validation set.

3. The method according to claim 1, characterized in that The specific steps of obtaining the detection model are as follows: 1) Select the detection network architecture and choose the target detection algorithm YOLOv5 as the basic model; 2) Introducing a ternary attention mechanism into the initial part of the backbone network of the basic model to strengthen the backbone network's feature connection with the feature information in the feature graph in the dimensions of height, width, and channel; 3) In the neck network, the C3CBAM module is used to replace the original C3 module in the neck network of the basic model, so as to enhance the attention of the neck network to the edge feature information of the feature map while extracting the feature information of images of different dimensions; the different dimensions refer to the height, width, and channel dimensions; 4) Use the lightweight convolution GhostConv to replace the original convolution Conv in the backbone network of the basic model, and train it on the training set to obtain the final detection model.

4. The method according to claim 1, characterized in that The implementation principle of obtaining the detection model is as follows: 1) Given an input feature map tensor Where H, W, and C are 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, the original convolution Conv is first replaced by the GhostConv lightweight convolution to reduce the number of model parameters. Then, the Triplet Attention module is introduced after the GhostConv layer to capture the interaction between the feature information in the spatial dimension and the channel dimension, so that the image can be read by the network in a state of retaining complete information in the shallow network stage. Subsequently, the feature information is input to the next layer, and the feature information is extracted in the channel and spatial dimensions by the C3 feature extractor, and the spatial pyramid pooling module SPP is used to complete the extraction of local and global feature information of the feature map. 2) When the feature map obtained after the above operation enters the neck network, it first undergoes convolution Conv to extract features, and then the image is upsampled to enlarge the resolution of the feature map and combine it with the feature map of the same resolution in the backbone network in the channel dimension, and then outputs the features after passing through the C3CBAM layer of different dimensions; the BatchNorm operation is used to normalize the distribution law of the feature map tensor, and the ReLU function is used as the activation function to reduce the amount of model calculation.

5. 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 image, and the detection result is jointly evaluated by the parameter quantity, average precision AP, mean detection precision mAP, the frame rate CPU-FPS detected on the Raspberry Pi, and the detection frame rate MNN-FPS after accelerated reasoning; the parameter quantity is an indicator to measure the complexity of the detection model, the value of AP is an approximation of the area under the precision and recall curve of a certain type of rice lesions, and mAP is obtained by averaging the AP values ​​of various types of rice leaf disease lesions detected, and the calculation formula is: N represents the number of types of rice leaf disease spots; CPU-FPS refers to the inference speed used to run the detection model on the Raspberry Pi, and MNN-FPS refers to the inference speed used to accelerate and run the detection model using the Raspberry Pi MNN engine. The higher the value, the faster the inference speed of the detection model.

Citation Information

Patent Citations

  • Forest weed detection method based on improved YOLOv5 model

    CN115546639A

  • Improved YOLOv5 lightweight community scene pedestrian detection method

    CN115862066A

  • Rice leaf scab detection method based on deep learning

    CN116012721A

  • 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

Cited By

  • Fruit target detection method based on lightweight multi-scale attention mechanism

    CN120259793A