A light wheat disease image recognition method for intelligent terminal in complex background
By constructing the SlimRepGhostNet model and combining it with knowledge distillation and the AdamW optimizer, the problem of lightweight wheat disease image recognition under complex backgrounds was solved, and efficient and accurate recognition was achieved on smart terminals.
Patent Information
- Application Number
- CN202411355090.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Existing technologies struggle to achieve high-precision, lightweight identification of wheat disease images in complex environments, especially in natural settings where complex backgrounds and uneven lighting conditions prevent sufficient validation of the effectiveness of lightweight models.
ResNeSt50 was used as the teacher model and RepGhostNet as the student model. By combining the knowledge distillation strategy and the LeakyReLU function, a lightweight wheat disease identification model was trained through feature distillation and the AdamW optimizer. The SlimRepGhostNet model was then constructed to achieve high-precision identification on smart terminals.
High-precision identification of wheat disease severity was achieved on mobile devices, improving the model's response speed and robustness, overcoming the challenges of high deployment costs and identification in complex environments, and enhancing the model's accuracy and adaptability.
Smart Images

Figure CN119314044B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of wheat disease image recognition, in particular to a lightweight wheat disease image recognition method for intelligent terminal in complex background. BACKGROUND
[0002] With the progress of artificial intelligence, digital image processing and machine learning methods have been widely used in crop disease classification and severity assessment. Artificial intelligence technology has the characteristics of low operation requirement, cost-effectiveness, high efficiency and strong versatility, which promotes the research and development of RGB image-based in the field of agriculture.
[0003] In recent years, as a new branch of machine learning, deep learning has made significant progress in crop disease identification, target detection and severity assessment. However, in the field of high-precision severity assessment, high-complexity convolutional network structures are often used for estimation, or image segmentation techniques are used to extract vegetation and disease areas before estimation to avoid the influence of complex background. Although these techniques have promoted the development of crop disease severity monitoring to some extent, there are still many problems to be overcome in model deployment, which brings great challenges to its practical application.
[0004] For lightweight models that are easy to deploy, due to accuracy issues, they are often used for disease severity detection in simple backgrounds, and in natural environments, due to complex background and uneven lighting, their effectiveness cannot be fully verified.
[0005] Therefore, how to design a high-precision lightweight wheat disease image recognition method in complex background has become a technical problem that needs to be solved urgently. SUMMARY
[0006] The purpose of the present application is to solve the problem of lightweight design of wheat disease image recognition in complex background in the prior art, and to provide a lightweight wheat disease image recognition method for intelligent terminal in complex background to solve the above problems.
[0007] In order to achieve the above purpose, the technical scheme of the present application is as follows:
[0008] A lightweight wheat disease image recognition method for intelligent terminal in complex background, comprising the following steps:
[0009] Obtain the wheat disease image dataset: obtain the wheat images taken by the intelligent terminal at different times, weather, environment and growth stages, which include healthy wheat and artificially inoculated disease wheat images, form a wheat scab disease image set, and perform expansion, enhancement preprocessing operation;
[0010] Constructing a lightweight wheat disease identification model: using a ResNeSt50 model as a teacher model and an improved RepGhostNet as a student model to construct a lightweight wheat disease identification model;
[0011] Training of the lightweight wheat disease identification model: based on the preprocessed wheat disease image set, the knowledge distillation strategy is adopted to train the lightweight wheat disease identification model;
[0012] Acquisition of the wheat disease image to be identified: acquiring the wheat disease image to be identified and preprocessing it;
[0013] Identification of the wheat disease image: inputting the preprocessed wheat disease image to be identified into the trained lightweight wheat disease detection model to obtain the wheat disease image identification result.
[0014] Constructing a lightweight wheat disease identification model includes the following steps:
[0015] Setting the lightweight wheat disease identification model includes a teacher model and a student model, wherein the teacher model adopts a ResNeSt50 model, and the student model adopts a RepGhostNet framework; an output of a feature map is added at the end of the feature extraction layer of the teacher model and the student model, and the feature maps of RepGhostNet and ResNeSt50 are output respectively, wherein the output of ResNeSt50 is used as a reference for the student model to learn in the distillation process, and the output of RepGhostNet is used to generate the feature map of the teacher model to calculate the distillation loss;
[0016] Setting the teacher model;
[0017] The teacher model is used to guide the training of the student model, and ResNeSt50 adopts a ResNeSt Block structure to stack, divides the input feature map into K main groups, then divides each main group into R secondary groups, performs convolution processing on the secondary groups, and then inputs them into a Split-Attention Block calculation unit for weighted operation, and finally splices all the main groups through Concatenate;
[0018] Setting the student model;
[0019] Setting that the RepGhostNet is composed of multiple RepGhost Bottleneck and is divided into 5 stages, the dense convolution layer uses 16 channels to process the input data, and a normal 1x1 convolution and an average pooling stack are used to predict the final output;
[0020] The RepGhost Bottleneck is divided into 5 groups, and the last Bottleneck in each group is set to stride = 2, except for the last Bottleneck,
[0021] The first layer of the stage2 part of the RepGhosNet is removed from the RepGhost-Bottleneck module, and the second and third layers of the RepGhost-Bottleneck module are removed in the stage4 part of the RepGhosNet;
[0022] The LeakyReLU function is used as the activation function f(x), and its expression is as follows:
[0023]
[0024] Where x is the input feature data, and alpha is a positive number close to 0.
[0025] The training of the lightweight wheat disease identification model includes the following steps:
[0026] The optimizer is set as follows:
[0027] AdamW is used as the optimizer of the lightweight wheat disease identification model, combined with the cosine annealing algorithm for adjusting the learning rate and class balance loss strategy to balance the influence caused by the uneven number of different disease degree images, and the cosine annealing algorithm is used to calculate the loss value of the training process to optimize the model;
[0028] AdamW is set to accelerate gradient descent through two momentum parameters β1 and β2, and in the weight decay processing, AdamW adds an additional L2 regular, separates the weight decay and gradient update processing, so that the weight decay is only used for weight parameters, not directly used for gradient update, to avoid the influence of bias parameters, and the specific calculation method is as follows:
[0029] m t = β1m t-1 + (1-β1)g t
[0030]
[0031] Where t is the training step number, β1 and β2 are manually adjusted momentum parameters, g represents the gradient, m and v are first and second order momentum estimates, respectively, m t and v t represent the results of two momentum bias correction, θ represents the parameter, γ is the learning rate, λ is the weight decay coefficient, and ∈ is a constant close to 0 to avoid the denominator being 0;
[0032] The teacher model is trained:
[0033] The pre-processed disease image size is adjusted to 244x244x3 during the teacher model training process, the initial learning rate is set to 0.001, the momentum is 0.937, and the weight decay is 0.0005; the training process is performed for a total of 100 iteration cycles, a warm-up stage is enabled during the training process, the minimum learning rate for warm-up is 1x10 -6 , the warm-up rate is 5%, and the specific training process is as follows:
[0034] The input layer reads image data, converts the image data into a feature array structure for initialization, and then submits the data to the feature extraction layer;
[0035] The feature extraction layer extracts high-dimensional disease features through a large number of convolution operations on feature data, and is composed of multiple ResNeSt Block stacks. After the feature image is input into the ResNeSt Block, the feature image is first grouped into K main groups, and then each main group is further divided into R secondary groups; secondly, for each secondary group, a high-dimensional feature is obtained through a feature extraction operation unit composed of multiple convolution operations; then the R feature secondary groups are weighted and operated through the SplitAttention module to aggregate the feature data, and the K main groups are aggregated through the Concatenate operation; finally, the SE attention module is used to weight and operate each feature channel of the feature data to obtain the output feature map T;
[0036] The output layer performs downsampling operation on the obtained high-dimensional disease feature image through simple convolution operation to obtain classification result, and calculates classification loss L through the classification result;
[0037] Finally, the ResNeSt50 model is updated through the classification loss L, and then the next batch of training is performed to obtain a teacher model capable of accurately identifying the degree of wheat disease;
[0038] Student model training:
[0039] The trained teacher model is enabled in prediction mode to extract features from the input pre-processed wheat disease image, and output the feature map T obtained by the feature extraction layer as the target image of the distillation process;
[0040] The student model is enabled in training mode to process the input image, and output the feature map S obtained by the feature extraction layer and the disease severity classification result of the student model;
[0041] The classification loss L of the model is calculated according to the classification result of the student model original ;
[0042] According to the feature maps T and S of the teacher model and the student model, a distillation loss L of the mask generation distillation is obtained dis ;
[0043] According to the distillation loss L of the mask generation distillation dis and the classification loss L original , a total loss L of the feature distillation calculation model training is carried out all ;
[0044] Feature distillation process:
[0045] Teacher and student feature maps are represented by T l ∈R C×H×W and S l ∈R C×H×W respectively, where l = 1,..,L,
[0046] The lth random mask is set to cover the lth feature of the student, which is represented as:
[0047]
[0048] Student wheat disease feature map mask is generated
[0049] Where l represents the lth wheat disease feature map, i and j represent the length and width of each feature channel of the teacher feature map respectively, R i,j is a random number between 0 and 1 following uniform distribution, λ is a hyperparameter representing the mask ratio, C, H, W represent the shape of the feature map;
[0050] The lth wheat disease feature map mask is used to cover the lth student wheat disease feature map, and the left pixel is used to generate the teacher wheat disease feature map:
[0051]
[0052] The teacher model feature map is generated by the student feature map, and the result of the teacher model is generated by using a small amount of disease features extracted by the student model.
[0053] Specifically, it includes: adopting an adaptive layer f align of a 1x1 convolution to adapt the feature dimension of the student feature S to the teacher feature T; adopting a point-by-point manner to mask the adapted student feature to obtain F; and generating the teacher feature map through a convolution structure including two convolution layers W l1 , w l2 and a projection layer of an activation layer ReLU.
[0054] The distillation loss calculation of the whole mask generation distillation method is as follows:
[0055]
[0056] The distillation loss L is calculated by point-by-point subtraction dis wherein L represents the total number of feature maps for distillation, C, H, W represent the shape of the feature map, and S and T represent the student and teacher features, respectively, represents the projection layer, L dis represents the distillation loss of training, is a student wheat disease feature map mask;
[0057] The total loss is calculated as follows:
[0058] L all = L original + a·L dis
[0059] The total loss L of the training process is calculated by a weighted operation all wherein L original is the original loss of the model in all tasks, and a is a hyperparameter for balancing the loss value;
[0060] Then, the total loss L all is used to update the student model RepGhostNet, the updated model is used for experimental training, and the disease severity of wheat in the wheat disease image is obtained.
[0061] Advantages
[0062] Compared with the prior art, the lightweight wheat disease image recognition method for intelligent terminal in a complex background can realize high-precision disease degree recognition while being flexibly deployed on a mobile device, the model structure is compressed, the model is optimized using LeakyReLU and AdamW optimizer, the response speed of the model is improved, the feature extraction result of a high-complexity model is learned in a knowledge distillation manner, the accuracy and robustness of the model are improved, and finally the wheat disease degree is efficiently and accurately recognized on a mobile device.
[0063] The application applies a deep learning method to wheat disease grade detection under natural conditions, adopts a lightweight deep learning method, and uses a mobile device to detect in different natural environment conditions, effectively overcoming the problems of low artificial detection efficiency and high experience requirement, and overcoming the problem of high deployment cost.
[0064] The application is improved based on the RepGhostNet model as a basic model, and the model has better classification effect and higher classification efficiency among numerous lightweight convolution structures, and has the best comprehensive performance. Meanwhile, the basic model is improved by simplifying the model structure and using the method of LeakyReLU and AdamW optimizer to obtain SlimRepGhostNet, and the comprehensive performance of the model is further improved.
[0065] The application adopts a masking generation distillation strategy to train the improved SlimRepGhostNet, masks random pixels of student features, and forces the student model to generate complete features of the teacher model through a simple block, so that the accuracy of the lightweight model training result can be comparable to that of a high complexity model, and the model can adapt to the detection task of images in complex natural environment. BRIEF DESCRIPTION OF DRAWINGS
[0066] Figure 1 The method sequence diagram of the application is shown in the figure;
[0067] Figure 2 The model structure diagram of the improved SlimRepGhostNet is shown in the figure;
[0068] Figure 3 The processing process diagram of the masking generation distillation strategy is shown in the figure;
[0069] Figure 4 The classification ability comparison diagram of the improved model is shown in the figure. DETAILED DESCRIPTION
[0070] In order to have a further understanding and understanding of the structural characteristics and effects achieved by the application, the preferred embodiments and the accompanying drawings are used for detailed description as follows:
[0071] As shown in the figure, Figure 1 The application provides a lightweight wheat disease image recognition method in a complex background of an intelligent terminal, which comprises the following steps:
[0072] Firstly, a wheat disease image dataset is obtained: wheat images of different times, weather, environment and growth stages taken by an intelligent terminal are obtained, which include healthy wheat and artificially inoculated wheat images, forming a wheat scab disease image set, and the collected wheat images are labeled according to the standard of the General Administration of Quality Supervision, Inspection and Quarantine; the labeled data is processed by non-repeated combination operation to expand the dataset in a combined enhancement manner, so as to simulate complex images in a real agricultural environment; the enhanced wheat images are divided into a training set, a verification set and a test set in a ratio of 6:2:2, which are respectively used for model training, model generalization evaluation and evaluation of model performance.
[0073] Second step, building a lightweight wheat disease recognition model: using ResNeSt50 model as teacher model, using improved RepGhostNet as student model, building a lightweight wheat disease recognition model.
[0074] The Split-Attention module in ResNeSt50 integrates cross-channel attention mechanism while maintaining the simplicity of ResNet architecture without introducing additional computational cost. This approach not only achieves high accuracy in ResNeSt50, but also makes it very suitable as a teacher model in the masking generation distillation.
[0075] The RepGhost module in RepGhostNet model achieves efficient use of hardware through reparameterization technology, avoiding the additional computational cost caused by traditional concat operation, thereby improving computational efficiency, achieving less parameters and shorter delay on mobile devices, while maintaining high accuracy performance, which is very suitable for deployment on mobile intelligent devices with limited hardware resources, and is very suitable as a student model.
[0076] (1) Set the lightweight wheat disease recognition model to include teacher model and student model, where the teacher model uses ResNeSt50 model and the student model uses RepGhostNet as the framework; add an output of feature map at the end of the feature extraction layer of the teacher model and the student model, respectively output the feature map of ResNeSt50 and RepGhostNet, where the output of ResNeSt50 is used as the reference for the student model learning in the distillation process, and the output of RepGhostNet is used to generate the feature map of the teacher model to calculate the distillation loss.
[0077] (2) Set the teacher model;
[0078] The teacher model is used to guide the training of the student model. ResNeSt50 uses ResNeSt Block structure stacking to divide the input feature map into K main groups, then divide each main group into R secondary groups, perform convolution processing on the secondary groups, then input into the Split-Attention Block calculation unit for weighted operation, and finally concatenate to combine all the main groups.
[0079] (3) Set the student model;
[0080] Set RepGhostNet to be composed of multiple RepGhost Bottleneck, which is divided into 5 stages, and the dense convolution layer uses 16 channels to process the input data, and a normal 1x1 convolution and average pooling stack is used to predict the final output.
[0081] RepGhost Bottleneck is divided into 5 groups, and the last Bottleneck of each group is set stride = 2, except the last Bottleneck,
[0082] Remove the first layer of the RepGhost-Bottleneck module in the stage2 part of RepGhosNet, and remove the second and third layers of the RepGhost-Bottleneck module in the stage4 part of RepGhosNet; Figure 2 The structure of the simplified SlimRepGhostNet model is shown.
[0083] The LeakyReLU function is used as the activation function f(x), and its expression is as follows:
[0084]
[0085] Where x is the input feature data, and a is a positive number close to 0.
[0086] Third, training of the lightweight wheat disease identification model: based on the preprocessed wheat disease image set, the lightweight wheat disease identification model is trained using the knowledge distillation strategy. Traditional deep learning models have high accuracy but have large model parameter quantities and high complexity, while lightweight models have fast recognition speed but generally have low model accuracy. Therefore, the knowledge distillation strategy is used to let the lightweight model learn the features learned by the high-precision model, thereby improving the model's accuracy without significantly affecting the model's recognition speed. The masking generation distillation strategy is used, which first randomly masks the student's feature pixels, and then uses the masked features to generate the teacher's complete features through a simple module, thereby improving the student's representation ability. Since random pixels are used in each iteration, all pixels are used during training, which means that the features learned by the student model RepGhostNet will be more robust, and its representation ability will also be improved, thereby improving the model's recognition ability, Figure 3 The process of the masking generation distillation.
[0087] (1) Set the optimizer:
[0088] AdamW is used as the optimizer of the lightweight wheat disease identification model, combined with the cosine annealing algorithm for adjusting the learning rate and the class balance loss strategy to balance the influence caused by the uneven number of images of different disease degrees. The cosine annealing algorithm is used to calculate the loss value of the training process to optimize the model;
[0089] AdamW is set to accelerate gradient descent by two momentum parameters β1 and β2. In terms of weight decay processing, AdamW adds an additional L2 regularization, separates weight decay from gradient update, and makes weight decay only for weight parameters, not directly for gradient update, to avoid the impact of bias parameters. The specific calculation method is as follows:
[0090] m t =β1m t-1 +(1-β1)g t
[0091]
[0092] where t is the training step, β1 and β2 are manually adjusted momentum parameters, g represents the gradient, m and v are the first and second order momentum estimates, respectively, m t and v t represent the results of two momentum bias correction, θ represents the parameter, γ is the learning rate, λ is the weight decay coefficient, and ∈ is a constant close to 0 to avoid the denominator being 0.
[0093] (2) Train the teacher model:
[0094] During the training of the teacher model, the preprocessed disease image size is adjusted to 244x244x3, the initial learning rate is set to 0.001, the momentum is 0.937, and the weight decay is 0.0005; the training process is performed for a total of 100 iterations, and a warm-up phase is enabled during the training process, with a minimum learning rate of 1x10 -6 and a warm-up rate of 5%. The specific training process is as follows:
[0095] The input layer reads image data, converts the image data into a feature array structure for initialization, and then submits the data to the feature extraction layer;
[0096] The feature extraction layer extracts high-dimensional disease features by performing a large number of convolution operations on the feature data. This layer is composed of multiple ResNeSt Blocks. After the feature image is input into the ResNeSt Block, it is first grouped into K main groups, and then each main group is further divided into R secondary groups. Second, for each secondary group, a high-dimensional feature is extracted by an operation unit composed of multiple convolution operations. Then, the R feature secondary groups are weighted and operated by the SplitAttention module to aggregate the feature data, and the K main groups are aggregated by the Concatenate operation. Finally, the SE attention module is used to weight the feature data of each feature channel to obtain the output feature map T.
[0097] The output layer performs downsampling operation on the obtained high-dimensional disease feature image through simple convolution operation, obtains a classification result, and calculates a classification loss L through the classification result;
[0098] Finally, the ResNeSt50 model is updated through the classification loss L, and then the next batch of training is performed to obtain a teacher model capable of accurately identifying the degree of wheat disease.
[0099] (3) Student model training:
[0100] The trained teacher model is enabled in the prediction mode, the preprocessed wheat disease image is input, feature extraction is performed, and the feature map T obtained by the feature extraction layer is output as the target image of the distillation process;
[0101] The student model is enabled in the training mode, the input image is processed, and the feature map S obtained by the feature extraction layer and the disease severity classification result of the model are output;
[0102] The classification loss L of the model is calculated according to the classification result of the student model original ;
[0103] According to the feature maps T and S of the teacher model and the student model, the distillation loss L of the mask generation distillation is obtained dis ;
[0104] According to the distillation loss L of the mask generation distillation dis and the classification loss L original , the total loss L of the model training is calculated by feature distillation all .
[0105] (4) Feature distillation process:
[0106] A1) Let T l ∈R C×H×W and S l ∈R C×H×W represent the lth wheat disease feature map of the teacher and the student, respectively, where l = 1,..,L,
[0107] The lth random mask is set to cover the lth feature of the student, which is represented as:
[0108]
[0109] The student wheat disease feature map mask is generated
[0110] where l represents the lth wheat disease feature map, i and j represent the length and width of each feature channel of the teacher feature map, respectively, and R i,jis a random number obeying uniform distribution between 0 and 1, λ is a hyperparameter representing the mask ratio, C, H, W represent the shape of the feature map;
[0111] A2) using the lth wheat disease feature map mask to cover the lth student's wheat disease feature map, and generating the teacher's wheat disease feature map with the left pixel:
[0112]
[0113] The teacher model feature map is generated by the student feature map, and the disease features extracted by a small number of student models are used to generate the result of the teacher model;
[0114] Specifically, an adaptive layer f align is adopted to adapt the feature dimension of the student feature S to the teacher feature T, and the adapted student feature is masked to obtain F by a point-by-point manner; and the student feature F is projected to the teacher feature T by a convolution structure including two convolution layers W l1 , W l2 and a projection layer of an activation layer ReLU to generate the teacher feature map;
[0115] A3) the distillation loss calculation of the whole distillation method is as follows:
[0116]
[0117] The distillation loss L dis is calculated by a point-by-point subtraction manner, wherein L represents the total number of feature map images used for distillation, C, H, W represent the shape of the feature map, S and T represent the features of the student and the teacher respectively, represents the projection layer, L dis represents the distillation loss of training, is the student wheat disease feature map mask;
[0118] The total loss is calculated as follows:
[0119] L all = L original + α·L dis
[0120] The total loss L all of the training process is calculated by a weighted operation, wherein L original is the original loss of the model in all tasks, and α is a hyperparameter for balancing the loss value;
[0121] Then, the total loss L all is used to update the student model SlimRepGhostNet, the updated model is used for experimental training, and a lightweight wheat disease recognition model is obtained.
[0122] Step 4: Acquire the image of the wheat disease to be identified: acquire the image of the wheat disease to be detected and perform preprocessing.
[0123] Step 5: Identify the image of the wheat disease: input the preprocessed image of the wheat disease into the trained lightweight wheat disease identification model to obtain the identification result of the image of the wheat disease.
[0124] In order to more clearly explore the classification effect of the model before and after the improvement of RepGhostNet, we reduce the output dimension of RepGhostNet and the improved model MGD-SlimRepGhost to two-dimensional space to visualize the classification results of the model.
[0125] Figure 4 (a) and Figure 4 (b) are the t-SNE graphs of the original RepGhostNet and the improved MGD-SlimRepGhostNet, respectively. From Figure 4 (a), it can be seen that before the improvement, the distribution within each level of wheat scab is scattered, and there is a lot of class overlap and confusion phenomenon, and the clustering effect is poor. From Figure 4 (b), it can be seen that in the improved model, the distribution within each level of wheat scab is relatively close, and the distinction between each level is obvious, and the class overlap and confusion phenomenon has been significantly improved, indicating that the improved model can better identify the differences between different severity of wheat scab images, thereby better achieving the diagnosis of the severity of wheat scab. The improved model MGD-SlimRepGhostNet has a larger improvement in model performance compared with the original RepGhostNet model.
[0126] Table 1 compares the performance of the two models on seven commonly used evaluation indicators, and MGD-SlimRepGhostNet is better than the original RepGhostNet in various indicators. From Table 1, it can be seen that compared with the original RepGhostNet, the improved MGD-SlimRepGhostNet has obvious improvement in each indicator. Its accuracy is improved by 4.29%, precision is improved by 6.43%, recall is improved by 6.13%, F1 score is improved by 6.31%, and FPS is improved by 21.17. At the same time, the parameter quantity and complexity of the model are also reduced. These improvements indicate that the improved model has significantly improved the ability to identify the severity of wheat single ear disease.
[0127] Table 1
[0128]
[0129] The above shows and describes the basic principles, main features and advantages of the present application. Those skilled in the art should understand that the present application is not limited to the above-mentioned embodiments, and the above-mentioned embodiments and descriptions in the specification are only the principles of the present application. Various changes and improvements can be made without departing from the spirit and scope of the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.
Claims
1. A lightweight wheat disease image recognition method for intelligent terminal complex background, characterized in that, Comprising the following steps: 11) Obtain a wheat disease image dataset: obtain wheat images taken by a smart terminal at different times, weather, environment, and growth stages, including healthy wheat and artificially inoculated disease wheat images, form a wheat scab disease image set, and perform extension and enhancement preprocessing operations; 12) Construct a lightweight wheat disease identification model: use a ResNeSt50 model as a teacher model and an improved RepGhostNet as a student model to construct a lightweight wheat disease identification model; Constructing a lightweight wheat disease identification model comprises the following steps: 121) Set the lightweight wheat disease identification model to include a teacher model and a student model, wherein the teacher model uses a ResNeSt50 model and the student model uses a RepGhostNet framework; add an output of a feature map at the end of the feature extraction layer of the teacher model and the student model, respectively output the feature maps of RepGhostNet and ResNeSt50, wherein the output of ResNeSt50 is used as a reference for the student model to learn in the distillation process, and the output of RepGhostNet is used to generate the feature map of the teacher model to calculate the distillation loss; 122) Set the teacher model; The teacher model is used to guide the training of the student model, and ResNeSt50 uses a ResNeSt Block structure to stack, divide the input feature map into K main groups, then divide each main group into R secondary groups, perform convolution processing on the secondary groups, then input them into the Split-Attention Block calculation unit for weighted operation, and finally concatenate them to combine all the main groups; 23) Set the student model; Set RepGhostNet to be composed of multiple RepGhost Bottlenecks, which are divided into 5 stages, and the dense convolution layer uses 16 channels to process the input data, and a normal 1x1 convolution and average pooling stack are used to predict the final output; RepGhost Bottleneck is divided into 5 groups, and the last Bottleneck in each group is set to stride=2, Remove the first layer of the RepGhost-Bottleneck module in the stage2 part of RepGhosNet, and remove the RepGhost-Bottleneck modules of the second and third layers in the stage4 part of RepGhosNet; Use the LeakyReLU function as the activation function f(x), and its expression is as follows: Where x is the input feature data and alpha is a positive number; 13) Training of the lightweight wheat disease identification model: based on the preprocessed wheat disease image set, use the knowledge distillation strategy to train the lightweight wheat disease identification model; The training of the lightweight wheat disease identification model comprises the following steps: 131) Set the optimizer: AdamW is used as the optimizer of the lightweight wheat disease recognition model, combined with the cosine annealing algorithm for adjusting the learning rate and class balance loss strategy to balance the influence caused by the uneven number of different disease degree images, and the cosine annealing algorithm is used to calculate the loss value in the training process to optimize the model; AdamW is set to accelerate gradient descent through two momentum parameters β1 and β2, and in the weight decay processing, AdamW adds an additional L2 regular, which separates the weight decay and gradient update processing, so that the weight decay is only used for weight parameters, not directly used for gradient update, to avoid the influence of bias parameters, and the specific calculation method is as follows: m t = β1m t-1 + (1 - β1)g t where t is the training step number, β1 and β2 are manually adjusted momentum parameters, g represents the gradient, m and v are the first and second order momentum estimates, respectively, and denotes the result of two momentum bias corrections, θ denotes the parameters, γ is the learning rate, λ is the weight decay coefficient, and ∈ is a constant to avoid division by zero; 132) Training of the teacher model: In the teacher model training process, the preprocessed disease image size is adjusted to 244x244x3, the initial learning rate is set to 0.001, the momentum is 0.937, and the weight decay is 0.0005; the training process is performed for a total of 100 iteration cycles, and a warm-up stage is enabled during the training process, with a minimum learning rate of 1x10 -6 , a warm-up rate of 5%, and the specific training process being as follows: The input layer reads image data, converts the image data into a feature array structure for initialization, and then submits the data to the feature extraction layer; The feature extraction layer extracts high-dimensional disease features through a large number of convolution operations on the feature data, and the layer is composed of multiple ResNeSt Block stacks. After the feature image is input into the ResNeSt Block, the feature image is first divided into K main groups, and then each main group is further divided into R secondary groups. Secondly, for each secondary group, a high-dimensional feature is obtained through a feature extraction operation unit composed of multiple convolution operations. Then, the feature data is aggregated through a SplitAttention module for weighted operation on the R secondary groups, and then the K main groups are aggregated through a Concatenate operation. Finally, the SE attention module is used to perform weighted operation on each feature channel of the feature data to obtain the output feature map T. The output layer performs downsampling operation on the obtained high-dimensional disease feature image through simple convolution operation to obtain classification result, and calculates classification loss L through the classification result; Finally, the ResNeSt50 model is updated through the classification loss L, and then the next batch of training is performed to obtain a teacher model capable of accurately identifying the severity of wheat diseases; 133) Training of the student model: The trained teacher model is enabled in the prediction mode to extract features from the preprocessed wheat disease image input, and output the feature map T obtained by the feature extraction layer as the target image in the distillation process. The student model is enabled in the training mode to process the input image and output the feature map S obtained by the feature extraction layer and the disease severity classification result of the student model; calculating a classification loss L of the model according to the classification result of the student model original ; According to the feature maps T and S of the teacher model and the student model, a distillation loss L of the mask generation distillation is obtained dis ; According to the masking, a distillation loss L is generated dis and a classification loss L original , a total loss L of the feature distillation calculation model training is carried out all ; 134) Feature distillation process: 1341) respectively with T l ∈R C×H×W and S l ∈R C×H×W denote the l-th wheat disease feature image of the teacher and student, respectively, where l = 1,.., L, The lth random mask is set to cover the lth feature of the student, which is represented as: Generating student wheat disease feature map masks wherein, l represents the lth wheat disease feature map, i and j represent the length and width of each feature channel of the teacher feature map respectively, R i,j is a random number between 0 and 1 subject to uniform distribution, λ' is a hyperparameter representing the mask ratio, C, H, and W represent the shape of the feature map; 1342) The lth wheat disease feature map mask is used to cover the lth wheat disease feature map of the student, and the left pixel is used to generate the wheat disease feature map of the teacher: The teacher model feature map is generated by the student feature map, and the disease feature extracted by the student model is used to generate the result of the teacher model; Specifically including: using an adaptive layer f of a 1x1 convolution align The student feature S is adapted to the feature dimension of the teacher feature T; the adapted student feature is masked by a point generation method to obtain F; the F is projected through a convolution structure Including two convolution layers W l1 , W l2 and a projection layer of an activation layer ReLU to generate a teacher feature map; 1343) The overall distillation loss calculation of the masking generation distillation method is as follows: Distillation loss L is calculated in a point-by-point subtraction manner dis where L represents the total number of feature maps for distillation, C, H, W represent the shape of the feature map, and S and T represent the student and teacher features, respectively, representing the projection layer, L dis representing the distillation loss of training, is a student wheat disease feature map mask; The total loss is calculated as follows: L all = L original + a' · L dis The total loss L of the training process is calculated by a weighted operation all where L original is the original loss of the model in all tasks, and a' is a hyperparameter for balancing the loss values. Then the total loss L all is used to update the student model RepGhostNet, and the updated model is used for experimental training to obtain the disease severity of wheat in the wheat disease image. 14) Acquisition of wheat disease images to be identified: acquire wheat disease images to be identified and preprocess them; 15) Wheat disease image recognition: input the preprocessed wheat disease image to be recognized into the trained lightweight wheat disease detection model to obtain the wheat disease image recognition result.
Citation Information
Patent Citations
Lightweight apple leaf disease identification method based on knowledge distillation
CN113610163A
Image recognition network fusing CNN (Convolutional Neural Network) and Transform model
CN116977822A