Lightweight crop disease recognition method and device based on gradient-guided mixture and wavelet feature enhancement
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ANHUI UNIV
- Filing Date
- 2025-12-22
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]为解决现有技术在小样本适应性、特征表达能力及混合增强精准度上不足的问题,本发明的首要目的在于提供一种在不依赖大量标注数据的前提下有效扩充训练样本,显著提升模型对不同尺度病害的特征捕捉能力,既提升泛化能力,又保障小样本场景下的识别精度的基于梯度引导混合与小波特征增强的轻量级农作物病害识别方法
[0056]由上述技术方案可知,本发明的有益效果为:第一,本发明针对小样本农作物病害识别场景,通过每类随机选取30张构建训练集的数据集构建方式,精准模拟农业场景数据稀缺现状,同时借助Guided-Mix策略实现病斑区域定向混合增强,在不依赖大量标注数据的前提下有效扩充训练样本,为解决小样本、数据不平衡问题提供了适配性强的技术路径;第二,本发明通过离散小波变换拆分低频与高频分量,对低频分量用多分支深度可分离卷积强化粗粒度特征、高频分量用点卷积突出细节特征,再经通道融合实现多尺度特征高效整合,显著提升模型对不同尺度病害的特征捕捉能力,解决传统模型特征表达单一的问题;第三,本发明通过Mix-CE损失函数与动量缓冲机制协同优化模型,Mix-CE 损失使模型充分学习混合样本的病害语义信息,动量缓冲机制通过平滑梯度更新避免训练震荡,二者结合让模型200次增强迭代中稳定收敛,既提升泛化能力,又保障小样本场景下的识别精度;第四,本发明构建的HWFE-MobileViT模型兼顾轻量化与高性能,在保持仅2.50MB参数量的同时,经HWFE模块与MobileViT模块的特征提取优化,可在移动终端部署,实现田间场景下快速、精准的病害诊断,为智慧农业落地提供实用技术支撑。
Smart Images

Figure CN121746792B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent crop disease identification technology, and in particular to a lightweight crop disease identification method and device based on gradient-guided hybridization and wavelet feature enhancement. Background Technology
[0002] Crop diseases are a critical issue affecting global agricultural production. According to data from the Food and Agriculture Organization of the United Nations, approximately 40% of global crops are damaged by pests and diseases each year, resulting in economic losses exceeding US$220 billion. The affected area is projected to increase by 6.2% in 2025 compared to 2024. Furthermore, climate change is driving the spread of diseases to higher latitudes and altitudes, and extreme weather events are further increasing the risk of disease outbreaks. Therefore, developing accurate and efficient methods for disease identification has become an urgent need to ensure agricultural production.
[0003] The development of computer vision technology has provided important support for disease identification. From the early traditional methods that relied on manually designed features combined with classifiers, to the current focus on deep learning, many lightweight identification models have emerged. These models have made breakthroughs in recognition accuracy and lightweight design, but they generally suffer from high requirements for training data. In scenarios with scarce crop disease data and small sample sizes, they are prone to inaccurate identification and underfitting, affecting the effectiveness of practical applications.
[0004] Furthermore, data augmentation is a key technique for alleviating insufficient sample size. Existing methods either fail to substantially optimize image features, making it difficult to guarantee the diversity of model learning; or they require complex model building and training processes, resulting in high application costs. Common mixed sample augmentation methods are also prone to introducing label noise by mixing irrelevant backgrounds, reducing recognition accuracy. Summary of the Invention
[0005] To address the shortcomings of existing technologies in terms of small sample adaptability, feature representation ability, and accuracy of hybrid enhancement, the primary objective of this invention is to provide a lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement that effectively expands training samples without relying on a large amount of labeled data, significantly improves the model's ability to capture features of diseases at different scales, enhances generalization ability, and ensures recognition accuracy in small sample scenarios.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: a lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement, the method comprising the following sequential steps:
[0007] (1) Obtain images of multiple types of crops, select images from each type to construct a small sample training set and test set, and perform preprocessing of uniform size to obtain preprocessed images;
[0008] (2) Using MobileViT as the backbone network, introduce the Haar wavelet frequency enhancement module, i.e., the HWFE module, to construct the HWFE-MobileViT model. The HWFE-MobileViT model includes a primary feature extraction layer, two MobileNetV2 modules, i.e., two MV2 modules, four HWFE modules, three MobileViT modules, and a classifier.
[0009] (3) Input the preprocessed image into the HWFE-MobileViT model for pre-training to obtain the pre-trained HWFE-MobileViT model. Use the gradient-guided fusion sample augmentation method to generate fusion training samples.
[0010] (4) Input the mixed training samples into the pre-trained HWFE-MobileViT model for training to obtain the trained HWFE-MobileViT model; during the training process, the momentum optimization algorithm is used to stabilize the model parameter update process and improve the training effect.
[0011] (5) Input the crop disease image to be identified into the trained HWFE-MobileViT model and output the disease category identification result.
[0012] Step (1) specifically refers to: the multi-category crop images include healthy leaves of rice, rice blast, rice blight, sesame spot disease, and sheath blight; healthy leaves of corn, leaf blight, and images of diseases after stem borer infestation; healthy leaves of apples, black rot, rust, and black spot disease, totaling 12 categories; among them, healthy leaf images serve as negative control samples for disease identification, used to assist the model in learning the feature differences between normal and diseased states, and the remaining 9 categories are disease samples for target identification; in order to construct a small sample training environment, 30 images are randomly selected from all images of each category to form a training set, and the remaining images are used as a test set; the preprocessing refers to: before training and testing, all images are uniformly scaled to a resolution of 256×256 pixels, and the image pixel values are normalized to the [0,1] interval.
[0013] Step (2) specifically refers to: the two MV2 modules include the first MV2 module and the second MV2 module; the four HWFE modules include the first HWFE module, the second HWFE module, the third HWFE module and the fourth HWFE module; and the three MobileViT modules include the first MobileViT module, the second MobileViT module and the third MobileViT module.
[0014] The preprocessed image is first input into a primary feature extraction layer, which uses a 3×3 convolutional layer to capture the basic texture and contour features of the image through convolution operations. Simultaneously, the image resolution is downsampled from 256×256 to 128×128, outputting a first-level feature map with dimensions of 128×128×64. This first-level feature map is then fed into the first MV2 module, which outputs a second-level feature map with dimensions of 128×128×64, achieving efficient feature compression and preservation of key information. Finally, the second-level feature map is input into the first HWFE module. The first-level enhanced feature map, with dimensions of 64×64×128, is output. Its length and width are half that of the second-level feature map, and its number of channels is twice that of the second-level feature map. This first-level enhanced feature map is then fed into the second MV2 module, where continuous downsampling gradually reduces its resolution from 64×64 to 32×32, while simultaneously increasing the number of channels to 256. This outputs a third-level feature map with dimensions of 32×32×256, further compressing the feature dimensions and enhancing disease-related feature information. Subsequently... The third-level feature map is input to the second HWFE module, outputting a second-level enhanced feature map with a dimension of 16×16×512, incorporating richer frequency dimension information into the features. The second-level enhanced feature map is then fed into the first MobileViT module, outputting a first-level global feature map with a dimension of 16×16×512, achieving collaborative modeling of local texture and global structural features. The first-level global feature map is then fed into the third HWFE module, outputting a third-level enhanced feature map with a dimension of 8×8×1024, incorporating more refined disease details into the global features. The third-level enhanced feature map is then fed into the second MobileViT module, outputting a second-level global feature map, further enhancing the global expressive power of the features. The second-level global feature map is then input into the fourth HWFE module, performing a final multi-scale frequency enhancement process, outputting a fourth-level enhanced feature map with a dimension of 8×8×1024, completing the deep optimization of the entire feature chain. The fourth-level enhanced feature map is then fed into the third MobileViT module, outputting a final feature map of 8×8×1024, which is then fed into the classifier. The classifier consists of a 1×1... The system consists of convolutional layers, global average pooling, fully connected layers, and a Softmax function. First, a 1×1 convolutional layer adjusts the number of channels from 1024 to 12 to match the requirements of the 12-class classification task. Then, global average pooling converts the 8×8×12 two-dimensional feature map into a 1×1×12 fixed-length feature vector. Subsequently, a fully connected layer completes the mapping from features to class probabilities. Finally, the Softmax function normalizes the data and outputs the recognition results of 12 types of crop images related to rice, corn, and apples.
[0015] Step (3) specifically refers to: the pre-training is achieved through optimization using the cross-entropy loss function, the formula of which is:
[0016] ;
[0017] In the formula, This represents the HWFE-MobileViT model; This represents the true label of the i-th data item; This represents the i-th input data; N represents the number of input images in each batch;
[0018] Will The input is fed into the pre-trained HWFE-MobileViT model to perform one forward propagation inference. During this process, the 1×1 convolutional layer of the HWFE-MobileViT model's classifier outputs a 3D feature map, and the classifier outputs the predicted scores corresponding to each class. The class with the highest predicted score is taken as the target class. And record the target category The corresponding predicted score is used as ;
[0019] Calculate target category Predicted score The gradient of the last 1×1 convolutional feature map in the HWFE-MobileViT model is used to obtain the feature map weights. :
[0020] ;
[0021] In the formula: Represents the width of the 3D feature map; The height of the three-dimensional feature map; The three-dimensional feature map represents the first On the [number] channel, located at [number] Column, No. The characteristic value of the row position;
[0022] Feature map weights Grad-CAM maps are generated by weighting the 3D feature maps and then applying the ReLU activation function.
[0023] ;
[0024] in, This represents the k-th channel of the 3D feature map; Represents the corresponding target category The resulting Grad-CAM image; This represents the weight value of the k-th channel corresponding to category t; n is the number of channels;
[0025] Processing using guided backpropagation method This process yields a visualization that highlights fine-grained details of crop diseases. The visualization is then fused with the Grad-CAM image through element-wise multiplication to obtain the Guided Grad-CAM image.
[0026] Perform grayscale processing on the Guided Grad-CAM image to convert it into a one-dimensional channel grayscale image; set the grayscale value threshold to 128, and perform binarization processing on the grayscale image, that is, set pixels with grayscale values less than 128 to 0, and set pixels with grayscale values greater than or equal to 128 to 255;
[0027] Subsequently, morphological erosion is used to remove noise from the binarized image, and then morphological dilation is used to preserve the edge information of the lesion region, finally obtaining the lesion region mask;
[0028] Mask the lesion area and Perform a logical AND operation to obtain a segmentation region containing only the diseased area. ;
[0029] Finally, the segmented regions will be... The segmented regions are mixed with corresponding segments from other images in the current training batch to generate mixed training samples; simultaneously, the segmented regions are statistically analyzed. area and area :
[0030] ;
[0031] Where x and y are the x and y coordinate indices of the pixels in the lesion region mask, respectively; M(x,y)=1 indicates that the position (x,y) belongs to the lesion region; M(x,y)=0 indicates that it does not belong to the lesion region. It is an indicator function; its value is 1 when the condition is true, and 0 otherwise.
[0032] ;
[0033] in, for width, for of high;
[0034] Calculate the mixing ratio :
[0035] ;
[0036] Based on the mixing ratio Grad-CAM diagram, Linear interpolation is performed on the true labels to generate mixed labels for the mixed training samples. :
[0037] ;
[0038] in, For the true labels of the Grad-CAM diagram, for The true label.
[0039] Step (4) specifically refers to:
[0040] The pre-trained HWFE-MobileViT model is trained using the Mix-CE loss function. The formula for the Mix-CE loss function is as follows:
[0041] ;
[0042] in, This represents the number of input images per batch; Represents the mixing ratio; This represents the enhanced new sample; This represents a pre-trained HWFE-MobileVit model; Let be the true label of the i-th data; T is a randomly selected positive integer from 1 to N; The true labels for the source images randomly selected in this training batch to provide the lesion regions for blending with the rest of the images;
[0043] During each parameter update, historical gradient information is accumulated using the momentum optimization algorithm to calculate the momentum term for the current iteration. :
[0044] ;
[0045] in, This is the momentum term from the previous iteration; The momentum coefficient; The current gradient is calculated based on the Mix-CE loss;
[0046] Then, update the model parameters:
[0047] ;
[0048] in, These are the updated model parameters; These are the model parameters before the update. The learning rate is 0.001.
[0049] Finally, the above parameter update process is continuously executed in 200 iterations of enhanced training. The momentum mechanism smooths gradient changes and avoids training oscillations. At the same time, the Mix-CE loss function is combined to enable the model to fully learn the disease features in the mixed samples, thereby improving the model's generalization ability and recognition accuracy.
[0050] The first, second, third, and fourth HWFE modules have the same structure. The first HWFE module includes a discrete wavelet transform submodule, a multi-scale feature extraction submodule, a high-frequency component processing submodule, and a feature concatenation submodule.
[0051] The Discrete Wavelet Transform submodule performs a two-dimensional discrete wavelet transform on the input second-level feature map using the Haar wavelet basis, decomposing it into four components. Each component has a length and width that are half the size of the second-level feature map. These four components are low-frequency components, horizontal edge components, vertical edge components, and diagonal edge components, with the horizontal, vertical, and diagonal edge components being high-frequency components. The decomposed low-frequency components are then fed into the multi-scale feature extraction submodule. Through depthwise separable convolutional branches at four scales (5×5, 7×7, 9×9, and 11×11) combined with an identity mapping branch, coarse-grained structural features at multiple scales are captured, outputting enhanced low-frequency features. The length, width, and number of channels of the enhanced low-frequency features are consistent with the input low-frequency components. First, the three high-frequency components—horizontal, vertical, and diagonal edge components—are merged along the channel dimension to form merged high-frequency features. Then, a 1×1... The convolution adjusts the number of channels for merging high-frequency features, outputting enhanced high-frequency features. The length and width of the enhanced high-frequency features are the same as the input single-class high-frequency components, and the number of channels is consistent with that of the low-frequency components. The enhanced low-frequency features and enhanced high-frequency features are concatenated along the channel dimension to form a fused feature. Finally, a 1×1 convolutional layer is used to integrate and optimize the channel information of the fused features to improve the feature representation capability, and finally outputs a 64×64×128 first-level enhanced feature map.
[0052] Another object of the present invention is to provide an electronic device comprising:
[0053] Processor; and
[0054] The memory stores computer program instructions that, when executed by the processor, cause the processor to perform the lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement as described above.
[0055] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, cause the processor to perform the lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement as described above.
[0056] As can be seen from the above technical solution, the beneficial effects of this invention are as follows: First, this invention addresses the scenario of small-sample crop disease identification by constructing a training set by randomly selecting 30 images for each class, accurately simulating the scarcity of agricultural data. Simultaneously, it utilizes the Guided-Mix strategy to achieve targeted mixing enhancement of lesion regions, effectively expanding the training samples without relying on a large amount of labeled data, providing a highly adaptable technical path to solve the problems of small samples and data imbalance. Second, this invention uses discrete wavelet transform to separate low-frequency and high-frequency components. For low-frequency components, multi-branch depthwise separable convolution is used to enhance coarse-grained features, while for high-frequency components, point convolution is used to highlight detailed features. Channel fusion is then used to achieve efficient integration of multi-scale features, significantly improving the model's ability to capture features of diseases at different scales and solving the problem of single feature representation in traditional models. Third, this invention uses the Mix-CE loss function and momentum buffering mechanism to collaboratively optimize the model. The loss mechanism enables the model to fully learn the semantic information of diseases in mixed samples, and the momentum buffer mechanism avoids training oscillations through smooth gradient updates. The combination of these two mechanisms allows the model to converge stably in 200 augmentation iterations, which not only improves the generalization ability but also ensures the recognition accuracy in small sample scenarios. Fourth, the HWFE-MobileViT model constructed in this invention balances lightweight and high performance. While maintaining only 2.50MB of parameters, it can be deployed on mobile terminals through feature extraction optimization by the HWFE module and the MobileViT module, enabling rapid and accurate disease diagnosis in field scenarios and providing practical technical support for the implementation of smart agriculture. Attached Figure Description
[0057] Figure 1 This is a flowchart of the method of the present invention;
[0058] Figure 2 This is a schematic diagram of the HWFE module in this invention;
[0059] Figure 3 This is a structural diagram of the HWFE-MobileViT model in this invention;
[0060] Figure 4 This is a flowchart illustrating the data augmentation and model training using the Guided-Mix strategy in this invention. Detailed Implementation
[0061] like Figure 1As shown, a lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement is presented. The method includes the following sequential steps:
[0062] (1) Obtain images of multiple types of crops, select images from each type to construct a small sample training set and test set, and perform preprocessing of uniform size to obtain preprocessed images;
[0063] (2) Using MobileViT as the backbone network, introduce the Haar wavelet frequency enhancement module, i.e., the HWFE module, to construct the HWFE-MobileViT model. The HWFE-MobileViT model includes a primary feature extraction layer, two MobileNetV2 modules, i.e., two MV2 modules, four HWFE modules, three MobileViT modules, and a classifier.
[0064] (3) Input the preprocessed image into the HWFE-MobileViT model for pre-training to obtain the pre-trained HWFE-MobileViT model. Use the gradient-guided mixed sample augmentation method, i.e., the Guided-Mix strategy, to generate mixed training samples.
[0065] (4) Input the mixed training samples into the pre-trained HWFE-MobileViT model for training to obtain the trained HWFE-MobileViT model; during the training process, the momentum optimization algorithm, i.e. the momentum buffering mechanism, is used to stabilize the model parameter update process and improve the training effect.
[0066] (5) Input the crop disease image to be identified into the trained HWFE-MobileViT model and output the disease category identification result.
[0067] Step (1) specifically refers to: the multi-category crop images include healthy leaves of rice, rice blast, rice blight, sesame spot disease, and sheath blight; healthy leaves of corn, leaf blight, and images of diseases after stem borer infestation; healthy leaves of apples, black rot, rust, and black spot disease, totaling 12 categories; among them, healthy leaf images serve as negative control samples for disease identification, used to assist the model in learning the feature differences between normal and diseased states, and the remaining 9 categories are disease samples for target identification; in order to construct a small sample training environment, 30 images are randomly selected from all images of each category to form a training set, and the remaining images are used as a test set; the preprocessing refers to: before training and testing, all images are uniformly scaled to a resolution of 256×256 pixels, and the image pixel values are normalized to the [0,1] interval.
[0068] like Figure 3As shown, step (2) specifically refers to: the two MV2 modules include the first MV2 module and the second MV2 module; the four HWFE modules include the first HWFE module, the second HWFE module, the third HWFE module and the fourth HWFE module; and the three MobileViT modules include the first MobileViT module, the second MobileViT module and the third MobileViT module.
[0069] The preprocessed image is first input into a primary feature extraction layer, which employs a 3×3 convolutional layer. This layer captures the basic texture and contour features of the image through convolution operations, while simultaneously downsampling the image resolution from 256×256 to 128×128, outputting a first-level feature map with dimensions of 128×128×64. This provides the basic feature support for subsequent lightweight processing. The first-level feature map is then fed into a lightweight convolutional module, the first MV2 module. This module is based on a lightweight design of depthwise separable convolution. Through a combination of "channel-wise convolution and 1×1 point convolution," it deepens feature extraction while reducing the number of computational parameters, outputting a second-level feature map with dimensions of 128×128×64, achieving efficient feature compression. Key information is preserved. To enhance the model's ability to extract multi-scale disease features, the second-level feature map is input into the first HWFE module, outputting a 64×64×128 first-level enhanced feature map. The length and width of the first-level enhanced feature map are half that of the second-level feature map, and the number of channels is twice that of the second-level feature map. The first-level enhanced feature map is then fed into the second MV2 module, continuing the lightweight logic of "channel-wise convolution and 1×1 point convolution." Through continuous downsampling operations, the resolution of the first-level enhanced feature map is gradually reduced from 64×64 to 32×32, while the number of channels is increased to 256, outputting a third-level feature map with a dimension of 32×32×256, further compressing the feature dimension and enhancing the disease features. Relevant feature information; subsequently, the third-level feature map is input into the second HWFE module, which repeats the core process of "wavelet decomposition-splitting enhancement-feature fusion" and outputs a second-level enhanced feature map with a dimension of 16×16×512, incorporating richer frequency dimension information into the features; the second-level enhanced feature map is then fed into the first MobileViT module, which first encodes local spatial information through a 3×3 convolutional layer, and then maps the features to a high-dimensional space through a 1×1 convolutional layer; subsequently, the high-dimensional feature tensor is unfolded into N non-overlapping flattened image patches, each with a size of 2×2, and the association between local and near-range features is strengthened through two Transformer layers. The process strictly maintains the spatial order of image blocks and the arrangement order of pixels within each block to avoid losing spatial location information. Finally, the processed global features are folded back into a two-dimensional tensor, projected to a low-dimensional space through a 1×1 convolutional layer, and fused with the original input features to output a first-level global feature map with a dimension of 16×16×512, realizing the collaborative modeling of local texture and global structural features. The first-level global feature map enters the third HWFE module, where the multi-scale frequency enhancement process is executed again: after decomposing the components through DWT, the structure and details in the global features are precisely enhanced, and after channel integration, a third-level enhanced feature map with a dimension of 8×8×1024 is output, so that more refined disease detail information is incorporated into the global features.The third-level enhanced feature map is fed into the second MobileViT module, which expands the global modeling scope through four Transformer layers, strengthens long-range dependencies between features, and maintains the 8×8×1024 dimension after processing, outputting a second-level global feature map to further enhance the global expressive power of the features. The second-level global feature map is fed into the fourth HWFE module, which performs the final multi-scale frequency enhancement processing: it performs final enhancement on key disease features in the preceding global features, and after integrating channel information through a 1×1 convolution, outputs a fourth-level enhanced feature map with a dimension of 8×8×1024, completing the deep optimization of the full-link features. The fourth-level enhanced feature map is fed into the third MobileViT module, which completes the final global feature integration through three Transformer layers, fully integrating local disease details, multi-scale structures, and global dependencies, outputting a final 8×8×1024 feature map which is then fed into the classifier. The classifier consists of a 1×1 convolutional layer, global average pooling (GAP), and a fully connected layer (FC). The algorithm consists of a Layer and a Softmax function. First, a 1×1 convolutional layer adjusts the number of channels from 1024 to 12 to match the requirements of the 12-class classification task. Then, global average pooling converts the 8×8×12 two-dimensional feature map into a 1×1×12 fixed-length feature vector. Subsequently, a fully connected layer maps the features to class probabilities. Finally, the Softmax function normalizes the data, outputting the recognition results for 12 types of crops, including rice, corn, and apples.
[0070] like Figure 4 As shown, step (3) specifically refers to: the pre-training is achieved through optimization using the cross-entropy loss function, the formula of which is:
[0071] ;
[0072] In the formula, This represents the HWFE-MobileViT model; This represents the true label of the i-th data item; This represents the i-th input data; N represents the number of input images in each batch;
[0073] Will The input is fed into the pre-trained HWFE-MobileViT model to perform one forward propagation inference. During this process, the 1×1 convolutional layer of the HWFE-MobileViT model's classifier outputs a 3D feature map, and the classifier outputs the predicted scores corresponding to each class. The class with the highest predicted score is taken as the target class. And record the target category The corresponding predicted score is used as ;
[0074] Calculate target category Predicted score The gradient of the last 1×1 convolutional feature map in the HWFE-MobileViT model is used to obtain the feature map weights. :
[0075] ;
[0076] In the formula: Represents the width of the 3D feature map; The height of the three-dimensional feature map; The three-dimensional feature map represents the first On the [number] channel, located at [number] Column, No. The characteristic value of the row position;
[0077] Feature map weights Grad-CAM maps are generated by weighting the 3D feature maps and then applying the ReLU activation function.
[0078] ;
[0079] in, This represents the k-th channel of the 3D feature map; Represents the corresponding target category The resulting Grad-CAM image; This represents the weight value of the k-th channel corresponding to category t; n is the number of channels;
[0080] Processing using guided backpropagation method This process yields a visualization that highlights fine-grained details of crop diseases. The visualization is then fused with the Grad-CAM image through element-wise multiplication to obtain the Guided Grad-CAM image.
[0081] Perform grayscale processing on the Guided Grad-CAM image to convert it into a one-dimensional channel grayscale image; set the grayscale value threshold to 128, and perform binarization processing on the grayscale image, that is, set pixels with grayscale values less than 128 to 0, and set pixels with grayscale values greater than or equal to 128 to 255;
[0082] Subsequently, morphological erosion is used to remove noise from the binarized image, and then morphological dilation is used to preserve the edge information of the lesion region, finally obtaining the lesion region mask;
[0083] Mask the lesion area and Perform a logical AND operation to obtain a segmentation region containing only the diseased area. ;
[0084] Finally, the segmented regions will be... The segmented regions are mixed with corresponding segments from other images in the current training batch to generate mixed training samples; simultaneously, the segmented regions are statistically analyzed. area and area :
[0085] ;
[0086] Where x and y are the x and y coordinate indices of the pixels in the lesion region mask, respectively; M(x,y)=1 indicates that the position (x,y) belongs to the lesion region; M(x,y)=0 indicates that it does not belong to the lesion region. It is an indicator function; its value is 1 when the condition is true, and 0 otherwise.
[0087] ;
[0088] in, for width, for of high;
[0089] Calculate the mixing ratio :
[0090] ;
[0091] Based on the mixing ratio Grad-CAM diagram, Linear interpolation is performed on the true labels to generate mixed labels for the mixed training samples. :
[0092] ;
[0093] in, For the true labels of the Grad-CAM diagram, for The true label.
[0094] like Figure 4 As shown, step (4) specifically refers to:
[0095] The pre-trained HWFE-MobileViT model is trained using the Mix-CE loss function. The formula for the Mix-CE loss function is as follows:
[0096] ;
[0097] in, This represents the number of input images per batch; Represents the mixing ratio; This represents the enhanced new sample; This represents a pre-trained HWFE-MobileVit model; Let be the true label of the i-th data; T is a randomly selected positive integer from 1 to N; The true labels for the source images randomly selected in this training batch to provide the lesion regions for blending with the rest of the images;
[0098] During each parameter update, historical gradient information is accumulated using the momentum optimization algorithm to calculate the momentum term for the current iteration. :
[0099] ;
[0100] in, This is the momentum term from the previous iteration; The momentum coefficient; The current gradient is calculated based on the Mix-CE loss;
[0101] Then, update the model parameters:
[0102] ;
[0103] in, These are the updated model parameters; These are the model parameters before the update. The learning rate is 0.001.
[0104] Finally, the above parameter update process is continuously executed in 200 iterations of enhanced training. The momentum mechanism smooths gradient changes and avoids training oscillations. At the same time, the Mix-CE loss function is combined to enable the model to fully learn the disease features in the mixed samples, thereby improving the model's generalization ability and recognition accuracy.
[0105] like Figure 2 As shown, the first, second, third, and fourth HWFE modules have the same structure. The first HWFE module includes a Discrete Wavelet Transform (DWT) submodule, a Multi-Scale Feature Extraction (PKI) submodule, a High-Frequency Component Processing submodule, and a Feature Concatenation submodule.
[0106] The Discrete Wavelet Transform submodule performs a two-dimensional discrete wavelet transform on the input second-level feature map using the Haar wavelet basis, decomposing it into four components. Each component has a length and width that are half the size of the second-level feature map. These four components are low-frequency components (LL), horizontal edge components (LH), vertical edge components (HL), and diagonal edge components (HH). The horizontal, vertical, and diagonal edge components are high-frequency components. The decomposed low-frequency components are then fed into the multi-scale feature extraction submodule. Through depthwise separable convolutional branches at four scales (5×5, 7×7, 9×9, and 11×11), combined with an identity mapping branch, coarse-grained structural features at multiple scales are captured, outputting enhanced low-frequency features. The length, width, and number of channels of the enhanced low-frequency features are consistent with the input low-frequency components. First, the horizontal, vertical, and diagonal edge components are merged along the channel dimension to form merged high-frequency features. Then, a 1×1... The convolution adjusts the number of channels for merging high-frequency features, outputting enhanced high-frequency features. The length and width of the enhanced high-frequency features are the same as the input single-class high-frequency components, and the number of channels is consistent with that of the low-frequency components. The enhanced low-frequency features and enhanced high-frequency features are concatenated along the channel dimension to form a fused feature. Finally, a 1×1 convolutional layer is used to integrate and optimize the channel information of the fused features to improve the feature representation capability, and finally outputs a 64×64×128 first-level enhanced feature map.
[0107] In summary, this invention addresses the scenario of small-sample crop disease identification by constructing a training set using 30 images randomly selected from each class. This accurately simulates the scarcity of data in agricultural scenarios. Simultaneously, it utilizes a Guided-Mix strategy to achieve targeted hybrid enhancement of lesion regions, effectively expanding the training samples without relying on a large amount of labeled data. This provides a highly adaptable technical path for solving the problems of small samples and data imbalance. Furthermore, this invention separates low-frequency and high-frequency components using discrete wavelet transform. For low-frequency components, multi-branch depthwise separable convolution is used to enhance coarse-grained features, while for high-frequency components, point convolution is used to highlight detailed features. Channel fusion is then used to achieve efficient integration of multi-scale features, significantly improving the model's ability to capture features of diseases at different scales and solving the problem of single feature representation in traditional models. Finally, this invention uses the Mix-CE loss function and momentum buffering mechanism to collaboratively optimize the model. The loss mechanism enables the model to fully learn the semantic information of diseases in mixed samples, while the momentum mechanism avoids training oscillations through smooth gradient updates. The combination of these two mechanisms allows the model to converge stably in 200 augmentation iterations, improving generalization ability while ensuring recognition accuracy in small sample scenarios. The HWFE-MobileViT model constructed in this invention balances lightweight design and high performance. While maintaining only 2.50MB of parameters, it can be deployed on mobile terminals through feature extraction optimization by the HWFE and MobileViT modules, enabling rapid and accurate disease diagnosis in field scenarios and providing practical technical support for the implementation of smart agriculture.
[0108] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement, characterized in that: The method includes the following steps in sequence: (1) Obtain images of multiple types of crops, select images from each type to construct a small sample training set and test set, and perform preprocessing of uniform size to obtain preprocessed images; (2) Using MobileViT as the backbone network, introduce the Haar wavelet frequency enhancement module, i.e., the HWFE module, to construct the HWFE-MobileViT model. The HWFE-MobileViT model includes a primary feature extraction layer, a first MV2 module, a second MV2 module, a first HWFE module, a second HWFE module, a third HWFE module, a fourth HWFE module, a first MobileViT module, a second MobileViT module, a third MobileViT module, and a classifier. The primary feature extraction layer outputs a first-level feature map, which is then fed into the first MV2 module. The first MV2 module outputs a second-level feature map, which is fed into the first HWFE module. The first HWFE module outputs a first-level enhanced feature map, which is fed into the second MV2 module. The second MV2 module outputs a third-level feature map, which is fed into the second HWFE module. The second HWFE module outputs a second-level enhanced feature map, which is fed into the first MobileViT module. The first MobileViT module outputs a first-level global feature map, which is fed into the third HWFE module. The third HWFE module outputs a third-level enhanced feature map, which is fed into the second MobileViT module. The second MobileViT module outputs a second-level global feature map, which is fed into the fourth HWFE module. The fourth HWFE module outputs a fourth-level enhanced feature map, which is fed into the third MobileViT module. The third MobileViT module outputs the final feature map, which is then fed into the classifier. The first, second, third, and fourth HWFE modules have the same structure. The first HWFE module includes a discrete wavelet transform submodule, a multi-scale feature extraction submodule, a high-frequency component processing submodule, and a feature concatenation submodule. The discrete wavelet transform submodule performs a two-dimensional discrete wavelet transform on the input second-level feature map using the Haar wavelet basis, decomposing it into four types of components. The length and width of each type of component are half of the second-level feature map. The four types of components are low-frequency components, horizontal edge components, vertical edge components, and diagonal edge components. The horizontal edge components, vertical edge components, and diagonal edge components are high-frequency components. The decomposed low-frequency components are then fed into the multi-scale feature extraction submodule, which processes them using 5×5 and 7×7... The system employs four depthwise separable convolutional branches at four scales: 9×9, 11×11, and 9×9, combined with an identity mapping branch, to capture multi-scale coarse-grained structural features and output enhanced low-frequency features. The length, width, and number of channels of the enhanced low-frequency features are consistent with the input low-frequency components. First, the three types of high-frequency components—horizontal edge components, vertical edge components, and diagonal edge components—are merged along the channel dimension to form merged high-frequency features. Then, a 1×1 convolution is used to adjust the number of channels of the merged high-frequency features, outputting enhanced high-frequency features. The length and width of the enhanced high-frequency features are the same as the input single-type high-frequency components, and the number of channels is consistent with the low-frequency components. Finally, the enhanced low-frequency features and enhanced high-frequency features are concatenated along the channel dimension to form fused features. Finally, a 1×1 convolutional layer is used to integrate and optimize the channel information of the fused features to improve the feature representation capability, and finally output the first-level enhanced feature map. (3) Input the preprocessed image into the HWFE-MobileViT model for pre-training to obtain the pre-trained HWFE-MobileViT model. Use the gradient-guided fusion sample augmentation method to generate fusion training samples. (4) Input the mixed training samples into the pre-trained HWFE-MobileViT model for training to obtain the trained HWFE-MobileViT model; during the training process, the momentum optimization algorithm is used to stabilize the model parameter update process and improve the training effect. (5) Input the crop disease image to be identified into the trained HWFE-MobileViT model and output the disease category identification result.
2. The lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement according to claim 1, characterized in that: Step (1) specifically refers to: the multi-category crop images include healthy leaves of rice, rice blast, rice blight, sesame spot disease, and sheath blight; healthy leaves of corn, leaf blight, and images of diseases after stem borer infestation; healthy leaves of apples, black rot, rust, and black spot disease, totaling 12 categories; among them, healthy leaf images serve as negative control samples for disease identification, used to assist the model in learning the feature differences between normal and diseased states, and the remaining 9 categories are disease samples for target identification; in order to construct a small sample training environment, 30 images are randomly selected from all images of each category to form a training set, and the remaining images are used as a test set; the preprocessing refers to: before training and testing, all images are uniformly scaled to a resolution of 256×256 pixels, and the image pixel values are normalized to the [0,1] interval.
3. The lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement according to claim 1, characterized in that: Step (2) specifically refers to: The preprocessed image is first input into the primary feature extraction layer, which uses a 3×3 convolutional layer to capture the basic texture and contour features of the image through convolution operations. At the same time, the image resolution is downsampled from 256×256 to 128×128, and the output dimension is 128×128×64. The first-level feature map is fed into the first MV2 module, which outputs a second-level feature map with a dimension of 128×128×64, achieving efficient feature compression and preservation of key information. The second-level feature map is then input into the first HWFE module, which outputs a 64×64×128 first-level enhanced feature map. The length and width of the first-level enhanced feature map are half that of the second-level feature map, and the number of channels is twice that of the second-level feature map. The first-level enhanced feature map is fed into the second MV2 module. Through continuous downsampling operations, the resolution of the first-level enhanced feature map is gradually reduced from 64×64 to 32×32, while the number of channels is increased to 256. The output is a third-level feature map with a dimension of 32×32×256, which further compresses the feature dimension and enhances the disease-related feature information. Subsequently, the third-level feature map is input into the second HWFE module, which outputs a second-level enhanced feature map with a dimension of 16×16×512, incorporating richer frequency dimension information into the features. The second-level enhanced feature map is then fed into the first MobileViT module, which outputs a first-level global feature map with a dimension of 16×16×512, achieving collaborative modeling of local texture and global structural features. The first-level global feature map is then fed into the third HWFE module, which outputs a third-level enhanced feature map with a dimension of 8×8×1024, incorporating more refined disease details into the global features. The third-level enhanced feature map is then fed into the second MobileViT module, which outputs a second-level global feature map, further enhancing the global expressive power of the features. Finally, the second-level global feature map is input into the fourth HWFE module, which performs a final multi-scale frequency enhancement process, outputting a fourth-level enhanced feature map, completing the deep optimization of the entire feature chain. The fourth-level enhanced feature map is fed into the third MobileViT module, and the final output feature map is fed into the classifier. The classifier consists of a 1×1 convolutional layer, global average pooling, a fully connected layer, and a Softmax function. First, the number of channels is adjusted to 12 through a 1×1 convolutional layer to match the requirements of the 12-class classification task. Then, global average pooling is used to convert the two-dimensional feature map into a fixed-length feature vector of 1×1×12. Subsequently, the fully connected layer completes the mapping from features to class probabilities. Finally, the Softmax function is used for normalization to output the recognition results of 12 types of crop images related to rice, corn, and apple.
4. The lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement according to claim 1, characterized in that: Step (3) specifically refers to: the pre-training is achieved through optimization using the cross-entropy loss function, the formula of which is: ; In the formula, This represents the HWFE-MobileViT model; This represents the true label of the i-th data item; This represents the i-th input data; N represents the number of input images in each batch; Will The input is fed into the pre-trained HWFE-MobileViT model to perform one forward propagation inference. During this process, the 1×1 convolutional layer of the HWFE-MobileViT model's classifier outputs a 3D feature map, and the classifier outputs the predicted scores corresponding to each class. The class with the highest predicted score is taken as the target class. And record the target category The corresponding predicted score is used as ; Calculate target category Predicted score The gradient of the last 1×1 convolutional feature map in the HWFE-MobileViT model is used to obtain the feature map weights. : ; In the formula: Represents the width of the 3D feature map; The height of the three-dimensional feature map; The three-dimensional feature map represents the first On the [number] channel, located at [number] Column, No. The characteristic value of the row position; Feature map weights Grad-CAM maps are generated by weighting the 3D feature maps and then applying the ReLU activation function. ; in, This represents the k-th channel of the 3D feature map; Represents the corresponding target category The resulting Grad-CAM image; This represents the weight value of the k-th channel corresponding to category t; n is the number of channels; Processing using guided backpropagation method This process yields a visualization that highlights fine-grained details of crop diseases. The visualization is then fused with the Grad-CAM image through element-wise multiplication to obtain the Guided Grad-CAM image. Perform grayscale processing on the Guided Grad-CAM image to convert it into a one-dimensional channel grayscale image; set the grayscale value threshold to 128, and perform binarization processing on the grayscale image, that is, set pixels with grayscale values less than 128 to 0, and set pixels with grayscale values greater than or equal to 128 to 255; Subsequently, morphological erosion is used to remove noise from the binarized image, and then morphological dilation is used to preserve the edge information of the lesion region, finally obtaining the lesion region mask; Mask the lesion area and Perform a logical AND operation to obtain a segmentation region containing only the diseased area. ; Finally, the segmented regions will be... The segmented regions are mixed with corresponding segments from other images in the current training batch to generate mixed training samples; simultaneously, the segmented regions are statistically analyzed. area and area : ; Where x and y are the x and y coordinate indices of the pixels in the lesion region mask, respectively; M(x,y)=1 indicates that the position (x,y) belongs to the lesion region; M(x,y)=0 indicates that it does not belong to the lesion region. It is an indicator function; its value is 1 when the condition is true, and 0 otherwise. ; in, for width, for of high; Calculate the mixing ratio : ; Based on the mixing ratio Grad-CAM diagram, Linear interpolation is performed on the true labels to generate mixed labels for the mixed training samples. : ; in, For the true labels of the Grad-CAM diagram, for The true label.
5. The lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement according to claim 1, characterized in that: Step (4) specifically refers to: The pre-trained HWFE-MobileViT model is trained using the Mix-CE loss function. The formula for the Mix-CE loss function is as follows: ; in, This represents the number of input images per batch; Represents the mixing ratio; This represents the enhanced new sample; This represents a pre-trained HWFE-MobileVit model; Let be the true label of the i-th data; T is a randomly selected positive integer from 1 to N; The true labels for the source images randomly selected in this training batch to provide the lesion regions for blending with the rest of the images; During each parameter update, historical gradient information is accumulated using the momentum optimization algorithm to calculate the momentum term for the current iteration. : ; in, This is the momentum term from the previous iteration; The momentum coefficient; The current gradient is calculated based on the Mix-CE loss; Then, update the model parameters: ; in, These are the updated model parameters; These are the model parameters before the update. The learning rate is 0.
001. Finally, the above parameter update process is continuously executed in 200 iterations of enhanced training. The momentum mechanism smooths gradient changes and avoids training oscillations. At the same time, the Mix-CE loss function is combined to enable the model to fully learn the disease features in the mixed samples, thereby improving the model's generalization ability and recognition accuracy.
6. An electronic device, comprising: processor; as well as A memory storing computer program instructions, which, when executed by the processor, cause the processor to perform the lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement as described in any one of claims 1-5.
7. A computer-readable storage medium having stored thereon computer program instructions, which, when executed by a processor, cause the processor to perform the lightweight crop disease identification method based on gradient-guided hybridization and wavelet feature enhancement as described in any one of claims 1-5.
Citation Information
Patent Citations
Pavement crack semantic segmentation method based on Transform and CNN architecture
CN120807916A
Machine-learning algorithms for low-power applications
US20250200927A1