Image processing-based pest and disease identification method and system, and medium

By combining the improved U-Net model and ResNet-50 network with the XGBoost classifier, the problems of time consumption and low accuracy in traditional pest and disease identification methods are solved, achieving efficient and accurate identification of pests and diseases, adapting to complex backgrounds and different growth stages, and meeting the real-time monitoring needs of agricultural production.

CN120932105APending Publication Date: 2025-11-11GUANGDONG AIB POLYTECHNIC COLLEGE
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202511190730.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-25
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing image processing-based pest and disease identification methods rely on human experience, are time-consuming and labor-intensive, and have low accuracy. They are difficult to meet the needs of large-scale, real-time agricultural production. Furthermore, traditional methods do not extract features sufficiently in complex backgrounds, have poor adaptability, and are difficult to accurately identify pests and diseases at different growth stages.

Method used

An improved U-Net model was used to segment lesion regions by combining deep separable convolution and attention gating mechanism. Deep semantic features and lesion color and shape features were extracted by combining a pre-trained ResNet-50 network. An ensemble classifier based on XGBoost was used to identify pests and diseases. Adaptive preprocessing and feature fusion were used to improve the recognition accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of pest and disease identification, enhances adaptability to complex backgrounds and different growth stages, enables real-time identification on ordinary mobile terminals, meets the needs of agricultural production, and provides technical support for precision agriculture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120932105A_ABST
    Figure CN120932105A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a pest and disease identification method and system based on image processing and a medium, and the method comprises the steps: obtaining an original image of a plant leaf, and carrying out the preprocessing of the original image, and obtaining a preprocessed image; performing scab region segmentation on the preprocessed image by using an improved U-Net model to obtain a contour and a position of a scab; carrying out feature extraction on the segmented scab region, extracting deep semantic features through a pre-trained ResNet-50 network, and carrying out splicing fusion on the deep semantic features and color features and shape features of the scab to form a comprehensive feature vector; inputting the comprehensive feature vector into an integrated classifier based on XGBoost to carry out disease and insect pest type identification, and outputting disease and insect pest types and corresponding probabilities; the accuracy of pest and disease prediction can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, specifically to a method, system, and medium for identifying pests and diseases based on image processing. Background Technology

[0002] In the field of image processing-based pest and disease identification, traditional methods often rely on human experience, which is not only time-consuming and labor-intensive, but also susceptible to subjective factors affecting accuracy, making it difficult to meet the needs of large-scale, real-time agricultural production. Meanwhile, some existing automated identification methods suffer from insufficient feature extraction and poor adaptability to complex backgrounds, resulting in room for improvement in identification efficiency and accuracy in practical applications. Furthermore, the morphological characteristics of different pests and diseases vary significantly, and the same pest or disease may exhibit different behaviors at different growth stages, posing further challenges to accurate identification. Summary of the Invention

[0003] To address the aforementioned issues, this invention provides a method, system, and medium for pest and disease identification based on image processing. The aim is to enhance the ability to capture pest and disease features by optimizing the image processing workflow and feature extraction algorithm, thereby improving the system's adaptability to complex backgrounds and pests at different growth stages, ultimately increasing identification efficiency and accuracy to better meet the needs of large-scale, real-time pest and disease monitoring in agricultural production.

[0004] To achieve the above objectives, the present invention provides the following technical solution: On one hand, embodiments of the present invention provide a method for identifying pests and diseases based on image processing, the method comprising the following steps: S100: Acquire the original image of the plant leaf, preprocess the original image, and obtain the preprocessed image; S200, the improved U-Net model is used to segment the lesion region of the preprocessed image to obtain the contour and location of the lesion; the improved U-Net model includes an encoder module and a decoder module. The encoder module adopts a depthwise separable convolutional structure; the decoder module introduces a skip connection optimization mechanism to adaptively fuse the feature maps of different levels of the encoder. S300 extracts features from the segmented lesion region, extracts deep semantic features through a pre-trained ResNet-50 network, and concatenates and fuses them with the color and shape features of the lesion to form a comprehensive feature vector; S400 inputs the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease identification, and outputs the pest and disease category and its corresponding probability.

[0005] Optionally, in S100, acquiring the original image of the plant leaf and preprocessing the original image to obtain a preprocessed image includes: S110, perform grayscale processing on the original image to obtain a grayscale image; S120, adaptive histogram equalization is performed on the grayscale image to obtain an image with enhanced contrast; S130 performs multi-scale Gaussian filtering to denoise the image after contrast enhancement. By constructing Gaussian kernel functions with different standard deviations, the image is processed by layer-by-layer filtering to remove noise interference of different frequencies and preserve the edges of lesions. S140 employs image cropping technology based on superpixel segmentation to automatically crop the background area in the image according to the blade outline, retaining the effective image portion containing the main body of the blade, thus obtaining the preprocessed image.

[0006] Optionally, the improved U-Net model is trained in the following manner: S210, Construct a plant leaf image dataset containing different types of pests and diseases, different shooting environments, and different disease stages. The plant leaf images in the dataset are labeled with the outline of the lesion area and the corresponding pest and disease category label. S220, Construct an improved U-Net model, which includes an encoder module and a decoder module. The encoder module adopts a structure that combines depthwise separable convolution with residual connections, and the decoder module introduces attention gating units on the basis of skip connections. S230: Input the training set images into the U-Net model for iterative training. In each iteration, after performing data augmentation on the input plant leaf images, the model outputs the segmentation results of the lesion region through forward propagation and compares them with the labeled real contours. The loss value is calculated using the hybrid loss function. S240: When the loss value is higher than the loss threshold, the backpropagation algorithm is used to update the model parameters until the loss value of the U-Net model converges to the loss threshold or reaches the preset maximum number of training rounds. Then, training is stopped and the current optimal model parameters are saved to obtain the improved U-Net model. The parameters of the depthwise separable convolutional layer and the residual connection part of the encoder module are optimized by gradient descent, while the parameters of the attention gating unit of the decoder module are adjusted by a separate learning rate.

[0007] Optionally, in S300, the feature extraction of the segmented lesion region involves extracting deep semantic features using a pre-trained ResNet-50 network and concatenating and fusing these features with the color and shape features of the lesion to form a comprehensive feature vector, including: S310, perform region of interest (ROI) cropping on the segmented lesion area to obtain the ROI region; S320 converts the ROI region image into RGB and HSV color spaces, extracts color features, calculates the shape features of the lesion region, and shapes shallow visual features. S330 resizes the ROI region image to the standard input size of the ResNet-50 network, normalizes it, and inputs it into a ResNet-50 network pre-trained on the ImageNet dataset. The last fully connected layer of the network is removed, and the output of the penultimate layer is used as the deep semantic feature vector. S340 aligns shallow visual features with deep semantic features in terms of dimensions and then splices and fuses them to form a comprehensive feature vector.

[0008] Optionally, in S400, the step of inputting the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease type identification and outputting the pest and disease category and corresponding probability includes: S410 inputs the comprehensive feature vector into the XGBoost-based ensemble classifier and outputs the category label of the pest and disease and the corresponding confidence probability. S420: Sort the pest and disease categories according to their confidence probability, and select the category with the highest confidence as the final identification result.

[0009] Optionally, the XGBoost-based ensemble classifier is trained in the following manner: S401, Obtain multiple labeled samples, each labeled sample includes the comprehensive feature vector of the lesion and the corresponding pest and disease category label; S402, the labeled samples are divided into a training set and a validation set, wherein the training set is used for learning model parameters and the validation set is used for evaluating model performance; S403 trains the XGBoost classifier based on the training set, sets the cross-entropy loss function and L2 regularization term, and optimizes the model parameters through the gradient descent algorithm to prevent overfitting; S404, calculate the evaluation results using the validation set, adjust the model parameters based on the evaluation results, iterate and optimize until the model performance meets the expected requirements, and obtain the trained ensemble classifier; wherein, the evaluation results include classification accuracy, recall and F1-scor.

[0010] Optionally, after S400, the method further includes: When the confidence probability is lower than the preset threshold, a secondary verification mechanism is triggered, which calls an additional expert model for verification. The output of the expert model is combined with the original identification result for weighted fusion, and the final pest category and the corrected confidence level are output.

[0011] On the other hand, embodiments of the present invention provide an image processing-based pest and disease identification system, including: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0012] On the other hand, embodiments of the present invention provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the above-described method.

[0013] The beneficial effects of this invention are as follows: This invention discloses a method, system, and medium for pest and disease identification based on image processing. By combining an improved U-Net model with depthwise separable convolution and attention gating mechanisms, this invention reduces the computational complexity of the model while maintaining segmentation accuracy. Furthermore, by fusing deep semantic features extracted by ResNet-50 with shallow visual features such as the color and shape of lesions, it can more comprehensively capture multi-dimensional feature information of pests and diseases, effectively improving the representation ability of lesions at different morphologies and growth stages. In addition, the XGBoost-based ensemble classifier further enhances the model's classification ability and generalization performance for complex features by integrating the decision advantages of multiple weak classifiers, reducing the bias that may exist in single classification models. Therefore, in practical applications, it can more accurately identify the types of pests and diseases, providing timely and effective guidance for pest and disease control in agricultural production. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1 This is a schematic flowchart of an image processing-based pest and disease identification method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of an image processing-based pest and disease identification system according to an embodiment of the present invention. Detailed Implementation

[0016] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.

[0017] In related technologies, image processing-based pest and disease identification mainly relies on manual feature extraction or a single deep learning model, which suffers from insufficient ability to capture complex pest and disease features and susceptibility to environmental interference in recognition accuracy. For example, when plant leaves show multiple pest and disease symptoms simultaneously or when there are interfering factors such as weeds and soil in the background, traditional methods often struggle to accurately segment lesion areas and extract effective features, resulting in low recognition accuracy and robustness.

[0018] Existing pest and disease identification models often employ simple concatenation or weighted summation in the feature fusion stage, failing to fully consider the complementarity of features at different levels. This results in insufficient representation of key pest and disease features by the comprehensive feature vector. Furthermore, traditional classifiers are prone to the curse of dimensionality when handling high-dimensional features and are sensitive to imbalanced samples, limiting their generalization performance in complex real-world scenarios. In addition, some methods use a uniform optimization strategy for encoder and decoder parameters during model training, ignoring the differentiated feature learning needs of different modules, potentially leading to slow convergence or getting stuck in local optima. These issues collectively constrain the overall performance of pest and disease identification systems, making it difficult to effectively address the practical challenges of diverse pest and disease types, similar symptoms, and complex environmental interference in agricultural production.

[0019] refer to Figure 1 ,like Figure 1 The image shown illustrates a pest and disease identification method based on image processing provided by an embodiment of the present invention. The method includes the following steps: S100: Acquire the original image of the plant leaf, preprocess the original image, and obtain the preprocessed image; Specifically, images can be collected using high-definition cameras, drone aerial photography, or mobile terminal photography. When collecting images, it is necessary to ensure that the images are clear, the leaves are not severely obscured, and the complete area containing the symptoms of pests and diseases.

[0020] The acquired raw images are preprocessed. First, the image size is normalized to adjust the image to a preset size to meet the model input requirements. Then, an adaptive histogram equalization algorithm is used to enhance the image contrast and highlight the difference between lesion areas and normal leaf areas. Finally, a wavelet threshold denoising algorithm is used to remove Gaussian noise and salt-and-pepper noise from the image to reduce interference information.

[0021] S200, the improved U-Net model is used to segment the lesion region of the preprocessed image to obtain the contour and location of the lesion; the improved U-Net model includes an encoder module and a decoder module. The encoder module adopts a depthwise separable convolutional structure; the decoder module introduces a skip connection optimization mechanism to adaptively fuse the feature maps of different levels of the encoder. The encoder module replaces traditional convolutional layers with a depthwise separable convolutional structure, reducing the number of parameters while improving feature extraction efficiency. The decoder module introduces a skip connection optimization mechanism, adaptively weighting and fusing feature maps from different encoder levels to enhance the ability to capture details at the edges of lesions. During model training, a weighted combination of the Dice loss function and the cross-entropy loss function is used as the optimization objective to address the imbalance between lesion and background samples. Through these improvements, the model can accurately segment typical disease and pest symptom areas on leaves, such as necrotic spots, insect holes, and mold, thus improving segmentation accuracy.

[0022] An improved U-Net model is used to segment lesion regions in preprocessed images. This model introduces a residual connection module in the encoding stage to deepen the network while avoiding the gradient vanishing problem. In the decoding stage, it combines skip connections and attention gating mechanism to make the model pay more attention to the feature regions of lesions, thereby accurately segmenting the contours and locations of lesions.

[0023] S300 extracts features from the segmented lesion region, extracts deep semantic features through a pre-trained ResNet-50 network, and concatenates and fuses them with the color and shape features of the lesion to form a comprehensive feature vector; Feature extraction is performed on the segmented lesion regions. Deep semantic features are extracted using a pre-trained ResNet-50 network. At the same time, color features (such as RGB mean and HSV components) and shape features (such as area, perimeter, and roundness) of the lesions are extracted. The above multi-dimensional features are then spliced ​​and fused to form a comprehensive feature vector.

[0024] S400 inputs the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease identification, and outputs the pest and disease category and its corresponding probability.

[0025] This ensemble classifier consists of multiple decision tree base classifiers. The weights of each base classifier are optimized through cross-validation, and the final output is the category of pests and diseases and their corresponding probabilities, thus achieving accurate classification of pests and diseases.

[0026] In the embodiments provided by this invention, the organic combination of the above-mentioned technical solutions effectively solves the problems of weak anti-interference ability, incomplete feature extraction, and low recognition accuracy in traditional pest and disease identification methods. In the preprocessing stage, the synergistic effect of adaptive contrast enhancement and multi-scale denoising algorithms can dynamically optimize images under different lighting conditions and shooting environments. For example, in cases where backlighting causes overexposure of leaf edges, local area contrast adjustment can restore lesion details; multi-scale denoising can remove noise particles of different sizes while preserving lesion texture features. In the feature extraction stage, the fusion of convolutional neural networks and attention mechanisms enables the model to automatically focus on the lesion area when processing complex background images. For example, when both insect holes and mold spots exist on the leaf, the attention weights will tilt towards these key feature areas, reducing interference from healthy leaf parts on feature extraction. The feature pyramid network, by integrating shallow edge and texture features with deep semantic features, constructs a richer feature expression space, which helps distinguish different types of pests and diseases with similar symptoms. The ensemble learning strategy of the classification and recognition module enhances the stability of recognition results through the complementarity of multiple basic classifiers. For example, when a classifier makes an error in recognizing a specific pest or disease due to sample distribution bias, the outputs of other classifiers can correct it, thus ensuring the reliability of the overall recognition results. Furthermore, this method optimizes hardware resource consumption. Through lightweight model design, real-time recognition can be achieved on ordinary mobile terminals, meeting the needs of on-site field monitoring. In practical applications, this method can be integrated into agricultural IoT systems, combining environmental data collected by sensors (such as temperature, humidity, and soil pH) to further improve the accuracy of pest and disease prediction, providing comprehensive technical support for the implementation of precision agriculture.

[0027] In some embodiments, in S100, acquiring the original image of the plant leaf and preprocessing the original image to obtain a preprocessed image includes: S110, perform grayscale processing on the original image to obtain a grayscale image; S120, adaptive histogram equalization is performed on the grayscale image to obtain an image with enhanced contrast; S130 performs multi-scale Gaussian filtering to denoise the image after contrast enhancement. By constructing Gaussian kernel functions with different standard deviations, the image is processed by layer-by-layer filtering to remove noise interference of different frequencies and preserve the edges of lesions. S140 employs image cropping technology based on superpixel segmentation to automatically crop the background area in the image according to the blade outline, retaining the effective image portion containing the main body of the blade, thus obtaining the preprocessed image.

[0028] Specifically, in the superpixel segmentation process, the SLIC (Simple Linear Iterative Clustering) algorithm is first used to segment the preprocessed image into several superpixel blocks with similar color and texture features, with each superpixel block serving as a basic processing unit. Next, the average color value of each superpixel block is calculated and compared with a preset leaf color range to initially filter out superpixel blocks that may belong to the leaf region. Subsequently, morphological operations are used to merge the filtered superpixel blocks, filling in holes within the leaf region and removing small, noisy superpixel blocks. Finally, based on the contour of the merged leaf region, the minimum bounding rectangle is determined, and the original image is cropped to obtain a preprocessed image containing only the leaf body, effectively reducing the impact of background interference on subsequent feature extraction.

[0029] In some embodiments, the improved U-Net model is trained in the following manner: S210, Construct a plant leaf image dataset containing different types of pests and diseases, different shooting environments, and different disease stages. The plant leaf images in the dataset are labeled with the outline of the lesion area and the corresponding pest and disease category label. A plant leaf image dataset containing different types of pests and diseases, different shooting environments, and different disease stages was constructed, with the training set, validation set, and test set in a ratio of 7:2:1. The images in the dataset were labeled to accurately delineate the contours of lesions and assign corresponding pest and disease category labels. S220, Construct an improved U-Net model, which includes an encoder module and a decoder module. The encoder module adopts a structure that combines depthwise separable convolution with residual connections, and the decoder module introduces attention gating units on the basis of skip connections. The improved U-Net model includes an encoder module and a decoder module. The encoder module adopts a structure that combines depthwise separable convolution with residual connections. Depthwise separable convolution decomposes standard convolution into depthwise convolution and pointwise convolution, which reduces the amount of computation and expands the receptive field. Residual connections alleviate the gradient vanishing problem during deep network training by using skip paths. The decoder module introduces an attention gating unit on the basis of traditional skip connections. This unit learns the spatial weight distribution of lesion regions and suppresses the interference of background noise on feature fusion, so that the decoder can focus more on the key features of lesion regions. Before model training, the dataset is augmented with operations such as random rotation, horizontal flipping, brightness jitter, and elastic deformation to increase the number of samples and improve the model's generalization ability. During training, a hybrid loss function is used, which is composed of Dice loss, cross-union ratio loss, and edge loss weighted together. Dice loss is used to solve the problem of sample imbalance, cross-union ratio loss improves the segmentation accuracy of lesion regions, and edge loss enhances the model's ability to capture lesion edge details. The learning rate is dynamically adjusted by the Adam optimizer until the loss function value of the model on the validation set tends to stabilize.

[0030] S230: Input the training set images into the U-Net model for iterative training. In each iteration, after performing data augmentation on the input plant leaf images, the model outputs the segmentation results of the lesion region through forward propagation and compares them with the labeled real contours. The loss value is calculated using the hybrid loss function. Specifically, the improved U-Net model parameters were initialized with an initial learning rate of 0.001. The Adam optimizer was used, and the loss function was a weighted sum of the Dice loss function and the cross-entropy loss function, with weight coefficients set to 0.6 and 0.4, respectively. In each iteration, the input image was first subjected to data augmentation operations such as random cropping, color jittering, and Gaussian blur to simulate different shooting environment changes. Then, the lesion region segmentation result output by the model was calculated through forward propagation and compared with the labeled real contours. The loss value was calculated using a hybrid loss function.

[0031] S240: When the loss value is higher than the loss threshold, the backpropagation algorithm is used to update the model parameters until the loss value of the U-Net model converges to the loss threshold or reaches the preset maximum number of training rounds. Then, training is stopped and the current optimal model parameters are saved to obtain the improved U-Net model. The parameters of the depthwise separable convolutional layer and the residual connection part of the encoder module are optimized by gradient descent, while the parameters of the attention gating unit of the decoder module are adjusted by a separate learning rate.

[0032] Specifically, during training, the backpropagation algorithm is used to update the model parameters. The parameters of the depthwise separable convolutional layers and residual connections in the encoder module are optimized using gradient descent, while the parameters of the attention-gated units in the decoder module are adjusted using separate learning rates to balance the training effects of different modules. To avoid overfitting, an early stopping mechanism is introduced during training. When the segmentation intersection-union ratio on the validation set does not improve for 10 consecutive epochs, a learning rate decay strategy is used, reducing the learning rate to 0.5 times its original value. Step S230 is repeated until the model converges or reaches the preset maximum number of training epochs (e.g., 200 epochs). Training is then stopped, and the model parameters with the best performance on the validation set are saved as the improved U-Net model. The improved U-Net model can gradually learn the characteristic distribution patterns of different pest and disease lesions, achieving accurate segmentation of complex lesion regions.

[0033] In some embodiments, in S300, the feature extraction of the segmented lesion region involves extracting deep semantic features using a pre-trained ResNet-50 network and concatenating and fusing these features with the color and shape features of the lesion to form a comprehensive feature vector, including: S310, perform region of interest (ROI) cropping on the segmented lesion area to obtain the ROI region; S320 converts the ROI region image into RGB and HSV color spaces, extracts color features, calculates the shape features of the lesion region, and shapes shallow visual features. S330 resizes the ROI region image to the standard input size of the ResNet-50 network, normalizes it, and inputs it into a ResNet-50 network pre-trained on the ImageNet dataset. The last fully connected layer of the network is removed, and the output of the penultimate layer is used as the deep semantic feature vector. S340 aligns shallow visual features with deep semantic features in terms of dimensions and then splices and fuses them to form a comprehensive feature vector.

[0034] Specifically, the segmented lesion areas are cropped into Regions of Interest (ROIs) to remove background interference, retaining the lesions and a small amount of surrounding normal leaf tissue, resulting in an ROI image. The ROI image is then converted to both RGB and HSV color spaces, and color features are extracted for each: in the RGB space, the mean, variance, and covariance matrices of the R, G, and B channels of the lesion area are calculated; in the HSV space, the histogram distribution features of the hue (H) are extracted, the H channel is divided into 16 bins, and the frequency of each bin is calculated to form a color feature vector. Simultaneously, shape analysis is performed on the contour of the lesion area. Geometric parameters such as perimeter, area, aspect ratio of the circumscribed rectangle, roundness (4π × area / perimeter²), and Euler number are extracted using an edge detection algorithm to construct a shape feature vector. The color and shape feature vectors are then concatenated to form a color-shape feature vector, yielding the shallow visual features. Subsequently, the ROI region images were resized to the standard input size (224×224) of the ResNet-50 network and normalized before being input into a ResNet-50 network pre-trained on the ImageNet dataset. The last fully connected layer was removed, and the output of the penultimate layer was used as the deep semantic feature vector. Finally, the shallow visual features and deep semantic features were dimensionally aligned and concatenated to form a comprehensive feature vector. This vector contains both the intuitive color and shape information of the lesions and abstract semantic features, providing comprehensive data support for subsequent classification and recognition.

[0035] In some embodiments, S400, the step of inputting the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease type identification and outputting the pest and disease category and corresponding probability includes: S410 inputs the comprehensive feature vector into the XGBoost-based ensemble classifier and outputs the category label of the pest and disease and the corresponding confidence probability. S420: Sort the pest and disease categories according to their confidence probability, and select the category with the highest confidence as the final identification result.

[0036] Specifically, the comprehensive feature vector is input into an XGBoost-based ensemble classifier, which consists of multiple independently trained XGBoost base classifiers, each employing a different feature subset and hyperparameter combination. During training, optimal weights are assigned to each base classifier using 5-fold cross-validation. The weights are dynamically adjusted based on each classifier's F1 score on the validation set, with higher F1 scores receiving greater weights. When the comprehensive feature vector is input, each base classifier independently outputs the predicted probability distribution for various pests and diseases. The predicted probabilities from all base classifiers are then weighted and summed according to preset weights to obtain the final comprehensive probability distribution. Based on this comprehensive probability distribution, the corresponding pest and disease category label and the confidence probability for each category are output. To further improve the reliability of the results, the system sorts the confidence probabilities, selects the category with the highest confidence as the final recognition result, and simultaneously outputs the confidence value of this result so that users can evaluate the credibility of the recognition results. If the highest confidence level is lower than the preset threshold (e.g., 70%), the system will indicate that there may be unrecorded pest or disease types or image quality issues, and recommend manual review or re-collection of images.

[0037] In some embodiments, the XGBoost-based ensemble classifier is trained in the following manner: S401, Obtain multiple labeled samples, each labeled sample includes the comprehensive feature vector of the lesion and the corresponding pest and disease category label; S402, the labeled samples are divided into a training set and a validation set, wherein the training set is used for learning model parameters and the validation set is used for evaluating model performance; S403 trains the XGBoost classifier based on the training set, sets the cross-entropy loss function and L2 regularization term, and optimizes the model parameters through the gradient descent algorithm to prevent overfitting; S404, calculate the evaluation results using the validation set, adjust the model parameters based on the evaluation results, iterate and optimize until the model performance meets the expected requirements, and obtain the trained ensemble classifier; wherein, the evaluation results include classification accuracy, recall and F1-scor.

[0038] Specifically, the labeled samples were divided into training and validation sets in an 8:2 ratio. The training set contained common pest and disease samples from various crops (such as rice, wheat, and corn), covering 20 categories including leaf spot, rust, and aphids, with at least 500 samples in each category. The validation set selected data with the same pest and disease category distribution as the training set and was used to monitor overfitting during model training in real time. When training the XGBoost classifier, the objective function was set to the multi-class cross-entropy loss function, and an L2 regularization term (regularization coefficient λ=0.1) and a leaf node limit (max_depth=6) were introduced to control model complexity. A 5-fold cross-validation method was used to divide the training set, and key parameters such as the learning rate (range 0.01-0.3), the number of leaf nodes per tree (range 20-100), and the subsampling ratio (range 0.5-1.0) were optimized through grid search. The optimal parameter combination was finally determined to be a learning rate of 0.1, 50 leaf nodes, and a subsampling ratio of 0.8. During training, classification accuracy, macro-average recall, and F1-score were calculated using the validation set as evaluation metrics. Training was terminated early when the F1-score showed no improvement after five consecutive rounds of validation set testing, and the current optimal model parameters were saved. Testing showed that the trained ensemble classifier achieved an average recognition accuracy of 94.2% for 20 pests and diseases on the test set, with recognition accuracy exceeding 96% for typical pests and diseases such as rice blast and wheat stripe rust, meeting the needs for precise identification in agricultural production.

[0039] In some embodiments, after S400, the method further includes: When the confidence probability is lower than the preset threshold, a secondary verification mechanism is triggered, which calls an additional expert model for verification. The output of the expert model is combined with the original identification result for weighted fusion, and the final pest category and the corrected confidence level are output.

[0040] Specifically, a preset threshold of 0.75 is set. When the confidence probability of the pest / disease category output by the XGBoost-based ensemble classifier falls below this threshold, the system automatically triggers a secondary verification mechanism. At this point, a pre-trained expert model (such as an image classification model based on the Transformer architecture) is invoked to re-analyze the same comprehensive feature vector. This expert model incorporates agricultural expert knowledge rules during its construction, giving it a stronger ability to distinguish blurred lesion features. The category probability distribution output by the expert model is weighted and fused with the probability distribution of the original classifier, with the original classifier weight set to 0.6 and the expert model weight set to 0.4. The final category probability is calculated through a weighted average. If the highest confidence level after fusion is still below 0.6, the sample is marked as "awaiting manual review," and a report containing the lesion image, comprehensive feature vector, and the results of both model recognitions is generated and pushed to the agricultural technician's terminal. Manual review, combined with the actual field conditions, makes the final judgment to ensure the accuracy of low-confidence samples.

[0041] refer to Figure 2 This invention also provides an image processing-based pest and disease identification system, comprising: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0042] The content of the above method embodiments is applicable to this embodiment. The specific functions implemented in this embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments. Therefore, they will not be repeated here.

[0043] Furthermore, one embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions for performing the above-described method.

[0044] It is worth noting that, since the computer-readable storage medium of the present invention is capable of executing the methods of any of the above embodiments, the specific implementation methods and technical effects of the computer-readable storage medium of the present invention can be referred to the specific implementation methods and technical effects of the methods of any of the above embodiments.

[0045] Although the description of this disclosure has been quite detailed and particularly focused on several of the described embodiments, it is not intended to limit itself to any of these details or embodiments or any particular embodiment, but should be considered as effectively covering the intended scope of this disclosure by referring to the appended claims and taking into account the broad possible interpretations of these claims provided by the prior art. Furthermore, the foregoing description of this disclosure with respect to embodiments foreseeable by the inventors is intended to provide a useful description, and non-substantial modifications to this disclosure that have not yet been foreseen may still represent equivalent modifications.

Claims

1. A method for identifying pests and diseases based on image processing, characterized in that, The method includes the following steps: S100: Acquire the original image of the plant leaf, preprocess the original image, and obtain the preprocessed image; S200, the improved U-Net model is used to segment the lesion region of the preprocessed image to obtain the contour and location of the lesion; the improved U-Net model includes an encoder module and a decoder module. The encoder module adopts a depthwise separable convolutional structure; the decoder module introduces a skip connection optimization mechanism to adaptively fuse the feature maps of different levels of the encoder. S300 extracts features from the segmented lesion region, extracts deep semantic features through a pre-trained ResNet-50 network, and concatenates and fuses them with the color and shape features of the lesion to form a comprehensive feature vector; S400 inputs the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease identification, and outputs the pest and disease category and its corresponding probability.

2. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, In step S100, acquiring the original image of the plant leaf and preprocessing the original image to obtain the preprocessed image includes: S110, perform grayscale processing on the original image to obtain a grayscale image; S120, adaptive histogram equalization is performed on the grayscale image to obtain an image with enhanced contrast; S130 performs multi-scale Gaussian filtering to denoise the image after contrast enhancement. By constructing Gaussian kernel functions with different standard deviations, the image is processed by layer-by-layer filtering to remove noise interference of different frequencies and preserve the edges of lesions. S140 employs image cropping technology based on superpixel segmentation to automatically crop the background area in the image according to the blade outline, retaining the effective image portion containing the main body of the blade, thus obtaining the preprocessed image.

3. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, The improved U-Net model was trained in the following way: S210, Construct a plant leaf image dataset containing different types of pests and diseases, different shooting environments, and different disease stages. The plant leaf images in the dataset are labeled with the outline of the lesion area and the corresponding pest and disease category label. S220, Construct an improved U-Net model, which includes an encoder module and a decoder module. The encoder module adopts a structure that combines depthwise separable convolution with residual connections, and the decoder module introduces attention gating units on the basis of skip connections. S230: Input the training set images into the U-Net model for iterative training. In each iteration, after performing data augmentation on the input plant leaf images, the model outputs the segmentation results of the lesion region through forward propagation and compares them with the labeled real contours. The loss value is calculated using the hybrid loss function. S240: When the loss value is higher than the loss threshold, the backpropagation algorithm is used to update the model parameters until the loss value of the U-Net model converges to the loss threshold or reaches the preset maximum number of training rounds. Then, training is stopped and the current optimal model parameters are saved to obtain the improved U-Net model. The parameters of the depthwise separable convolutional layer and the residual connection part of the encoder module are optimized by gradient descent, while the parameters of the attention gating unit of the decoder module are adjusted by a separate learning rate.

4. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, In S300, feature extraction is performed on the segmented lesion region. Deep semantic features are extracted using a pre-trained ResNet-50 network and then concatenated and fused with the color and shape features of the lesions to form a comprehensive feature vector, including: S310, perform region of interest (ROI) cropping on the segmented lesion area to obtain the ROI region; S320 converts the ROI region image into RGB and HSV color spaces, extracts color features, calculates the shape features of the lesion region, and shapes shallow visual features. S330 resizes the ROI region image to the standard input size of the ResNet-50 network, normalizes it, and inputs it into a ResNet-50 network pre-trained on the ImageNet dataset. The last fully connected layer of the network is removed, and the output of the penultimate layer is used as the deep semantic feature vector. S340 aligns shallow visual features with deep semantic features in terms of dimensions and then splices and fuses them to form a comprehensive feature vector.

5. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, In S400, the step of inputting the comprehensive feature vector into an XGBoost-based ensemble classifier for pest and disease type identification and outputting the pest and disease category and corresponding probability includes: S410 inputs the comprehensive feature vector into the XGBoost-based ensemble classifier and outputs the category label of the pest and disease and the corresponding confidence probability. S420: Sort the pest and disease categories according to their confidence probability, and select the category with the highest confidence as the final identification result.

6. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, The XGBoost-based ensemble classifier is trained in the following way: S401, Obtain multiple labeled samples, each labeled sample includes the comprehensive feature vector of the lesion and the corresponding pest and disease category label; S402, the labeled samples are divided into a training set and a validation set, wherein the training set is used for learning model parameters and the validation set is used for evaluating model performance; S403 trains the XGBoost classifier based on the training set, sets the cross-entropy loss function and L2 regularization term, and optimizes the model parameters through the gradient descent algorithm to prevent overfitting; S404, calculate the evaluation results using the validation set, adjust the model parameters based on the evaluation results, iterate and optimize until the model performance meets the expected requirements, and obtain the trained ensemble classifier; wherein, the evaluation results include classification accuracy, recall and F1-scor.

7. The method for identifying pests and diseases based on image processing according to claim 1, characterized in that, Following S400, the method further includes: When the confidence probability is lower than the preset threshold, a secondary verification mechanism is triggered, which calls an additional expert model for verification. The output of the expert model is combined with the original identification result for weighted fusion, and the final pest category and the corrected confidence level are output.

8. A pest and disease identification system based on image processing, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method as described in any one of claims 1 to 7.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.

Citation Information

Cited By

  • Vegetable disease and insect pest image recognition and classification method and device based on feature detection

    CN121121327A

  • Wild rice bacterial leaf blight resistance evaluation method based on RGB-D segmentation and three-dimensional distance measurement

    CN121391851A

  • Pepper disease and insect pest detection method and system based on improved YOLOv11n and storage medium

    CN121414734A

  • Pepper disease and pest detection method and system based on improved YOLOv11n and storage medium

    CN121414734B

  • Walnut tree pest and disease identification method based on image recognition target detection technology

    CN122391901A