Classification method and system for leaf diseases of Cucurbitaceae plants
By constructing the ResNet18-AWRB architecture and combining the SE and GAM modules to generate dynamic attention weights, the problem of the difference in features between the lesion area and the background in plant disease images in the deep learning model was solved, and the accuracy and robustness of disease classification were improved.
Patent Information
- Application Number
- CN202511006134.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-07-22
AI Technical Summary
Existing deep learning models have difficulty adapting to the significant differences in morphology, scale, and distribution between lesion areas and background features in plant disease images, resulting in poor classification performance.
A ResNet18-AWRB architecture is constructed, combining the SE module and the GAM module to generate dynamic attention weights. By fusing the main path and the residual path, the focusing ability on the diseased area is enhanced and background interference is suppressed.
Without increasing the computational complexity, the model's ability to identify diseased areas and classification accuracy are improved, especially showing stronger robustness in complex backgrounds and weak disease scenarios.
Smart Images

Figure CN120510458B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent agricultural technology, and in particular to a method and system for classifying leaf diseases of Cucurbitaceae plants. Background Art
[0002] Plant diseases are having an increasingly serious impact on agricultural production. Crop diseases not only lead to reduced crop yields but also affect their quality, even threatening the sustainable development of agriculture. Globally, food losses due to plant diseases and insect pests account for approximately 40% of total crop production each year, a proportion that is increasing with global climate change and changes in agricultural production methods. In this context, early identification and rapid diagnosis of plant diseases are particularly important. Traditional manual inspection methods are not only time-consuming and labor-intensive, but also susceptible to subjective human factors, making them unable to meet the needs of precision agriculture. Efficient and automated identification and classification of plant diseases has become a key research direction in the development of smart agriculture.
[0003] Traditional plant disease diagnosis methods rely primarily on manual inspection and expert knowledge. Disease classification and diagnosis are performed manually by observing the appearance of symptoms on leaves, fruits, and other parts of the plant. Common manual diagnostic methods include visual inspection, microscopic examination, and biological diagnostic methods. While these methods have a certain degree of reliability, they often have significant limitations. First, manual inspection requires a significant amount of time and manpower and is easily affected by environmental factors, leading to inconsistent results. Second, the diagnostic process relies on expert experience and requires a high level of specialized knowledge, making it difficult to popularize in large-scale agricultural production. Finally, early disease symptoms are often subtle and difficult to detect with the naked eye, and the expression of disease symptoms varies regionally, limiting the adaptability and reliability of traditional methods. In recent years, with the development of deep learning and computer vision technologies, automatic disease detection methods based on image recognition have gradually become a research hotspot in plant disease identification. Convolutional neural networks (CNNs), one of the core algorithms of deep learning, have been widely used in image processing, particularly in plant disease identification. CNNs automatically extract features from images through multi-layer convolution operations, eliminating the tedious process of manual feature extraction and significantly improving the efficiency and accuracy of image classification. The application of CNNs not only speeds up disease identification but also reduces human interference in the results. Currently, CNN-based plant disease identification methods have made some progress. By training on large-scale plant disease image datasets, researchers have enabled CNNs to identify a variety of diseases across different plant species.
[0004] While existing deep learning-based methods have made significant progress in plant disease recognition, traditional CNNs still face several challenges. One of the most significant issues is that standard CNNs often lack the ability to focus on diseased areas, resulting in poor classification performance when dealing with complex backgrounds or different disease types. In plant disease images, lesions often appear as small areas, and their morphology can differ significantly from surrounding healthy areas. This can cause models, without sufficient attention mechanisms, to overlook key disease features, compromising classification accuracy.
[0005] To address this issue, some recent studies have proposed introducing an attention mechanism to enhance the model's ability to focus on diseased areas. By assigning different weights to different regions in the image, the attention mechanism allows the model to focus more closely on disease features, thereby improving the accuracy of disease classification. For example, the Squeeze-and-Excitation (SE) module weights the features of each channel, enhancing the model's responsiveness to important features. Furthermore, the Global Attention Module (GAM) module combines channel and spatial attention to further enhance the model's understanding of the overall image structure, providing more comprehensive feature extraction capabilities for disease recognition.
[0006] Although attention mechanisms have demonstrated promising performance in multiple image recognition tasks, existing research often embeds attention modules (such as SE or GAM modules) as additional structures within CNN or ResNet (residual network) backbones to enhance channel response or spatial focus. However, this approach remains limited by the limitations of traditional residual-structured information fusion mechanisms. Standard residual connections employ a fixed weight strategy for information fusion, making them difficult to adapt to the significant differences in morphology, scale, and distribution between lesion areas and background features in plant disease images. Summary of the Invention
[0007] The present invention solves the problem that existing deep learning models are difficult to adapt to the significant differences in morphology, scale and distribution between the lesion area and background features in plant disease images.
[0008] The method for classifying leaf diseases of Cucurbitaceae plants of the present invention comprises the following steps:
[0009] Step S1, obtaining a dataset of images of cucurbitaceae plant leaf diseases and preprocessing the images;
[0010] Step S2: Build the ResNet18-AWRB architecture, specifically:
[0011] The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path;
[0012] Step S3: input the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and output the classification results of Cucurbitaceae plant leaf diseases.
[0013] Furthermore, in one embodiment of the present invention, in step S2, the ResNet18-AWRB architecture is specifically:
[0014] The attention fusion path generates the first attention weight and the second attention weight respectively. The first attention weight weights the output result of the residual path, and the second attention weight weights the output result of the main path. The weighted output result of the residual path and the weighted output result of the main path are fused.
[0015] Furthermore, in one embodiment of the present invention, the attention fusion path generates the first attention weight and the second attention weight respectively, specifically:
[0016] The attention fusion path generates the first attention weight and the second attention weight by fusing attention respectively.
[0017] Furthermore, in one embodiment of the present invention, the fused attention is a fusion combination of the SE module and the GAM module.
[0018] Furthermore, in one embodiment of the present invention, the first attention weight weights the output result of the residual path, specifically:
[0019] The residual path outputs the result through the identity mapping, and the first attention weight weights the output result of the residual path.
[0020] Furthermore, in one embodiment of the present invention, the second attention weight is used to weight the output result of the main path, specifically:
[0021] The main path outputs the results through the convolution weight layer, activation layer and convolution weight layer in sequence, and the second attention weight weights the output results of the main path.
[0022] The Cucurbitaceae plant leaf disease classification system of the present invention is implemented by the Cucurbitaceae plant leaf disease classification method described above, and includes the following modules:
[0023] The preprocessing module obtains a dataset of images of cucurbitaceae plant leaf diseases and preprocesses them;
[0024] Build the module and build the ResNet18-AWRB architecture, specifically:
[0025] The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path;
[0026] The classification module inputs the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and outputs the classification results of Cucurbitaceae plant leaf diseases.
[0027] This invention solves the problem that existing deep learning models are difficult to adapt to the significant differences in morphology, scale, and distribution between lesion areas and background features in plant disease images. Specific benefits include:
[0028] The present invention relates to a method for classifying leaf diseases of Cucurbitaceae plants. Existing deep learning models are difficult to adapt to the significant differences in morphology, scale, and distribution between the diseased area and the background features in plant disease images. In order to solve the above technical problems, the present invention improves the original ResNet18 to construct a ResNet18-AWRB architecture, and uses this architecture to classify leaf diseases of Cucurbitaceae plants. This architecture utilizes the SE module and the GAM module to extract the channel importance and spatial context relationship of the input features, and dynamically generates the fusion weights of the main path and the residual path. and , achieving adaptive focusing on lesion features and suppressing redundant features, thereby improving the model's ability to identify key areas without significantly increasing computational complexity. AWRB seamlessly replaces the residual units in each layer of the original ResNet18, offering greater structural uniformity and deployment flexibility. Experiments demonstrate that this architecture outperforms traditional attention embedding methods across multiple evaluation metrics, demonstrating particularly robustness in complex backgrounds and scenarios with faint disease features. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0030] Figure 1 This is the ResNet18-AWRB architecture diagram described in Implementation Method 2. DETAILED DESCRIPTION
[0031] The following will clearly and completely describe various embodiments of the present invention in conjunction with the accompanying drawings. The embodiments described with reference to the accompanying drawings are exemplary and intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0032] Embodiment 1: The method for classifying leaf diseases of Cucurbitaceae plants described in this embodiment comprises the following steps:
[0033] Step S1, obtaining a dataset of images of cucurbitaceae plant leaf diseases and preprocessing the images;
[0034] Step S2: Build the ResNet18-AWRB architecture, specifically:
[0035] The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path;
[0036] Step S3: input the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and output the classification results of Cucurbitaceae plant leaf diseases.
[0037] Existing deep learning models have difficulty adapting to the significant differences in morphology, scale, and distribution between lesion areas and background features in plant disease images.
[0038] In order to solve the above technical problems, this embodiment proposes a method for classifying leaf diseases of Cucurbitaceae plants, comprising the following steps:
[0039] Step S1: obtaining a dataset of images of cucurbitaceae plant leaf diseases and preprocessing the images, specifically:
[0040] A dataset of images of leaf diseases in cucurbit plants was constructed. This dataset includes images of healthy and diseased leaves from 12 different cucurbit species (such as cucumber, pumpkin, gourd, and loofah). During the dataset construction process, the image samples of different disease types and healthy states were carefully considered to cover a wide range of natural environmental conditions, including factors such as lighting, angles, and background interference. All images were standardized and uniformly converted to RGB (red, green, and blue) three-channel format. All images were resized to 224×224 to meet the input requirements of the ResNet18 network. Image augmentation techniques were used for data expansion. Data augmentation operations included random rotation, horizontal flipping, affine transformation (maximum translation of 10%), and brightness and contrast adjustments. These operations increased the diversity of the dataset, thereby improving the generalization ability of the model.
[0041] Step S2: Build the ResNet18-AWRB architecture, specifically:
[0042] The ResNet18-AWRB architecture consists of a main path, a residual path, and an attention fusion path.
[0043] Step S3: Optimize the ResNet18-AWRB architecture and training strategy, specifically:
[0044] The model is trained using Adam (optimizer), with the initial learning rate set to 1e-3 and the loss function being CrossEntropyLoss (cross entropy loss). The loss function is calculated as follows:
[0045] ;
[0046] in, is the true label, is the predicted probability, is the number of samples, is the loss function, is a natural number. To prevent overfitting, an early stopping mechanism is employed; training is automatically terminated when the validation set loss does not decrease for five consecutive rounds. Furthermore, batch normalization and dropout regularization techniques are used during training to further enhance the model's generalization capabilities. Data augmentation techniques are employed during training to increase the diversity of training data through various methods, such as random rotation, affine transformation, and brightness adjustment. This allows the model to adapt to different disease states and natural environmental conditions, thereby improving its robustness and accuracy.
[0047] Step S4, evaluation and optimization, specifically:
[0048] After training is complete, multiple evaluation metrics are used to comprehensively evaluate the model performance. In order to fully understand the performance of the model on different disease categories, this implementation adopts the following evaluation metrics:
[0049] 1) Accuracy is a common indicator for evaluating the overall performance of a model. It represents the proportion of correctly classified samples to the total number of samples. Its calculation formula is:
[0050] ;
[0051] in, (True Positive) is the correct classification, which is the number of samples in the positive class. (True Negative) is the correct classification, which is the number of negative class samples. (False Positive) is the number of samples of the wrong classification, (False Negative) is the number of samples that are misclassified and are negative.
[0052] 2) Precision evaluates the proportion of samples that are actually positive among the samples that the model identifies as positive. It is used to measure the accuracy of the model when predicting positive. The calculation formula is as follows:
[0053] ;
[0054] 3) Recall evaluates the proportion of samples that the model correctly identifies as positive among all samples that are actually positive. It is used to measure the sensitivity of the model and is calculated as:
[0055] ;
[0056] 4) F1 Score is the harmonic mean of precision and recall, comprehensively considering the model's precision and recall in positive class identification. In classification tasks, F1 Score is an important evaluation metric, especially in cases of class imbalance. A higher F1 Score indicates better overall model performance, balancing the trade-off between precision and recall. Its calculation formula is:
[0057] ;
[0058] 5) Kappa coefficient (an indicator of classification accuracy) is a statistic used to evaluate the consistency and reliability of a classifier. It takes into account the impact of accidental consistency on the classification results. Its calculation formula is:
[0059] ;
[0060] in, is the observed consistency probability, which is the probability that the model prediction result is consistent with the true label; is the expected probability of consistency, and is the random probability of consistency based on the category distribution. The value of the Kappa coefficient ranges from -1 to 1, with higher values indicating better classification consistency.
[0061] 6) Matthews correlation coefficient is another indicator used to evaluate the performance of binary classification models, which can comprehensively consider the results of all four confusion matrices ( 、 、 and ), the value of MCC (control side) ranges from -1 to 1, with a value of 1 for perfect classification, 0 for random classification, and -1 for complete misclassification. The MCC calculation formula is:
[0062] ;
[0063] 7) The confusion matrix is used to show how the model classifies samples of different categories. The confusion matrix can intuitively show which categories the model is prone to misclassification.
[0064] This implementation compares the performance of different model architectures through ablation experiments. Specifically, the following comparison models were constructed: the original ResNet18 (Residual Neural Network 18), the original ResNet18 with only the SE module introduced, the original ResNet18 with only the GAM module introduced, and the ResNet18-AWRB (Residual Neural Network 18 - Weighted Residual Architecture) described in this implementation. By comparing the performance of these models under the same training conditions, the advantages of AWRB in improving diseased area identification, classification accuracy, and robustness were further verified.
[0065] Step S5: Input the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and output the classification results of Cucurbitaceae plant leaf diseases, specifically:
[0066] After the dataset is augmented in step S1, it is divided into a training set, a validation set, and a test set. The training set is used to train the model, the validation set is used to monitor the model's performance during training, and the test set is used to ultimately evaluate the model's accuracy and robustness. The training set and validation set are split in a 7:3 ratio to ensure data diversity during training and reduce the possibility of overfitting.
[0067] Therefore, this implementation method takes the attention-guided AWRB as the core, and on the basis of keeping the model lightweight, strengthens the disease characteristic response through the dynamic information flow regulation mechanism, thereby improving the model's discrimination ability and practical applicability.
[0068] In summary, this implementation replaces the BasicBlock residual unit in the original ResNet18 with the AWRB. This module dynamically generates weight coefficients between the main path and the identity mapping path, enabling adaptive regulation of feature information between the main and residual paths. This structurally overcomes the residual bottleneck of traditional "fixed weighted fusion."
[0069] First, in terms of feature extraction, the attention fusion path no longer acts in isolation on the feature map, but participates in controlling the information fusion path, making the feature flow more directional and targeted, thereby improving the expression accuracy of disease features. Secondly, in terms of structural optimization, AWRB retains the original lightweight basic framework of ResNet18, does not introduce additional deep network stacking, and only achieves enhanced feature modeling capabilities through local structural replacement. The weighted path fusion method in the module uses channel-by-channel multiplication and summation operations, which has low computational overhead and is suitable for agricultural edge device deployment scenarios with limited computing resources. It has good practicality and scalability. Thirdly, in terms of model generalization ability, this embodiment clearly constructs a self-built Cucurbitaceae plant image dataset containing 12 categories of health and disease states, and combines various data enhancement methods such as rotation, translation, and brightness perturbation to improve the model's adaptability under complex natural conditions. Ablation experiments were conducted to compare the ResNet18-AWRB, ResNet18-SE, ResNet18-GAM, and the original ResNet18 described in this embodiment. The results showed that they outperformed existing methods in terms of F1 score, Kappa coefficient, MCC, and other indicators, especially in disease categories such as "gray mold" and "downy mildew", significantly improving the classification accuracy. This verifies the effectiveness of the attention-guided residual fusion mechanism in multi-category disease recognition tasks.
[0070] In addition, the residual structure designed in this embodiment also performs well in terms of training stability. Due to the introduction of the main path and residual path with adjustable weights, the network gradient transfer is more flexible, which helps to alleviate the gradient vanishing or information redundancy problems in deep network training. In summary, this embodiment achieves the unity of feature extraction capability and structural efficiency by introducing the weighted residual structure of attention control without significantly increasing the complexity of the model, taking into account the requirements of accuracy, lightweight and deployability, and has clear technological advancement and broad application prospects.
[0071] Implementation 2: This implementation further limits the method for classifying leaf diseases of Cucurbitaceae plants described in Implementation 1. In step S2, the ResNet18-AWRB architecture is specifically:
[0072] The attention fusion path generates the first attention weight and the second attention weight respectively. The first attention weight weights the output result of the residual path, and the second attention weight weights the output result of the main path. The weighted output result of the residual path and the weighted output result of the main path are fused.
[0073] In this embodiment, the attention fusion path generates the first attention weight and the second attention weight respectively, specifically:
[0074] The attention fusion path generates the first attention weight and the second attention weight by fusing attention respectively.
[0075] In this embodiment, the fused attention is a fusion combination of the SE module and the GAM module.
[0076] In this embodiment, the first attention weight weights the output result of the residual path, specifically:
[0077] The residual path outputs the result through the identity mapping, and the first attention weight weights the output result of the residual path.
[0078] In this embodiment, the second attention weight is used to weight the output result of the main path, specifically:
[0079] The main path outputs the results through the convolution weight layer, activation layer and convolution weight layer in sequence, and the second attention weight weights the output results of the main path.
[0080] In this embodiment, if Figure 1 As shown in the figure, the original ResNet18 is used as the backbone network framework, and the ResNet18-AWRB architecture is proposed. Based on the original ResNet18 structure, the standard BasicBlock units in all residual modules are replaced with AWRB, forming the ResNet18-AWRB architecture. This achieves adaptive adjustment of the importance of information pathways, thereby enhancing the feature expression of the lesion area and improving recognition accuracy. The ResNet18-AWRB architecture consists of three parts: the main path, the residual path, and the attention fusion path.
[0081] 1) Main path: Feature x passes through the convolution weight layer, activation layer and convolution weight layer in sequence to extract deep local features, and the output is recorded as F(x);
[0082] 2) Residual path: The identity mapping directly transfers the input feature x, which is used to preserve shallow structural information and background patterns, enhancing the stability of model training;
[0083] 3) Attention Fusion Path: The fused attention is formed by the fusion of the SE module and the GAM. The input feature X is input into the SE module and the GAM module respectively. The results of the two are averaged and fused to output the total feature. Specifically: ① The SE module models the channel attention relationship through global average pooling and fully connected layers, and outputs the channel weight vector; ② The GAM module extracts channel and spatial dependencies at the same time, and models the cross-region feature response relationship; ③ The outputs of the two are concatenated and fed into a 1×1 convolution and a Sigmoid activation function (non-linear activation function) to generate the fused attention coefficient. , its complement is .
[0084] Finally, the output of AWRB is a weighted fusion of the main path output F(x) and the residual path input x according to the attention weight, which is achieved as follows: .
[0085] The above design realizes the dynamic weighted fusion of the main path and residual path information flows, effectively improving the model's ability to focus on fine-grained lesion areas and suppressing background noise interference.
[0086] Therefore, this embodiment adopts the original ResNet18 as the backbone network, and on its basis replaces the standard BasicBlock unit in each level of the residual module with the AWRB described in this embodiment. This structure dynamically weights and regulates the information fusion of the main path and the residual path by introducing an attention fusion path to enhance the model's ability to focus on key lesion areas. The main path includes two 3×3 convolution weight layers for constructing F(x), and an identity mapping branch to retain the input x. In each AWRB, the input feature x is input into the SE module and the GAM module at the same time. The SE module generates a channel attention vector through global average pooling and two fully connected layers, while the GAM module uses parallel channel branches and spatial branches to calculate Mc (channel matrix) and Ms (spatial matrix) respectively, and after fusion, generates the final fusion weight through 1×1 convolution and Sigmoid function. , used to weight the main path output; its complementary value Used to weight the residual path. This mechanism allows the model to adaptively assign the importance of the main path and residual path based on the input features, thereby enhancing the network's ability to distinguish local lesions from background areas, effectively suppressing background interference, and improving the ability to discriminate subtle disease patterns.
[0087] Embodiment 3: The Cucurbitaceae plant leaf disease classification system described in this embodiment is implemented by the Cucurbitaceae plant leaf disease classification method described in embodiment 1, and includes the following modules:
[0088] The preprocessing module obtains a dataset of images of cucurbitaceae plant leaf diseases and preprocesses them;
[0089] Build the module and build the ResNet18-AWRB architecture, specifically:
[0090] The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path;
[0091] The classification module inputs the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and outputs the classification results of Cucurbitaceae plant leaf diseases.
[0092] The above is a detailed introduction to the Cucurbitaceae plant leaf disease classification method and system proposed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for classifying leaf diseases of Cucurbitaceae plants, characterized in that: The following steps are involved: Step S1, obtaining a dataset of images of cucurbitaceae plant leaf diseases and preprocessing the images; Step S2: Build the ResNet18-AWRB architecture, specifically: The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path; Step S3, inputting the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture, and outputting the classification results of Cucurbitaceae plant leaf diseases; In step S2, the ResNet18-AWRB architecture is specifically: The attention fusion path generates a first attention weight and a second attention weight respectively. The first attention weight weights the output result of the residual path, and the second attention weight weights the output result of the main path. The weighted output result of the residual path and the weighted output result of the main path are fused; The attention fusion path generates the first attention weight and the second attention weight respectively, specifically: The attention fusion path generates the first attention weight and the second attention weight respectively by fusing attention; The fusion attention is composed of the SE module and the GAM module; The first attention weight weights the output result of the residual path, specifically: The residual path outputs the result through the identity mapping, and the first attention weight weights the output result of the residual path; The second attention weight weights the output results of the main path, specifically: The main path outputs the results through the convolution weight layer, activation layer and convolution weight layer in sequence, and the second attention weight weights the output results of the main path.
2. A classification system for leaf diseases of Cucurbitaceae plants, said system being implemented by the method for classifying leaf diseases of Cucurbitaceae plants according to claim 1, characterized in that: Includes the following modules: The preprocessing module obtains a dataset of images of cucurbitaceae plant leaf diseases and preprocesses them; Build the module and build the ResNet18-AWRB architecture, specifically: The ResNet18-AWRB architecture includes a main path, a residual path, and an attention fusion path; The classification module inputs the dataset of Cucurbitaceae plant leaf disease images into the ResNet18-AWRB architecture and outputs the classification results of Cucurbitaceae plant leaf diseases.
Citation Information
Patent Citations
Camellia oleifera leaf disease identification method and system based on improved ResNet model
CN116612325A
Crop leaf disease identification method and device based on multi-resolution double-path characteristics
CN117689931A