Leaf disease detection method and device and storage medium
By introducing SimAM parameterless attention mechanism and PConv convolution in apple leaf disease detection, the backbone and neck network of the YOLOv7 model was optimized, and the problems of low efficiency and insufficient accuracy of apple leaf disease detection were solved, and high precision and Efficient disease detection.
Patent Information
- Application Number
- CN202411220775.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-01-03
AI Technical Summary
The existing apple leaf disease detection methods are inefficient and are easily affected by subjective factors. YOLOv7 lacks the accuracy of detection of small objects in complex environments, and has a lower sensitivity to complete crossover than loss function, resulting in frequent error detection and missed detection.
Introducing SimAM parametric attention mechanism and PConv convolution to improve the initial leaf disease detection model, optimize the backbone network and neck network, and use lightweight expansion of local attention network layer and SPPCSPC-parametric attention mechanism structure to improve Feature extraction accuracy and detection capability reduce the calculation amount.
It significantly improves the accuracy and efficiency of apple leaf disease detection, enhances detection capabilities in complex backgrounds, and ensures the reliability and high accuracy of the detection results.
Smart Images

Figure CN119251154A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of target detection technology, and in particular to a leaf disease detection method, device and storage medium. Background Art
[0002] With the development of intelligent agricultural production around the world, disease detection in apple planting has become an important part of improving yield and quality. Apple leaf diseases have a significant impact on the growth and yield of fruit trees. Timely and accurate detection and identification of these diseases can help farmers take effective prevention and control measures. However, traditional disease detection methods often rely on manual observation, which is not only inefficient but also easily affected by subjective factors. Therefore, researching and developing an automated and intelligent method for detecting apple leaf diseases has become a key need in agricultural technology.
[0003] At present, deep learning-based target detection technologies, such as the YOLO (You Only Look Once) series of models, have been widely used in target recognition tasks in many complex scenarios. YOLOv7 is an improved version of the YOLO model. Its network structure includes an input layer, a backbone network, a neck network, and a multi-scale detection head layer. Through the combination of these layers, it can process and recognize targets in complex backgrounds. However, as a small target detection task, apple leaf disease has problems such as little feature information, high positioning accuracy requirements, and complex changes in the surrounding environment, which puts forward higher requirements on the detection accuracy of YOLOv7.
[0004] Although YOLOv7 has shown certain advantages in handling target detection tasks, its detection accuracy is still insufficient in complex natural environments, especially for small target detection such as apple leaves. YOLOv7's original complete intersection over union (CIOU) loss function has low sensitivity in small target detection and is prone to false detection and missed detection. In addition, complex natural backgrounds can also interfere with the extraction of disease features and affect the reliability of detection results. Therefore, how to accurately detect apple leaf diseases has become an urgent problem to be solved.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The purpose of this application is to provide a leaf disease detection method, device and storage medium, aiming to solve the technical problem of how to accurately detect apple leaf diseases.
[0007] To achieve the above objectives, the present application proposes a leaf disease detection method, the method comprising:
[0008] Acquire the image to be detected;
[0009] Inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model;
[0010] Leaf disease information is output according to the detection result.
[0011] In one embodiment, the initial leaf disease detection model includes an initial backbone network and an initial neck network, the initial backbone network includes an extended local attention network layer, the initial neck network includes an SPPCSPC structure, and the target leaf disease detection model includes a backbone network and a neck network;
[0012] The backbone network is obtained by improving the initial backbone network using a lightweight extended local attention network layer and a lightweight hybrid attention mechanism network layer;
[0013] The neck network is obtained by improving the initial neck network using the SPPCSPC-parameter-free attention mechanism structure;
[0014] The lightweight extended local attention network layer, the lightweight hybrid attention mechanism network layer and the SPPCSPC-parameter-free attention mechanism structure are obtained by improving the extended local attention network layer and the SPPCSPC structure based on the PConv convolution and the SimAM parameter-free attention mechanism.
[0015] In one embodiment, the lightweight extended local attention network layer is obtained by replacing the convolution block structure in the extended local attention network layer with the PConv convolution;
[0016] The lightweight hybrid attention mechanism network layer is obtained by introducing the SimAM parameter-free attention mechanism into the lightweight extended local attention network layer;
[0017] The SPPCSPC-parameter-free attention mechanism structure is obtained by introducing the SimAM parameter-free attention mechanism into the SPPCSPC structure.
[0018] In one embodiment, the step of inputting the image to be detected into the target leaf disease detection model to obtain the detection result includes:
[0019] The target leaf disease detection model is used to adjust the image to be detected to a preset size to obtain the target image to be detected;
[0020] Extracting features of the target image to be detected by using the target leaf disease detection model to obtain a multi-scale feature map;
[0021] Performing feature mapping, upsampling, downsampling, and horizontal connection on the multi-scale feature map through the target leaf disease detection model to obtain a fused feature map;
[0022] The fused feature map is decoded and classified by the target leaf disease detection model to obtain a detection result including the location and category information of the leaf disease.
[0023] In one embodiment, before the step of inputting the image to be detected into the target leaf disease detection model to obtain the detection result, the step further includes:
[0024] Acquire a target leaf data set, and divide the target leaf data set into a training set and a test set;
[0025] The training set and the test set are used to train and test the initial leaf disease detection model to obtain a target leaf disease detection model.
[0026] In one embodiment, the step of training and testing the initial leaf disease detection model using the training set and the test set to obtain a target leaf disease detection model comprises:
[0027] Using the training set to train the initial leaf disease detection model to obtain a reference detection model;
[0028] Using the test set to test the reference detection model, to obtain a test result;
[0029] When the test result does not meet the preset requirements, return to the step of using the training set to train the reference detection model until the test result meets the preset requirements to obtain a target leaf disease detection model.
[0030] In one embodiment, the loss function in the initial leaf disease detection model includes complete intersection-over-union loss, category loss, and confidence loss, and the step of using the training set to train the initial leaf disease detection model to obtain a reference detection model includes:
[0031] Introducing the mean distance prior intersection-over-union loss to replace the complete intersection-over-union loss;
[0032] Obtaining a total loss according to the mean distance prior intersection-over-union loss, the confidence loss, and the category loss;
[0033] The initial leaf disease detection model is trained using the training set until the total loss is lower than a preset loss value, thereby obtaining a reference detection model.
[0034] In one embodiment, the step of obtaining the target leaf data set includes:
[0035] Obtain an initial leaf data set;
[0036] Rotating, adjusting brightness, adjusting contrast, and cropping the images in the initial leaf data set to obtain an enhanced data set;
[0037] The enhanced data set is labeled and classified to obtain a target leaf data set.
[0038] In addition, to achieve the above objectives, the present application also proposes a leaf disease detection device, the device comprising:
[0039] An image acquisition module, used for acquiring an image to be detected;
[0040] A detection module, used for inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model;
[0041] The result output module outputs leaf disease information according to the detection result.
[0042] In addition, to achieve the above-mentioned purpose, the present application also proposes a leaf disease detection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the leaf disease detection method as described above.
[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the leaf disease detection method described above are implemented.
[0044] One or more technical solutions proposed in this application have at least the following technical effects:
[0045] The method comprises the steps of obtaining an image to be detected; inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing the SimAM non-parameter attention mechanism and PConv convolution to improve the initial leaf disease detection model; and outputting leaf disease information according to the detection result. First, the apple leaf images to be detected are obtained through a camera device or from a database or a network. Then, the images to be detected are input into the target leaf disease detection model. The model is optimized to first adjust the images to a preset size to ensure a consistent input size. Subsequently, the model performs feature extraction and feature mapping, and generates a fused feature map through upsampling, downsampling and lateral connection. Finally, the detection result of the disease is obtained through decoding and classification, and the location and category information of the leaf disease is obtained according to the detection result. Since the model introduces the SimAM non-parameter attention mechanism and PConv convolution, the accuracy of feature extraction and the detection capability of small target diseases are significantly enhanced, while the amount of calculation is reduced and the detection efficiency is improved. These improvements enable the model to maintain high accuracy even in complex backgrounds, thereby enabling accurate detection of apple leaf diseases and effectively improving the reliability of leaf disease detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the leaf disease detection method of the present application;
[0049] Figure 2 A schematic diagram of the SimAM attention mechanism provided for the first embodiment of the leaf disease detection method of the present application;
[0050] Figure 3 A schematic diagram of the PConv convolution structure provided in Example 1 of the leaf disease detection method of this application;
[0051] Figure 4 A schematic diagram of the structure of a target leaf disease detection model provided in Example 1 of the leaf disease detection method of the present application;
[0052] Figure 5 A schematic diagram of the process provided for the second embodiment of the leaf disease detection method of the present application;
[0053] Figure 6 This is a schematic diagram of the module structure of the leaf disease detection device according to an embodiment of the present application;
[0054] Figure 7 Schematic diagram of the equipment structure of the hardware operating environment involved in the leaf disease detection method in the embodiment of the present application.
[0055] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0056] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0057] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0058] With the development of intelligent agricultural production, automated and intelligent apple leaf disease detection has become particularly important to improve yield and quality. Although the YOLO series of models based on deep learning have made progress in target detection, YOLOv7 still faces challenges in detecting small targets such as apple leaf diseases because it has insufficient detection accuracy for small targets in complex environments, the original CIOU loss function is not sensitive enough to small targets, and the complexity of the natural background may interfere with the extraction of disease features, resulting in false detection and missed detection.
[0059] The main solution of the embodiment of the present application is: first obtain the apple leaf image to be detected and input it into the optimized target leaf disease detection model, which adjusts the image size and performs feature extraction, mapping and fusion, and finally generates disease detection results through decoding and classification. By introducing the SimAM parameter-free attention mechanism and PConv convolution, the model improves the feature extraction accuracy and detection capability while reducing the amount of calculation, ensuring accurate detection of apple leaf diseases in complex backgrounds and the reliability of detection results.
[0060] It should be noted that the execution subject of the embodiment of the present application may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a leaf disease detection device, etc. The following takes the leaf disease detection device as an example to illustrate this embodiment and the following embodiments.
[0061] Based on this, the present application embodiment provides a leaf disease detection method, referring to Figure 1 , Figure 1 This is a schematic diagram of the flow chart of the first embodiment of the leaf disease detection method of the present application.
[0062] In this embodiment, the leaf disease detection method includes steps S10 to S30:
[0063] Step S10, obtaining an image to be detected;
[0064] It should be noted that the images to be tested are those taken by cameras in actual application scenarios, including images of apple tree leaves under different lighting, angles, and background conditions. Unlike the dataset used for training, the images to be tested are unknown, unlabeled images in actual environments. By testing these images, possible leaf diseases such as brown spot, gray spot, mosaic, rust, and leaf spot can be identified.
[0065] It is understandable that, firstly, the leaf images can be directly taken in the apple planting area using a camera, a mobile phone or a drone. This method can obtain the latest image data in a real environment. Secondly, the relevant apple leaf images can be downloaded from the Internet. These images may come from agricultural research institutions, open image libraries or professional photography websites. In addition, the images to be detected can be obtained from existing image databases. These databases usually contain collected and organized apple leaf images, which can be used to test and verify the performance of the model. Through these channels, the images obtained will be used for analysis and processing of the disease detection model.
[0066] Step S20, inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model;
[0067] The target leaf disease detection model is a model that is optimized and improved by further introducing the SimAM parameter-free attention mechanism and PConv convolutional layer on the basis of the initial YOLOv7 model. This model is specifically used to detect diseases on apple leaves. It has higher detection accuracy and robustness, and can identify small diseases on leaves in complex natural environments. The detection result refers to the result of the model identifying and outputting the apple leaf disease in the image after the image to be detected is input into the target leaf disease detection model. This includes information such as the location, type, and possible severity of the disease, which is a quantitative or qualitative analysis of the leaf disease in the image.
[0068] The SimAM parameter-free attention mechanism is an attention module based on neuroscience theory. It does not rely on additional parameters and evaluates the importance of neurons by calculating their energy functions. It is introduced into the leaf disease detection model to enhance the model's attention to diseases on apple leaves, thereby improving feature extraction capabilities and detection accuracy in complex backgrounds. Inspired by neuroscience theory, SimAM believes that a more active neuron may inhibit the expression of surrounding neurons. In order to better distinguish target neurons from other neurons, the SimAM attention mechanism uses a defined energy function to evaluate the importance of a single neuron. The calculation process of the energy function is as follows:
[0069]
[0070] Where M is the size of the input feature map, t is the target neuron, and Represent the mean and variance of each channel respectively, λ is the weight parameter or adjustment coefficient, which is used to balance the contribution between different items or adjust the influence of a variable in the formula, and E is the energy function of a single channel. The smaller the energy, the greater the importance of the neuron. After inferring the importance of each neuron, the Sigmoid function is used for feature refinement, where X is the input feature, For the output features, the final SimAM calculation formula is as follows:
[0071]
[0072] Please refer to Figure 2 , Figure 2The schematic diagram of the SimAM attention mechanism provided for the first embodiment of the leaf disease detection method of the present application shows the structure and calculation process of the SimAM (Simple Attention Module) parameterless attention mechanism. First, the input feature map X (the cube on the left) enters the attention mechanism, and the weighted feature map (the bars in the middle part) is generated by three-dimensional weight calculation in the "Generation" step. These bars represent the features adjusted by attention in different dimensions. Next, the "Fusion" step fuses these three-dimensional weighted features with the original feature map to generate a new feature map. In the "Expansion" step, the fused feature map is expanded to include more channels (C), height (H) and width (W), and the next step is processed with higher dimensional information. Finally, the whole process enhances the model's attention to key features by adjusting the weight and fusion of each feature. In the figure, X represents the input feature map, which contains the preliminary feature information extracted from the image. These feature maps provide basic data for the SimAM attention mechanism for calculating and adjusting the importance of features. H represents the attention feature map obtained by calculation. This step generates a weighted importance feature map by applying the SimAM mechanism to the input feature map X to enhance the focus on key features. Fusion represents the feature fusion operation, which combines the feature map H adjusted by the attention mechanism with the input feature map X. This fusion operation integrates the original features and weighted features, allowing the model to better utilize the enhanced feature information for further processing and decision-making. The Energy Function is used to calculate the importance of each neuron, which is usually calculated by statistics such as mean and variance. The SimAM mechanism evaluates the contribution of each neuron in the input feature map through this energy function, and neurons with higher importance are given greater weights. Sigmoid Activation is used to normalize the output value of the energy function to between 0 and 1 to represent the weight of each feature. This normalization process helps the model effectively adjust and enhance the focus on important features.
[0073] PConv convolution (Partial Convolution) is an improved convolution layer design that aims to reduce the amount of network computation and memory access times. Unlike standard convolution, PConv only performs convolution operations on some input channels, while keeping other channels unchanged, thereby achieving lightweight models and improving detection efficiency while maintaining high accuracy. A new type of convolution called PConv is used to replace some CBS 3*3 standard convolutions in the backbone network, which can reduce the amount of floating-point operations and memory access times. PConv only applies filters to some input channels for feature extraction, and keeps the remaining channels unchanged. When the original Conv convolution performs feature extraction on c input channels, the number of floating-point operations per second (FLOPS) is h×w×k 2 ×c 2 , while PConv in c p The FLOPS of operations on the channels is h×w×k 2 ×c p 2 Assume that the input channel c p If the number of channels is 1 / 4 of the original channel c, the FLOPS of PConv is only 1 / 16 of that of the conventional Conv convolution. At the same time, the number of memory accesses is reduced to 1 / 4 of that of the conventional convolution, effectively achieving the lightweight model.
[0074] Please refer to Figure 3 , Figure 3 The PConv convolution structure diagram provided in the first embodiment of the leaf disease detection method of the present application shows the schematic diagram of the PConv (Partial Convolution) convolution structure. In the figure, the rectangular block on the left represents the input feature map, which has a height h, a width W and a number of channels C. p In the convolution operation, the input feature map (Input) is passed through a layer containing C p The convolution kernel k×k of the filter is partially convolved, and the result will generate a new feature map, maintaining the original height h and width W, but still with the same number of channels C p In this structure, the output after convolution retains the number of channels of the input feature. Through the "Identity" path, part of the information of the input feature map is directly passed to the output, thereby retaining more original feature information in the final output. This structure helps to better utilize the input features, especially in partial convolution operations, more important information can be retained.
[0075] The initial leaf disease detection model refers to the unmodified YOLOv7 model. YOLOv7 is a target detection framework that can achieve efficient target detection in complex scenarios through the input layer, backbone network, neck network and multi-scale detection head layer. Although YOLOv7 has good detection performance, it still has the problem of insufficient accuracy when detecting small diseases on apple leaves. Therefore, it is necessary to improve its detection ability by introducing improvements such as SimAM and PConv. The network structure of YOLOv7 includes the following parts: 1) Input layer: preprocess the input image. 2) Backbone network: consists of multiple convolutional layers to extract image features. YOLOv7 uses an improved convolutional block structure to handle feature extraction tasks. 3) Neck network: includes feature fusion layers (such as SPPCSPC) to combine features from different scales to improve detection accuracy. 4) Detection Head: generates prediction boxes and category labels based on the previously extracted and fused features.
[0076] It is understandable that, first, the acquired image to be detected is imported into the improved target leaf disease detection model. This model is optimized on the basis of the initial YOLOv7 model, and the SimAM parameter-free attention mechanism is introduced to enhance the focus on leaf disease characteristics. At the same time, PConv convolution is used to reduce computational complexity and improve detection efficiency. After receiving the image, the model will automatically extract the feature information, analyze and identify the possible diseases on the leaves. Finally, the model outputs the detection results, including the specific location, type, and possible disease area or severity of the disease, providing a basis for subsequent prevention and control measures.
[0077] As an example, the initial leaf disease detection model includes an initial backbone network and an initial neck network, the initial backbone network includes an extended local attention network layer, the initial neck network includes an SPPCSPC structure, and the target leaf disease detection model includes a backbone network and a neck network; the backbone network is obtained by improving the initial backbone network using a lightweight extended local attention network layer and a lightweight hybrid attention mechanism network layer; the neck network is obtained by improving the initial neck network using an SPPCSPC-parameter-free attention mechanism structure; the lightweight extended local attention network layer, the lightweight hybrid attention mechanism network layer and the SPPCSPC-parameter-free attention mechanism structure are obtained by improving the extended local attention network layer and the SPPCSPC structure according to the PConv convolution and the SimAM parameter-free attention mechanism.
[0078] The initial backbone network is a key part of the YOLOv7 model, which is used to extract basic features from the input image. It consists of multiple convolutional layers and other processing units, which are responsible for the initial extraction of important information from the image, which is then passed to subsequent network layers for more in-depth processing. The initial neck network is another part of the YOLOv7 model, which is mainly responsible for fusing and further processing the features extracted by the backbone network. The neck network helps the model to more accurately identify objects in the image by integrating feature information from different scales. The extended local attention network layer is a specific structure in the initial backbone network that is used to enhance the network's attention ability when processing local areas of the image. This attention mechanism helps the model better focus on important local areas in the image, especially when dealing with complex backgrounds or small objects, improving the accuracy of feature extraction. The SPPCSPC (Spatial Pyramid Pooling+Concat with SpatialPyramid Convolution) structure is a component of the initial neck network. It combines spatial pyramid pooling and spatial pyramid convolution operations to fuse features from different scales, thereby enhancing the performance of the model when dealing with multi-scale objects. The backbone network is an improved version of the initial backbone network. By introducing the lightweight extended local attention network layer and the lightweight hybrid attention mechanism network layer, the improved backbone network maintains the computational efficiency of the model while enhancing the ability of feature extraction, especially in small target detection. The neck network is an improved version of the initial neck network. It uses the SPPCSPC-parameter-free attention mechanism structure to enhance the initial network, thereby improving the accuracy of feature fusion and the overall detection ability of the model. The lightweight extended local attention network layer is an optimized version of the extended local attention network layer. It reduces the complexity of the model by reducing the amount of calculation and the number of parameters, while still retaining a strong local feature extraction ability, which helps to improve detection efficiency under limited resources. The lightweight hybrid attention mechanism network layer is a network layer designed by combining multiple attention mechanisms to further enhance the model's ability to focus on key features in the image. This layer is designed to improve the detection accuracy of the model in complex scenes while keeping the calculation lightweight. The SPPCSPC-parameter-free attention mechanism structure is an improved version of the initial SPPCSPC structure. By introducing the SimAM parameter-free attention mechanism, the feature fusion capability is further enhanced, especially when dealing with complex backgrounds and small targets, enabling the model to more accurately identify and classify targets.
[0079] First, the initial leaf disease detection model consists of a backbone network and a neck network. The backbone network contains an extended local attention network layer, which is responsible for extracting preliminary features from the image; the neck network contains an SPPCSPC structure, which is used to fuse multi-scale features. In order to improve the accuracy and efficiency of the model in detecting apple leaf diseases, the target leaf disease detection model optimizes and improves these initial structures. Specifically, the backbone network is optimized to use a lightweight extended local attention network layer. This improvement is based on PConv convolution and SimAM parameterless attention mechanism, which reduces the computational complexity of the model and enhances the ability to extract local features. In addition, the backbone network also introduces a lightweight hybrid attention mechanism network layer to further improve the model's attention to key features. The neck network is improved through the SPPCSPC-parameterless attention mechanism structure, which is also based on PConv convolution and SimAM parameterless attention mechanism, making feature fusion more accurate, and ultimately improving the model's disease detection performance in complex natural environments.
[0080] As an example, the lightweight extended local attention network layer is obtained by replacing the convolution block structure in the extended local attention network layer with the PConv convolution; the lightweight hybrid attention mechanism network layer is obtained by introducing the SimAM parameter-free attention mechanism into the lightweight extended local attention network layer; the SPPCSPC-parameter-free attention mechanism structure is obtained by introducing the SimAM parameter-free attention mechanism into the SPPCSPC structure.
[0081] YOLOv7 is an object detection model, a version of the YOLO series, whose core architecture is based on convolutional neural networks (CNNs). The convolutional block structure refers to a basic building block in CNNs, which usually includes one or more convolutional layers, as well as possible activation functions (such as ReLU), batch normalization, and pooling layers. The convolutional block structure is responsible for performing convolution operations on the input feature map to extract feature information from the image. By stacking multiple convolutional block structures, the model is able to gradually extract low-level to high-level features from the image.
[0082] First, the convolution block structure in the original extended local attention network layer is replaced with PConv convolution. PConv convolution reduces the amount of calculation and memory usage by performing convolution operations on some channels, thereby achieving lightweight and efficient network. Then, the SimAM non-parameter attention mechanism is introduced in this lightweight extended local attention network layer. The SimAM mechanism enhances the network's attention to important features by evaluating the energy of each neuron in the feature map, thereby improving the ability of feature extraction. Finally, the convolution operation in the SPPCSPC structure is also improved, and the SimAM non-parameter attention mechanism is added to form the SPPCSPC-non-parameter attention mechanism structure. This structure optimizes the feature fusion process, allowing the model to more accurately integrate feature information from different scales, thereby significantly improving the accuracy and effect of target detection.
[0083] Please refer to Figure 4 , Figure 4The schematic diagram of the target leaf disease detection model structure provided in the first embodiment of the leaf disease detection method of the present application is divided into three main parts: Backbone, Neck and Head. Each part contains multiple modules and operations. The following is a detailed explanation of each structure and element in the figure: 1) Backbone: Input: The size of the image input is 640×640×3, representing the width, height and number of channels (RGB) of the input image. CBS: represents the operation module of the combination of convolutional layer, batch normalization, and SiLU activation function. This combination can enhance the effect of feature extraction and accelerate the convergence of the model. SP-ELAN: It is composed of multiple CBS modules, PConv modules (Partial Convolution) and SimAM attention mechanism, which are used to process the features of the input image and perform multi-scale feature extraction. ELAN-PConv: It is composed of multiple CBS modules and PConv modules, and further extracts and aggregates feature information through partial convolution. MP (MaxPooling): Maximum pooling operation, used to reduce the spatial dimension of the feature map while retaining the most important features. This helps reduce computational complexity and improve the robustness of the model to features. 2) Neck: SPPCSPC-SimAM: Consists of multiple CBS modules, a maximum pooling (MaxPool) module, feature fusion (cat), and SimAM attention mechanism, used to further process features from the Backbone part. The SPPCSPC module enhances the model's adaptability to complex scenes by fusing feature information at different scales. ELAN-W: Consists of multi-level feature fusion (cat) operations and upsampling (UPSample) operations, combining multi-scale feature information to enhance the recognition of objects of different sizes. UPSample: Upsampling operation, used to increase the resolution of feature maps. Combined with the low-resolution feature map after downsampling (MP), the model is able to identify diseases at multiple scales. MP-2: A maximum pooling operation similar to MP, but a different pooling strategy (such as a larger kernel size) is used here to further reduce the spatial dimension of the feature map. cat: Feature connection operation, which concatenates feature maps from different modules along the channel dimension to enhance the diversity and expression of features. 3) Head: REP: RepVGG module, a convolutional neural network module optimized for inference efficiency, improves the inference speed and performance of the model by rearranging convolutional layers and activation functions. Conv: Convolutional layer, used to generate the final output feature map.Usually in disease detection, the convolution layer will output a set of feature maps for prediction, representing the probability distribution of different categories of diseases. Output: The output feature map represents the detection result of the target leaf disease, which may include location coordinates, category, and confidence information. 4) Structural details within the module: SP-ELAN module: It includes multiple layers of CBS, PConv, and SimAM modules, combined with multiple feature connection operations (cat). The SimAM attention mechanism adaptively adjusts the weights of each feature map to increase the focus on important features. ELAN-PConv module: It consists of multiple CBS and PConv, focusing on the use of partial convolution, which can ignore invalid information during feature extraction and focus on important parts of the leaf. SPPCSPC-SimAM module: It includes multiple layers of CBS, maximum pooling, and SimAM modules, combined with feature connection operations to further enhance the model's ability to recognize complex features. Through layer-by-layer feature extraction and fusion, the model can effectively process multi-scale leaf disease features in the input image and ultimately output accurate disease detection results.
[0084] As an example, the image to be detected is input into a target leaf disease detection model, and the step of obtaining a detection result includes: adjusting the image to be detected to a preset size through the target leaf disease detection model to obtain a target image to be detected; performing feature extraction on the target image to be detected through the target leaf disease detection model to obtain a multi-scale feature map; performing feature mapping, upsampling, downsampling and horizontal connection on the multi-scale feature map through the target leaf disease detection model to obtain a fused feature map; decoding and classifying the fused feature map through the target leaf disease detection model to obtain a detection result including the location and category information of the leaf disease.
[0085] The preset size refers to the fixed size to which the image to be detected is adjusted for uniform processing and analysis in the target leaf disease detection model. This is usually a standardized resolution (such as 416x416 pixels) to ensure that the image has a consistent size when it is input to the model, so as to adapt to the model's input requirements and optimize computational efficiency. Feature extraction refers to the extraction of important information or features that can represent the image content from the image through the model's convolutional layer. For leaf disease detection, these features may include information such as leaf shape, color change, and texture, which are then used to identify and locate the disease. Multi-scale feature maps refer to the features extracted from images of different scales (resolutions) by the model during the feature extraction process. These feature maps contain a variety of features from low-level to high-level, from small details to global information, which helps to identify diseases at different scales. Feature mapping refers to the conversion of extracted features from one representation to another for better subsequent processing. Upsampling and downsampling refer to increasing or decreasing the resolution of feature maps to match feature maps of different scales. Horizontal connection is to fuse feature maps from different network layers at the same scale to integrate multi-level feature information. The fused feature map is a feature map formed by integrating multi-scale feature maps through upsampling, downsampling and horizontal connection. It contains feature information of multiple scales and levels, which can more comprehensively represent the image content and provide a rich information basis for disease detection. Decoding refers to converting the information in the fused feature map back to specific image content or target detection results through back propagation and other technologies. This step decodes the information in the feature map into specific prediction boxes and disease categories. Classification refers to the model classifying the area in the image into specific disease categories based on the extracted features. For leaf disease detection, this step will output the specific category of the disease on the leaves in the image, such as brown spot disease, rust spot disease, etc. The location of the leaf disease refers to the specific location of the disease on the leaf determined by the model through detection. It is usually represented by one or more bounding boxes. These bounding boxes mark the exact location of the disease in the image to help identify the affected area. Category information refers to the specific type or name of the disease identified by the model in the classification step, such as brown spot disease, gray spot disease, mosaic disease, etc. This information is used to determine the specific type of disease on the leaf and help to carry out targeted prevention and control measures.
[0086] First, the image to be detected is input into the target leaf disease detection model. The model will adjust the image to the preset standard size to ensure that the image input size is consistent, so as to obtain a uniformly processed target image to be detected. Next, the model extracts features from the target image and generates multi-scale feature maps, which contain image information at different resolutions. Then, the model performs feature mapping on these multi-scale feature maps, adjusts the resolution of the feature maps by upsampling and downsampling, and combines lateral connections to integrate feature maps from different scales into fused feature maps. Next, the model decodes the fused feature maps, parses out specific disease information, and classifies it to finally obtain the detection results. The detection results contain the specific location of the leaf disease in the image, as well as the category information of the disease, thus providing a basis for subsequent disease management and prevention.
[0087] Step S30: output leaf disease information according to the detection result.
[0088] It should be noted that leaf disease information refers to the detailed information about apple leaf diseases provided by the model based on the test results, including: 1) Disease location: The specific location of the disease identified by the model in the image, usually marked in the form of a bounding box, indicating the area or range of the disease. These bounding boxes can help identify the exact location affected by the disease for further analysis or processing. 2) Disease category: The type or category of disease identified by the model, such as brown spot, gray spot, mosaic, etc. Each disease type has specific symptoms and manifestations. Category information helps determine the specific type of disease so that corresponding prevention and control measures can be taken. 3) Confidence score: The confidence score of the model for each recognition result indicates the model's confidence in its test results. The confidence score helps evaluate the reliability and accuracy of the test results. 4) Disease severity: Leaf disease information may also include the severity or infection level of the disease to guide disease management strategies.
[0089] It can be understood that first, the disease information is extracted based on the detection results generated by the model. These results include the specific location of the disease in the image, usually represented by the coordinates of a bounding box, indicating the diseased area. Next, the category of the disease is identified, such as brown spot, gray spot, or mosaic disease. The model will classify each disease type and output the corresponding label. Subsequently, the confidence score provided by the model will show the degree of confidence in each detection result, helping to assess the reliability of the results. Finally, this information is summarized into a detailed leaf disease report and output to the user for further analysis and appropriate prevention and control measures. This process ensures the accuracy and practicality of disease information, thereby supporting more effective disease management.
[0090] This embodiment provides a leaf disease detection method, which includes obtaining an image to be detected; inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM non-parameter attention mechanism and PConv convolution to improve the initial leaf disease detection model; and outputting leaf disease information according to the detection result. First, the apple leaf image to be detected is obtained through a camera device or from a database or a network, and then, these images to be detected are input into the target leaf disease detection model, which is optimized to first adjust the image to a preset size to ensure a consistent input size. Subsequently, the model performs feature extraction and feature mapping, and generates a fusion feature map through upsampling, downsampling and lateral connection, and finally obtains the disease detection result through decoding and classification, and obtains the location and category information of the leaf disease according to the detection result. Since the model introduces SimAM non-parameter attention mechanism and PConv convolution, the accuracy of feature extraction and the detection capability of small target diseases are significantly enhanced, while reducing the amount of calculation and improving the detection efficiency. These improvements enable the model to maintain high accuracy even in complex backgrounds, thereby enabling accurate detection of apple leaf diseases and effectively improving the reliability of leaf disease detection.
[0091] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can refer to the above introduction, and will not be repeated later. Figure 5 , Figure 5 This is a flow chart of the second embodiment of the leaf disease detection method of the present application. Before step S20, the leaf disease detection method further includes steps S01 to S02:
[0092] Step S01, obtaining a target leaf data set, and dividing the target leaf data set into a training set and a test set;
[0093] It should be noted that the target leaf dataset refers to a collection of a large number of apple leaf images, which are specifically used for model training and testing. The dataset contains images of various leaf diseases, such as brown spot, gray spot, mosaic, etc., and may include leaf images under different lighting, angles and backgrounds, in order to provide the model with diverse learning and testing samples. The training set is a part of the data divided from the target leaf dataset, which is used for model learning and training. During the training process, the model learns how to identify and classify diseases on leaves by continuously processing the images in the training set and their corresponding labels. The test set is another part of the data divided from the target leaf dataset, which is specifically used to evaluate the performance of the model. The images in the test set are not involved in the training of the model. They are used to test the performance of the model on unseen data to ensure the generalization ability and practical application effect of the model.
[0094] It can be understood that, first, the target leaf data set is constructed by shooting or collecting apple leaf images containing a variety of leaf diseases (such as brown spot, gray spot, mosaic, etc.) from the database to ensure that the data covers different lighting, angles and background conditions to provide comprehensive training and test samples. After the construction is completed, the data set is divided into a training set and a test set. Usually, the data set is divided in a ratio of 80%:20% or 70%:30%, of which 80% or 70% of the data is used as a training set for model training and parameter adjustment, and the remaining 20% or 30% is used as a test set to evaluate the performance and generalization ability of the model. During the division process, ensure that the images in the training set and the test set have similar disease category distributions to avoid inconsistencies between the training and test data and ensure the reliability of the evaluation results.
[0095] Step S02: using the training set and the test set to train and test the initial leaf disease detection model to obtain a target leaf disease detection model.
[0096] Training refers to inputting the image data in the training set into the initial leaf disease detection model, adjusting its internal parameters through the model's learning process, and gradually improving the accuracy of leaf disease detection and classification by extracting features and classifying diseases from the images in the training set, and using known disease labels for back propagation and optimization. The training process includes multiple iterations. In each iteration, the model calculates the error between the predicted result and the true label through the loss function, and adjusts the model parameters through optimization algorithms (such as gradient descent) to minimize the error, and finally obtains a trained target leaf disease detection model. Testing refers to inputting the image data in the test set into the trained model to evaluate the performance of the model on unseen data. The test set is used to test the generalization ability of the model, that is, whether the model can accurately identify and classify diseases in new images. During the test process, the model predicts the test set images, generates detection results, and then compares these results with the true labels of the test set to evaluate the model's performance indicators such as accuracy, recall, F1 score, etc., so as to determine the reliability and effectiveness of the model in practical applications.
[0097] It can be understood that, first, the initial leaf disease detection model is trained, the image data in the training set is input into the model, and the model is used to extract features and classify diseases from these images. Combined with the known disease labels, the model adjusts its internal parameters through back propagation and optimization algorithms to minimize the error between the predicted results and the actual labels, thereby improving the detection accuracy of the model. The training process will be iterated multiple times to ensure that the model performs best on the training data. Secondly, the performance of the model is tested, and the image data in the test set is input into the trained model to evaluate the performance of the model on unseen data. By comparing the model's prediction results with the true labels of the test set, the model's accuracy, recall rate and other performance indicators are calculated to verify the model's generalization ability and practical application effect. Finally, through these two steps, the optimized target leaf disease detection model is obtained, which has higher accuracy and reliability in identifying and classifying leaf diseases.
[0098] As an example, the steps of training and testing the initial leaf disease detection model using the training set and the test set to obtain the target leaf disease detection model include: training the initial leaf disease detection model using the training set to obtain a reference detection model; testing the reference detection model using the test set to obtain a test result; when the test result does not meet the preset requirements, returning to the step of training the reference detection model using the training set until the test result meets the preset requirements to obtain the target leaf disease detection model.
[0099] The reference detection model refers to a leaf disease detection model that has undergone preliminary training. It is a model version obtained after training the initial model using the training set. After the training is completed, this model is used for further testing to evaluate its performance on new data. The test results refer to the results obtained after evaluating the performance of the reference detection model on the test set, including the model's disease detection accuracy, precision, recall rate and other performance indicators on the test set images. These results are used to determine whether the model meets the expected performance standards. Preset requirements refer to performance standards or goals set during the model testing process, such as detection accuracy, recall rate, F1 score, etc. The model test results need to meet these standards to consider the model performance qualified. If the test results do not meet the preset requirements, the model needs to be retrained, parameters adjusted or the algorithm improved until the model meets these requirements.
[0100] First, the initial leaf disease detection model is trained using the training set to generate a reference detection model. During the training process, the model continuously adjusts internal parameters to improve the prediction accuracy of the training data. Next, the images in the test set are input into the reference detection model for performance testing to obtain test results, which include the accuracy of the model on unseen data and other performance indicators. If the test results fail to meet the preset performance requirements (such as accuracy, recall rate, etc.), it is necessary to return to the training stage and re-use the training set to further train and optimize the model. This process will continue to cycle until the test results of the model meet the preset requirements, and finally an optimized target leaf disease detection model with higher detection accuracy and reliability is obtained.
[0101] As an example, the loss function in the initial leaf disease detection model includes complete intersection-over-union loss, category loss and confidence loss. The step of using the training set to train the initial leaf disease detection model to obtain a reference detection model includes: introducing the mean distance prior intersection-over-union loss to replace the complete intersection-over-union loss; obtaining the total loss based on the mean distance prior intersection-over-union loss, the confidence loss and the category loss; using the training set to train the initial leaf disease detection model until the total loss is lower than a preset loss value to obtain a reference detection model.
[0102] The loss function is a mathematical function used to evaluate the difference between the model's prediction results and the actual label. It guides the model to adjust parameters during the training process to minimize the prediction error and improve the model performance. Complete Intersection over Union Loss (CIOU loss) is a loss function that measures the overlap between the predicted box and the true box. CIOU loss not only considers the overlapping area of the predicted box and the true box, but also their center point distance and aspect ratio, aiming to improve the positioning accuracy and shape matching of the box. Category loss is used to measure the model's prediction accuracy for each target category. It calculates the difference between the category probability distribution predicted by the model and the true category label, and is usually optimized using cross entropy loss. Confidence loss is used to measure the model's confidence in the existence of the target. It evaluates the gap between the confidence score predicted by the model (i.e., the probability that the target is contained in the target detection box) and the actual label, aiming to improve the reliability of target detection. Mean Distance Prior Intersection over Union Loss (MDPIOU loss) is an improved loss function. It combines the geometric features of the rectangular box on the basis of CIOU loss, uses the minimum point distance to predict the bounding box, and optimizes the model's positioning accuracy for the target. The calculation formula of MDPIOU is as follows:
[0103]
[0104] Where A and B represent the predicted box and the real box, w and h refer to the width and height of the input image, d1 and d2 represent the distance between the upper left corner and the lower right corner of the predicted box and the real box, respectively.
[0105] The total loss is a comprehensive loss value calculated by combining the mean distance prior intersection loss, confidence loss, and category loss. The total loss reflects the overall performance of the model in the object detection task and helps guide the model training process. The preset loss value is a threshold set during the training process to determine whether the model has achieved the expected performance level. When the total loss is lower than this preset value, it means that the prediction error of the model is within an acceptable range and the training process can be terminated.
[0106] First, in the initial leaf disease detection model, the original loss function includes complete intersection over union loss (CIOU loss), category loss, and confidence loss. In order to optimize the model performance, the complete intersection over union loss is replaced by the mean distance prior intersection over union loss (MDPIOU loss), which combines the geometric features of the target box to improve the positioning accuracy. Then, based on the new MDPIOU loss, confidence loss, and category loss, the total loss is calculated. This total loss combines the positioning accuracy, classification accuracy, and confidence reliability of the model in target detection. Next, the model is trained using the training set, and the model parameters are continuously adjusted to minimize the total loss until the total loss is lower than the preset loss value. Finally, the performance of the reference detection model obtained on the training data reaches the optimization goal, providing a basis for improvement for subsequent target leaf disease detection.
[0107] As an example, the step of obtaining a target leaf data set includes: obtaining an initial leaf data set; rotating, adjusting brightness, adjusting contrast, and cropping images in the initial leaf data set to obtain an enhanced data set; and labeling and classifying the enhanced data set to obtain a target leaf data set.
[0108] The initial leaf dataset refers to the collection of apple leaf images collected initially. These images may include different types of leaf diseases, but may not fully cover all possible situations in terms of quantity and type. It is the basis for constructing the target leaf dataset. Rotation adjustment refers to rotating the image to generate views at different angles, increasing the diversity of the dataset, and helping the model to handle disease identification at various leaf angles. Brightness adjustment refers to adjusting the brightness of the image to simulate the state of the leaf under different lighting conditions, so that the model has stronger disease detection capabilities under different lighting conditions. Contrast adjustment refers to adjusting the contrast of the image to enhance or weaken the color difference in the image, thereby helping the model to identify diseases under various contrasts. Cropping refers to cropping the image, selecting a part of the image area, increasing the regional variability in the dataset, and helping the model focus on different parts of the image. The enhanced dataset refers to the dataset generated by applying the above-mentioned various image processing techniques (such as rotation, brightness and contrast adjustment, and cropping) to the initial leaf dataset. This enhanced dataset contains transformed and processed images, has higher diversity and richness, and can help improve the training effect and generalization ability of the model. Labeling and classification refers to the detailed labeling and classification of the images in the augmented dataset. Labeling includes marking the specific location and type of the disease in each image, and classification is to clearly mark the category of the disease in the image (such as brown spot disease, gray spot disease, etc.). This process ensures that each image in the dataset has corresponding disease information, providing accurate label data for model training and evaluation.
[0109] First, an initial leaf dataset is collected, which contains images of different types of apple leaves, which may cover a variety of leaf diseases. Then, the images in the initial leaf dataset are enhanced by rotation adjustment to generate views at different angles, brightness adjustment to simulate different lighting conditions, contrast adjustment to adjust the color differences of the images, and cropping the images to focus on different areas. These operations make the dataset richer and more diverse. Subsequently, the LabelIng tool is used to annotate and classify the enhanced dataset, that is, to add specific location marks and category labels of the disease to each image to ensure that each image accurately represents its disease type. Ultimately, the target leaf dataset obtained after these processing has higher quality and diversity, providing a solid foundation for model training and testing.
[0110] This embodiment obtains a target leaf data set, and divides the target leaf data set into a training set and a test set; uses the training set and the test set to train and test the initial leaf disease detection model to obtain a target leaf disease detection model. First, this embodiment ensures the diversity and representativeness of the data set by obtaining the target leaf data set and dividing it into a training set and a test set. The training set is used to train the initial leaf disease detection model. By inputting the image data in the training set into the model, the model can learn how to identify and classify different types of leaf diseases, thereby optimizing its performance. The test set is used to evaluate the generalization ability of the model, that is, the performance of the model on unseen data. By inputting the test set into the model, its detection accuracy and reliability can be verified to ensure that the model not only performs well on the training data, but also can process new data in practical applications. Finally, after training and testing, the target leaf disease detection model obtained in this embodiment has high accuracy and robustness in disease recognition, and can effectively support actual disease detection tasks.
[0111] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the leaf disease detection method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0112] This application also provides a leaf disease detection device, please refer to Figure 6 , the leaf disease detection device comprises:
[0113] An image acquisition module 10 is used to acquire an image to be detected;
[0114] A detection module 20 is used to input the image to be detected into a target leaf disease detection model to obtain a detection result. The target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model;
[0115] The result output module 30 outputs leaf disease information according to the detection result.
[0116] In one embodiment, the initial leaf disease detection model includes an initial backbone network and an initial neck network, the initial backbone network includes an extended local attention network layer, the initial neck network includes an SPPCSPC structure, and the target leaf disease detection model includes a backbone network and a neck network; the backbone network is obtained by improving the initial backbone network using a lightweight extended local attention network layer and a lightweight hybrid attention mechanism network layer; the neck network is obtained by improving the initial neck network using an SPPCSPC-parameter-free attention mechanism structure; the lightweight extended local attention network layer, the lightweight hybrid attention mechanism network layer, and the SPPCSPC-parameter-free attention mechanism structure are obtained by improving the extended local attention network layer and the SPPCSPC structure according to the PConv convolution and the SimAM parameter-free attention mechanism.
[0117] In one embodiment, the lightweight extended local attention network layer is obtained by replacing the convolution block structure in the extended local attention network layer with the PConv convolution; the lightweight hybrid attention mechanism network layer is obtained by introducing the SimAM parameter-free attention mechanism into the lightweight extended local attention network layer; the SPPCSPC-parameter-free attention mechanism structure is obtained by introducing the SimAM parameter-free attention mechanism into the SPPCSPC structure.
[0118] In one embodiment, the detection module 20 is further used to adjust the image to be detected to a preset size through the target leaf disease detection model to obtain the target image to be detected; perform feature extraction on the target image to be detected through the target leaf disease detection model to obtain a multi-scale feature map; perform feature mapping, upsampling, downsampling and horizontal connection on the multi-scale feature map through the target leaf disease detection model to obtain a fused feature map; decode and classify the fused feature map through the target leaf disease detection model to obtain a detection result including the location and category information of the leaf disease.
[0119] In one embodiment, the detection module 20 is also used to obtain a target leaf data set and divide the target leaf data set into a training set and a test set; use the training set and the test set to train and test the initial leaf disease detection model to obtain a target leaf disease detection model.
[0120] In one embodiment, the detection module 20 is further used to train the initial leaf disease detection model using the training set to obtain a reference detection model; test the reference detection model using the test set to obtain a test result; when the test result does not meet the preset requirements, return to the step of training the reference detection model using the training set until the test result meets the preset requirements to obtain a target leaf disease detection model.
[0121] In one embodiment, the loss function in the initial leaf disease detection model includes a complete intersection-and-union loss, a category loss, and a confidence loss. The detection module 20 is also used to introduce a mean distance prior intersection-and-union loss to replace the complete intersection-and-union loss; a total loss is obtained based on the mean distance prior intersection-and-union loss, the confidence loss, and the category loss; and the initial leaf disease detection model is trained using the training set until the total loss is lower than a preset loss value to obtain a reference detection model.
[0122] In one embodiment, the detection module 20 is also used to obtain an initial leaf data set; rotate, adjust brightness, adjust contrast, and crop the images in the initial leaf data set to obtain an enhanced data set; and label and classify the enhanced data set to obtain a target leaf data set.
[0123] The leaf disease detection device provided by the present application adopts the leaf disease detection method in the above embodiment, which can solve the technical problem of how to accurately detect apple leaf diseases. Compared with the prior art, the beneficial effects of the leaf disease detection device provided by the present application are the same as the beneficial effects of the leaf disease detection method provided by the above embodiment, and the other technical features of the leaf disease detection device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0124] The present application provides a leaf disease detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the leaf disease detection method in the above-mentioned embodiment one.
[0125] Reference below Figure 7, which shows a schematic diagram of the structure of a leaf disease detection device suitable for implementing the embodiment of the present application. The leaf disease detection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The leaf disease detection device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0126] like Figure 7 As shown, the leaf disease detection device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM) 1004. Various programs and data required for the operation of the leaf disease detection device are also stored in the RAM 1004. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 may allow the leaf disease detection device to communicate wirelessly or wired with other devices to exchange data. Although the leaf disease detection device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.
[0127] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0128] The leaf disease detection device provided by the present application adopts the leaf disease detection method in the above embodiment, which can solve the technical problem of how to accurately detect apple leaf diseases. Compared with the prior art, the beneficial effects of the leaf disease detection device provided by the present application are the same as the beneficial effects of the leaf disease detection method provided by the above embodiment, and the other technical features of the leaf disease detection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0129] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0130] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0131] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the leaf disease detection method in the above-mentioned embodiment.
[0132] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0133] The computer-readable storage medium may be included in the leaf disease detection device; or may exist independently without being assembled into the leaf disease detection device.
[0134] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the leaf disease detection device, the leaf disease detection device: obtains an image to be detected; inputs the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model; and outputs leaf disease information according to the detection result.
[0135] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0136] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0137] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0138] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned leaf disease detection method, and can solve the technical problem of how to accurately detect apple leaf diseases. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the leaf disease detection method provided in the above-mentioned embodiment, and will not be elaborated here.
[0139] The present application also provides a computer program product, comprising a computer program, which implements the steps of the leaf disease detection method as described above when executed by a processor.
[0140] The computer program product provided in this application can solve the technical problem of how to accurately detect apple leaf diseases. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the leaf disease detection method provided in the above embodiment, which will not be repeated here.
[0141] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A leaf disease detection method, characterized in that: The method comprises: Acquire the image to be detected; Inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model; Leaf disease information is output according to the detection result.
2. The method according to claim 1, characterized in that The initial leaf disease detection model includes an initial backbone network and an initial neck network, the initial backbone network includes an extended local attention network layer, the initial neck network includes an SPPCSPC structure, and the target leaf disease detection model includes a backbone network and a neck network; The backbone network is obtained by improving the initial backbone network using a lightweight extended local attention network layer and a lightweight hybrid attention mechanism network layer; The neck network is obtained by improving the initial neck network using the SPPCSPC-parameter-free attention mechanism structure; The lightweight extended local attention network layer, the lightweight hybrid attention mechanism network layer and the SPPCSPC-parameter-free attention mechanism structure are obtained by improving the extended local attention network layer and the SPPCSPC structure based on the PConv convolution and the SimAM parameter-free attention mechanism.
3. The method according to claim 2, characterized in that The lightweight extended local attention network layer is obtained by replacing the convolution block structure in the extended local attention network layer with the PConv convolution; The lightweight hybrid attention mechanism network layer is obtained by introducing the SimAM parameter-free attention mechanism into the lightweight extended local attention network layer; The SPPCSPC-parameter-free attention mechanism structure is obtained by introducing the SimAM parameter-free attention mechanism into the SPPCSPC structure.
4. The method according to claim 1, characterized in that The step of inputting the image to be detected into the target leaf disease detection model to obtain the detection result comprises: The target leaf disease detection model is used to adjust the image to be detected to a preset size to obtain the target image to be detected; Extracting features of the target image to be detected by using the target leaf disease detection model to obtain a multi-scale feature map; Performing feature mapping, upsampling, downsampling, and horizontal connection on the multi-scale feature map through the target leaf disease detection model to obtain a fused feature map; The fused feature map is decoded and classified by the target leaf disease detection model to obtain a detection result including the location and category information of the leaf disease.
5. The method according to claim 1, characterized in that Before the step of inputting the image to be detected into the target leaf disease detection model to obtain the detection result, the method further includes: Acquire a target leaf data set, and divide the target leaf data set into a training set and a test set; The training set and the test set are used to train and test the initial leaf disease detection model to obtain a target leaf disease detection model.
6. The method according to claim 5, characterized in that The step of using the training set and the test set to train and test the initial leaf disease detection model to obtain the target leaf disease detection model comprises: Using the training set to train the initial leaf disease detection model to obtain a reference detection model; Using the test set to test the reference detection model, to obtain a test result; When the test result does not meet the preset requirements, return to the step of using the training set to train the reference detection model until the test result meets the preset requirements to obtain a target leaf disease detection model.
7. The method according to claim 6, characterized in that The loss function in the initial leaf disease detection model includes complete intersection-over-union loss, category loss, and confidence loss. The step of using the training set to train the initial leaf disease detection model to obtain a reference detection model includes: Introducing the mean distance prior intersection-over-union loss to replace the complete intersection-over-union loss; Obtaining a total loss according to the mean distance prior intersection-over-union loss, the confidence loss, and the category loss; The initial leaf disease detection model is trained using the training set until the total loss is lower than a preset loss value, thereby obtaining a reference detection model.
8. The method according to claim 5, characterized in that The step of obtaining the target leaf data set includes: Obtain an initial leaf data set; Rotating, adjusting brightness, adjusting contrast, and cropping the images in the initial leaf data set to obtain an enhanced data set; The enhanced data set is labeled and classified to obtain a target leaf data set.
9. A leaf disease detection device, characterized in that: The device comprises: An image acquisition module, used for acquiring an image to be detected; A detection module, used for inputting the image to be detected into a target leaf disease detection model to obtain a detection result, wherein the target leaf disease detection model is obtained by introducing SimAM parameter-free attention mechanism and PConv convolution to improve the initial leaf disease detection model; The result output module outputs leaf disease information according to the detection result.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the leaf disease detection method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Crop disease detection method and device
CN120032181A
