A method, system, equipment and medium for constructing a leaf disease detection model
By lightweighting the YOLOX-Nano network and combining it with optimization techniques such as asymmetric shuffling blocks, attention mechanisms, and blueprint separable convolutions, an efficient and low-cost leaf disease detection model suitable for apple disease detection was generated. This solves the problem of insufficient model generalization ability in existing technologies and achieves a balance between real-time performance and accuracy.
Patent Information
- Application Number
- CN202410273168.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2044-03-11
AI Technical Summary
Existing apple disease detection models suffer from poor generalization ability, difficulty in balancing real-time performance and accuracy, and issues related to model size, running speed, and power consumption, resulting in low detection efficiency.
A lightweight leaf disease detection model is adopted. The YOLOX-Nano network is lightweighted and optimized by combining asymmetric shuffling blocks, attention mechanism, blueprint separable convolution and CIoU loss function to generate the best detection model.
It improves the model's accuracy and generalization ability, reduces computational costs and power consumption, is suitable for mobile devices with lower computing power, and enhances the real-time performance and accuracy of Apple disease detection.
Smart Images

Figure CN118097418B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics technology, and in particular to a method, system, device and medium for constructing a leaf disease detection model. Background Technology
[0002] The fruit industry is an important branch of national economic development, and apples are in high demand in many countries. Developing modern apple cultivation is key to improving rural economy and agricultural living standards.
[0003] Controlling apple diseases is a routine task in apple cultivation. Improving the efficiency of disease detection is a crucial means to increase productivity and promote industry development. Timely acquisition of information on apple diseases allows for their discovery and effective control, playing a vital role in improving apple quality and reducing economic losses for farmers.
[0004] Traditional methods for identifying apple diseases based on human experience require expert agricultural workers to make judgments, which are not only time-consuming, labor-intensive, and costly, but also suffer from strong subjectivity and susceptibility to interference. Accuracy and stability are difficult to guarantee, and indiscriminate use of pesticides can lead to problems such as affecting apple quality and causing environmental pollution. Furthermore, existing deep learning models still have some issues: poor generalization ability, difficulty in balancing real-time performance and accuracy, and limitations in model size, running speed, and power consumption also pose significant challenges to apple disease detection. Summary of the Invention
[0005] The purpose of this invention is to address the shortcomings of the prior art by providing a method, system, device, and medium for constructing a leaf disease detection model. This addresses the problems in the prior art, such as poor model generalization ability, difficulty in balancing real-time performance and accuracy, and the challenges posed by model size, running speed, and power consumption to apple disease detection.
[0006] This invention specifically provides the following technical solution: a method for constructing a leaf disease detection model, comprising the following steps:
[0007] Collect image data of leaf diseases;
[0008] The YOLOX-Nano-based network model is lightweighted to obtain a lightweight leaf disease detection model, and the image data is used to train the lightweight leaf disease detection model.
[0009] The trained lightweight leaf disease detection model was processed using asymmetric shuffling blocks, attention mechanisms, blueprint separable convolutions, and CIoU loss functions to obtain an optimized leaf disease detection model.
[0010] Deep learning is applied to the optimized leaf disease detection model to generate the best leaf disease detection model.
[0011] The step of using an asymmetric shuffling block to train the lightweight leaf disease detection model includes the following steps:
[0012] In the lightweight leaf disease detection model, channel splitting is used to divide the input image data into two sets of image data layers.
[0013] The second set of image data layers after the channel segmentation operation is passed through an asymmetric bottleneck structure and stitched together with the first set of image layers in the channel dimension.
[0014] By fusing features of the first and second image layers through a shuffling operation, the optimal value of the asymmetric shuffling block expansion factor p is selected, and the optimal image features are selected from the existing image features based on the optimal value of the asymmetric shuffling block expansion factor p.
[0015] Preferably, after collecting image data of leaf diseases, the image data is labeled and augmented, specifically including the following steps:
[0016] The image data is labeled using labelImg, and processed using biomimetic transformation, geometric transformation, and methods to adjust hue, saturation, and brightness to enhance the image scene.
[0017] Among them, biomimetic transformations include flipping, scaling, mirroring, and cropping.
[0018] Preferably, the optimal value of the asymmetric shuffle block expansion factor p is specifically expressed as follows:
[0019] Y=Concat(PW(DW(Concat(2q·X1,F p-q (X1)))), X2)
[0020] Among them, F p-q is the output of the first PW point convolution, p is the expansion factor, q is used to control the asymmetry rate, X1 and X2 correspond to the first 1 / 2 channel and the last 1 / 2 channel of the input feature map, respectively, and DW is the depth decomposition convolution.
[0021] Preferably, when using the attention mechanism on the trained lightweight leaf disease detection model, channel attention and spatial attention of SA are introduced into the two branches of the CSP structure in the lightweight leaf disease detection model, respectively.
[0022] Specifically, the branch introducing SA channel attention weights the features of different channels by squeezing the spatial dimension of the input feature map; the branch introducing SA spatial attention has a bottleneck block, and spatial attention is applied to it to obtain the spatial relationship of the feature map.
[0023] Preferably, when using blueprint separable convolution on the trained lightweight leaf disease detection model, the time-consuming convolution operation is optimized by replacing the depth separable convolution in the lightweight leaf disease detection model with blueprint separable convolution, and extracting feature information of different feature channels in spatial location through pointwise convolution of the blueprint separable convolution.
[0024] Preferably, when using the CIoU loss function on the trained lightweight leaf disease detection model, an experimental comparison is adopted to compare the experimental data under the loss functions IoU, GIoU, DIoU and CIoU respectively, and the optimal loss function is obtained through the comparison results.
[0025] Preferably, when performing deep learning on the optimized leaf disease detection model, the PyTorch deep learning framework is used to perform deep learning on the optimized leaf disease detection model, and an ablation experiment is used to test the optimized leaf disease detection model to obtain the best leaf disease detection model.
[0026] Preferably, the present invention provides a system for constructing a leaf disease detection model, comprising:
[0027] The acquisition module is used to acquire image data of leaf diseases;
[0028] The training module is used to perform lightweight processing on the YOLOX-Nano-based network model to obtain a lightweight leaf disease detection model, and to train the lightweight leaf disease detection model using the image data.
[0029] The model processing module is used to process the trained lightweight leaf disease detection model using asymmetric shuffling blocks, attention mechanisms, blueprint separable convolutions, and CIoU loss functions to obtain an optimized leaf disease detection model.
[0030] The model generation module is used to perform deep learning on the optimized leaf disease detection model to generate the best leaf disease detection model.
[0031] The model processing module is used to apply an asymmetric shuffling block to the trained lightweight leaf disease detection model, and also includes:
[0032] The segmentation module is used to perform channel segmentation operations in the lightweight leaf disease detection model to divide the input image data into two sets of image data layers.
[0033] The stitching module is used to stitch the second set of image data layers after the channel segmentation operation through an asymmetric bottleneck structure and with the first set of image layers in the channel dimension.
[0034] The filtering module is used to fuse features of the first group of image layers and the second group of image layers through a shuffling operation, filter out the optimal value of the asymmetric shuffling block expansion factor p, and filter out the best image features from the existing image features based on the optimal value of the asymmetric shuffling block expansion factor p.
[0035] Preferably, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor performs the steps of the method for constructing a leaf disease detection model.
[0036] Preferably, the present invention provides a storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the method for constructing a leaf disease detection model.
[0037] Compared with the prior art, the present invention has the following significant advantages:
[0038] This invention proposes an asymmetric shuffling block in the new model to segment the model into channels. The two segments are then stitched together and their features are fused to select the optimal image features. This allows for the acquisition of more feature information at a lower cost, improving model accuracy while ensuring network efficiency. Blueprint-separable convolution replaces depthwise separable convolution, leveraging the internal correlation of the convolution kernel to enhance the separation effect of conventional convolution and improve the network's feature extraction capability. Different loss functions were screened, and the optimal loss function for leaf diseases was found, significantly saving time and cost while having the advantages of fewer parameters and less computation, making it suitable for mobile devices with lower computing power. This provides a new approach for disease detection methods in related plants. Attached Figure Description
[0039] Figure 1 This is a flowchart of the method for detecting apple leaf diseases based on deep learning in an embodiment of the present invention;
[0040] Figure 2 The images shown are experimental effect diagrams provided in the embodiments of the present invention; where (a)-(e) are experimental effect diagrams of different disease images respectively. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0042] This invention addresses the shortcomings of existing technologies by proposing a method, system, equipment, and medium for constructing a leaf disease detection model, thus resolving the problems of existing technologies.
[0043] like Figure 1 As shown, embodiments of this application provide a method for constructing a leaf disease detection model, comprising the following steps:
[0044] Step S1: Collect image data of leaf diseases.
[0045] Specifically, in order to obtain images of apple diseases under complex environments, mobile phones were used to take pictures in the apple orchard. That is, offline data collection was carried out by taking pictures with mobile phones at a distance of 25-50 cm from the tree canopy, including apple leaf images under various conditions. These images were then integrated with some high-quality RGB images from the public dataset Plant Pathology 2020–FGVC7 collected online to ensure the maximum acquisition of apple disease features for training.
[0046] The acquired image data is labeled and augmented, specifically as follows:
[0047] All image data were labeled using labelImg. To avoid the impact of class imbalance and insufficient sample size on the model's detection and recognition performance, data augmentation techniques were employed to expand the dataset size. Online data augmentation methods mainly included: using biomimetic transformation methods such as flipping, scaling, mirroring, and cropping; randomly enhancing or weakening the hue, saturation, and brightness channels; and using the Mosaic method for geometric transformations to effectively enrich the image scene and improve the model's generalization ability and robustness.
[0048] Step S2: Lighten the YOLOX-Nano-based network model to obtain a lightweight leaf disease detection model, and train the lightweight leaf disease detection model using image data.
[0049] This invention uses a lightweight network with few model parameters and strong real-time performance to detect diseases on apple leaves. By improving and optimizing the YOLOX-Nano network, it solves the problems of insufficient feature extraction ability and low model accuracy of lightweight networks.
[0050] Step S3: The trained lightweight leaf disease detection model is processed using asymmetric shuffling blocks, attention mechanism, blueprint separable convolution and CIoU loss function to obtain the optimized leaf disease detection model.
[0051] Specifically, the lightweight leaf disease detection model trained using an asymmetric shuffling block is as follows:
[0052] To improve network performance, feature reuse and shuffling operations are performed in the lightweight leaf disease detection model. An asymmetric shuffling block is designed, and the optimal value of the asymmetric shuffling block expansion factor p is selected. The specific expression is:
[0053] Y=Concat(PW(DW(Concat(2q·X1,F p-q (X1)))),X2) (1)
[0054] F in formula (1) p- q is the output of the first PW point convolution, p is the spread factor, q is used to control the asymmetry rate, and X 1和 X2 corresponds to the first and second half channels of the input feature map, respectively, and DW is depthwise decomposition convolution.
[0055] The input features are divided into two groups using a channel splitting operation. The second group of features is then passed through an asymmetric bottleneck structure and concatenated with the first group of features along the channel dimension. Finally, the two groups are fused using a channel shuffling operation.
[0056] Specifically, when using the attention mechanism on the trained lightweight leaf disease detection model, the process is as follows:
[0057] To focus more on disease information during feature learning and improve the model's detection performance, SA attention is introduced into the original CSP module, proposing a CSP-SA module. In the CSP structure of the lightweight leaf disease detection model, SA channel attention and SA spatial attention are introduced into the two branches of the CSP structure, respectively. One branch weights the features of different channels by compressing the spatial dimension of the input feature map, while the other branch, with a bottleneck block, uses spatial attention to obtain the spatial relationships of the feature map, highlighting important feature regions while suppressing unimportant information. Finally, the features from the two branches are concatenated and shuffled to achieve information fusion and exchange.
[0058] In order to improve the computational efficiency of the network, when using blueprint separable convolution on the trained lightweight leaf disease detection model, the time-consuming convolution operation is optimized. The original depth separable convolution of the lightweight leaf disease detection model is replaced with blueprint separable convolution. By using blueprint separable convolution instead of depth separable convolution, the convolutional feature map in blueprint separable convolution can be fully utilized by depth convolution through the previous pointwise convolution, so as to better extract the feature information of different feature channels in spatial location and improve the network's feature extraction ability for apple leaf diseases.
[0059] In the process of using the CIoU loss function on the trained lightweight leaf disease detection model, an experimental comparison was conducted to compare the experimental data under the loss functions IoU, GIoU, DIoU and CIoU respectively, to determine that CIoU is the best loss function and to find the optimal loss function.
[0060] Step S4: Perform deep learning on the optimized leaf disease detection model to generate the best leaf disease detection model.
[0061] When using the PyTorch deep learning framework to perform deep learning on the optimized leaf disease detection model, an ablation experiment was used to verify the effectiveness of the improvement and optimization. The above improvements were tested on the optimized leaf disease detection model to obtain the best leaf disease detection model. By inputting images or videos into the final apple leaf disease detection model, the detection results of apple leaf diseases can be obtained quickly.
[0062] Based on the above methods and statements, the present invention provides a system for constructing a leaf disease detection model, comprising: a data acquisition module, a training module, a model processing module, and a model generation module.
[0063] The system comprises the following modules: an acquisition module for acquiring image data of leaf diseases; a training module for lightweighting the YOLOX-Nano-based network model to obtain a lightweight leaf disease detection model, and training the lightweight leaf disease detection model using the image data; a model processing module for processing the trained lightweight leaf disease detection model using asymmetric shuffling blocks, attention mechanisms, blueprint separable convolutions, and CIoU loss functions to obtain an optimized leaf disease detection model; and a model generation module for performing deep learning on the optimized leaf disease detection model to generate the best leaf disease detection model.
[0064] The model processing module, used for applying asymmetric mixing blocks to the trained lightweight leaf disease detection model, also includes a segmentation module, a splicing module, and a filtering module.
[0065] The segmentation module is used to perform channel segmentation operations in the lightweight leaf disease detection model, dividing the input image data into two sets of image data layers. The stitching module is used to stitch the second set of image data layers after the channel segmentation operation with the first set of image layers in the channel dimension through an asymmetric bottleneck structure. The filtering module is used to perform feature fusion of the first and second set of image layers through a shuffling operation, filter out the optimal value of the asymmetric shuffling block expansion factor p, and filter out the best image features from the existing image features based on the optimal value of the asymmetric shuffling block expansion factor p.
[0066] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor performs the steps of a method for constructing a leaf disease detection model.
[0067] The present invention also provides a storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of a method for constructing a leaf disease detection model.
[0068] The above description, in conjunction with specific preferred embodiments, provides a more detailed explanation of the present invention. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such deductions or substitutions should be considered to fall within the scope of protection of the present invention.
Claims
1. A method for constructing a leaf disease detection model, characterized in that, include: Collect image data of leaf diseases; The YOLOX-Nano-based network model is lightweighted to obtain a lightweight leaf disease detection model, and the image data is used to train the lightweight leaf disease detection model. The trained lightweight leaf disease detection model was processed using asymmetric shuffling blocks, attention mechanisms, blueprint separable convolutions, and CIoU loss functions to obtain an optimized leaf disease detection model. Deep learning is applied to the optimized leaf disease detection model to generate the best leaf disease detection model. The step of using an asymmetric shuffling block to train the lightweight leaf disease detection model includes the following steps: In the lightweight leaf disease detection model, channel splitting is used to divide the input image data into two sets of image data layers. The second set of image data layers after the channel segmentation operation is passed through an asymmetric bottleneck structure and stitched together with the first set of image layers in the channel dimension. By performing feature fusion on the first and second image layers through a shuffling operation, the optimal value of the asymmetric shuffling block expansion factor p is selected, and the optimal image features are selected from the existing image features based on the optimal value of the asymmetric shuffling block expansion factor p. The optimal value of the asymmetric shuffle block expansion factor p is determined by the following expression: ; in, This is the output of the first PW point convolution. For expansion factor, Used to control the asymmetry rate and These correspond to the first half and the last half channels of the input feature map, respectively. DW is a depthwise decomposition convolution. When the attention mechanism is used on the trained lightweight leaf disease detection model, SA channel attention and SA spatial attention are introduced into the two branches of the CSP structure in the lightweight leaf disease detection model, respectively. Specifically, the branch introducing SA channel attention weights the features of different channels by squeezing the spatial dimension of the input feature map; the branch introducing SA spatial attention has a bottleneck block, and spatial attention is applied to it to obtain the spatial relationship of the feature map. When using blueprint separable convolution on the trained lightweight leaf disease detection model, the time-consuming convolution operation is optimized. The depth separable convolution in the lightweight leaf disease detection model is replaced with blueprint separable convolution. The feature information of different feature channels in spatial location is extracted through pointwise convolution of the blueprint separable convolution.
2. The method for constructing a leaf disease detection model as described in claim 1, characterized in that, After collecting image data of leaf diseases, the image data is labeled and augmented, specifically including the following steps: The image data is labeled using labelImg, and processed using biomimetic transformation, geometric transformation, and methods to adjust hue, saturation, and brightness to enhance the image scene. Among them, biomimetic transformations include flipping, scaling, mirroring, and cropping.
3. The method for constructing a leaf disease detection model as described in claim 1, characterized in that, When using the CIoU loss function on the trained lightweight leaf disease detection model, an experimental comparison was conducted to compare the experimental data under the loss functions IoU, GIoU, DIoU, and CIoU respectively, and the optimal loss function was obtained through the comparison results.
4. The method for constructing a leaf disease detection model as described in claim 1, characterized in that, When performing deep learning on the optimized leaf disease detection model, the PyTorch deep learning framework is used to perform deep learning on the optimized leaf disease detection model, and an ablation experiment is used to test the optimized leaf disease detection model to obtain the best leaf disease detection model.
5. A system for constructing a leaf disease detection model as described in any one of claims 1-4, characterized in that, include: The acquisition module is used to acquire image data of leaf diseases; The training module is used to perform lightweight processing on the YOLOX-Nano-based network model to obtain a lightweight leaf disease detection model, and to train the lightweight leaf disease detection model using the image data. The model processing module is used to process the trained lightweight leaf disease detection model using asymmetric shuffling blocks, attention mechanisms, blueprint separable convolutions, and CIoU loss functions to obtain an optimized leaf disease detection model. The model generation module is used to perform deep learning on the optimized leaf disease detection model to generate the best leaf disease detection model. The model processing module includes: The segmentation module is used to perform channel segmentation operations in the lightweight leaf disease detection model to divide the input image data into two sets of image data layers. The stitching module is used to stitch the second set of image data layers after the channel segmentation operation through an asymmetric bottleneck structure and with the first set of image layers in the channel dimension. The filtering module is used to fuse features of the first group of image layers and the second group of image layers through a shuffling operation, filter out the optimal value of the asymmetric shuffling block expansion factor p, and filter out the best image features from the existing image features based on the optimal value of the asymmetric shuffling block expansion factor p.
6. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores a program that, when executed by the processor, causes the processor to perform the steps of the method for constructing a leaf disease detection model as described in any one of claims 1 to 4.
7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for constructing a leaf disease detection model according to any one of claims 1 to 4.
Citation Information
Patent Citations
Apple leaf disease detection method based on improved YOLOv4
CN115240186A
