Lightweight Transformer tomato disease identification method fused with self-supervision enhancement
By introducing a multi-scale selection fusion attention module and self-supervised learning loss, combined with a reparameterizable normalization method, the recognition accuracy and robustness of the tomato disease identification model are improved. This solves the problems of insufficient global feature modeling and limited performance of lightweight models, making it suitable for disease monitoring tasks in complex agricultural environments.
Patent Information
- Application Number
- CN202511278029.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2045-09-09
AI Technical Summary
Existing methods for identifying tomato diseases suffer from problems such as insufficient global feature modeling capabilities, poor performance in identifying multi-scale lesions, and limited performance of lightweight models, making it difficult to meet the needs of modern agriculture for rapid, efficient, and automated disease identification.
A lightweight Transformer tomato disease identification method with self-supervised enhancement is adopted. Multi-scale selection fusion attention module (MSFAB) and self-supervised learning loss are introduced, combined with reparameterizable normalization method (RepBN) to improve the model's ability to model fine-grained differences and reduce computational overhead.
It improves the model's recognition accuracy and robustness in complex backgrounds, enhances its ability to classify diverse lesion morphologies and fine-grained details, and is suitable for resource-constrained agricultural production sites.
Smart Images

Figure CN120833523A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of natural image classification, and relates to an efficient recognition method for classifying tomato diseases. BACKGROUND
[0002] In order to effectively control the yield loss caused by tomato diseases, traditional agricultural production mainly relies on on-site observation and manual diagnosis of agricultural experts, judges the disease type according to the symptoms and takes corresponding prevention and control measures. However, this method is limited by subjective judgment, low diagnosis efficiency, strong dependence on professional knowledge and other problems, and it is difficult to meet the needs of modern agriculture for rapid, efficient and automatic disease identification. In recent years, with the rapid development of deep learning technology, the application of computer vision in crop disease identification has gradually become a research hotspot. Especially, the convolutional neural network (CNN) has strong image feature extraction ability and has been widely used in tomato leaf disease detection, which has significantly improved the recognition accuracy and model robustness, and gradually replaced the traditional recognition method based on handcrafted features and machine learning algorithms.
[0003] In view of the difficulties of insufficient labeled data, weak disease spot features and complex background interference, the existing methods have proposed various improved methods based on deep learning. For example, self-supervised learning and multi-network collaborative mechanism effectively improve the feature learning ability; combining Retinex image enhancement and improved Faster R-CNN detection network can improve the detection and severity grading accuracy of leaf diseases; the hybrid model of CNN and SVM combines the advantages of feature extraction and classification; lightweight convolutional structure (such as TomConv, TrioConv, CAST-Net) further compresses the model parameter quantity, improves the inference speed and deployment flexibility. These methods have achieved more than 90% classification accuracy on public data sets such as PlantVillage, showing high practical potential. However, the inherent local receptive field mechanism of the CNN model limits its modeling ability to rely on global disease spot patterns and long-distance features, especially when facing images with scattered disease spots, fuzzy boundaries or multiple diseases coexisting, the classification performance still has certain deficiencies.
[0004] In recent years, due to the global context modeling capability of the self-attention mechanism, Transformer-based visual models (such as Vision Transformer and Swin Transformer) have been widely used in fine-grained image classification and disease detection tasks. Many studies have shown that Transformer models outperform traditional CNNs in distinguishing between tomato early and late blight and quantitatively analyzing disease severity. For example, the STNet model that integrates spectral information improves detection accuracy; the model that introduces multi-head attention mechanism and L1 regular attention enhances the focusing ability of the disease spot area; the lightweight ViT network that introduces self-distillation strategy or hierarchical attention mechanism achieves a good balance between accuracy and model complexity. However, most Transformer models still have problems such as complex structure, large number of parameters, high training cost, strong dependence on computing resources, and are difficult to be directly applied to resource-limited agricultural production sites. In addition, Transformer still has some shortcomings in modeling high-frequency local texture details, which affects the recognition ability of early subtle disease spot features. Therefore, how to reduce the model's computational burden while maintaining high accuracy and enhancing the model's adaptability to complex background interference is still an important challenge in the field of tomato disease recognition. SUMMARY
[0005] The present application aims to solve the problems of insufficient global feature modeling capability, poor recognition effect of multi-scale disease spots, and limited performance of lightweight models in existing tomato disease recognition methods. It provides a tomato disease recognition method based on multi-scale fusion and self-supervised optimization mechanism to improve the accuracy, robustness, and generalization ability of the model in complex background, diverse disease spot morphology, and fine-grained classification scenarios.
[0006] The present application proposes a lightweight Transformer tomato disease recognition method with self-supervised enhancement, which includes the following steps:
[0007] (1) First, collect the tomato disease image dataset and perform data preprocessing on the dataset;
[0008] (2) To address the challenges of tomato disease classification and the lack of research in this field, a lightweight Transformer tomato disease recognition model SAEFormer based on fusion self-supervised enhancement is proposed, which includes the introduction of a multi-scale selection fusion attention module (MSFAB) to enhance the model's feature extraction capability; and the introduction of a self-supervised learning loss to effectively improve the model's ability to model fine-grained differences; and the use of RepBN optimization strategy to improve the model's deployment efficiency and reduce computational overhead;
[0009] (3) The preprocessed tomato disease image data is sent into the SAEFormer model for training and verification, and the final performance of the model is evaluated through multiple evaluation indexes;
[0010] (4) The tomato disease image to be classified is input into the SAEFormer model trained in the above step (3), and a classification result is output through forward calculation.
[0011] Further, the pre-processing method of step 1 is specifically:
[0012] (1.1) Before the experiment, first set the corresponding categories for the tomato diseases in each image; perform size normalization processing on the input network image I, and scale the image size to 224*224 pixels.
[0013] (1.2) Finally, the data set is randomly divided into a training set and a verification set according to a ratio of 8:2.
[0014] Further, the lightweight tomato disease recognition model based on fusion self-supervised enhancement of step 2 is specifically:
[0015] (2.1) The input feature is X, which first passes through a CPE conditional position encoding to introduce position information based on the local neighborhood of the input token.
[0016] X' = X + CPE(X)
[0017] A multi-scale selection fusion attention module (MSFAB) is embedded into the feature fusion network to improve the flexibility and information capturing ability of the model. By extracting local and global features in the spatial dimension and weighting the importance of features in the channel dimension, the most discriminative information in different receptive fields is adaptively selected, thereby enhancing the model's perception ability of multi-scale disease spot regions. First, a depth separable convolution with a kernel size of 3 is used to capture fine-grained features and local textures. Then, in branch one, a convolution with a kernel size of 1 is used to compress the channel number, generating feature F1. In branch two, a depth separable convolution with a kernel size of 5 is used to capture more context information in a larger area, and then a convolution with a kernel size of 1 is used to compress the channel number, generating feature F2. The two features F1 and F2 are concatenated in the channel dimension to form a joint feature F fuse , which retains all the information of the two scales and provides complete semantic feature information for the subsequent attention mechanism.
[0018] F1 = Conv1x1(DWConv 3×3 (X'))
[0019] F2 = Conv 1×1 (DWConv 5×5(DWConv 3×3 (X′)))
[0020] F fuse =Concat(F1,F2)
[0021] For the fusion feature F fuse Do the maximum pooling max(F along the channel dimension fuse ) and adaptive average pooling avg(F fuse ) to obtain a spatial map, and then generate a spatial attention map M through convolution with a convolution kernel size of 1 and Sigmoid activation function.
[0022] M=σ(Concat(max(F fuse ),avg(F fuse )))
[0023] The generated spatial attention map and the fusion feature are weighted element-by-element multiplication to obtain the spatial feature F s .
[0024] F s =F fuse ⊙M
[0025] F1 and F2 are channel-weighted to obtain F'1 and F'2, and then sent to the fully connected layer through global average pooling (GAP) to compress and obtain a selective channel vector. Then, a softmax operation is performed to split it into two weight vectors a1 and a2, and channel-level multiplication weighting is performed on F'1 and F'2 respectively.
[0026] a1=softmax(F1), a2=softmax(f2)
[0027] F′1=a1·F1, F′2=a2·F2
[0028] F c =F′1+F′2
[0029] Then the spatial attention output F s and channel attention output F c The two branches are added together and added to the initial input X' to form the residual output Y.
[0030] Y=X′+F s +F c
[0031] The model is made to focus more on the typical features of the lesion site and filter out interference information such as irrelevant background, thereby improving the accuracy of classification.
[0032] (2.2) Next, a self-supervised learning mechanism is introduced to improve the robustness of the model to the representation and guide the model to automatically mine key features. After the feature processing of the multiple MSFAB modules and the multi-head self-attention module in the above steps, the final token embedding grid is obtained where e i,j represents the token representation at the (i,j)th position.
[0033] Next, n pairs of position indices (a,b) and (c,d) are randomly sampled from H x According to these indices, the normalized real position offsets s u and s v are calculated, where (s u ,s v )∈[0,1] 2 , and the formula is as follows:
[0034]
[0035] The embeddings e a,b and e c,d of the two patches are concatenated into a 2D vector z, which is input into an MLP network to output two t u and t v as the predicted offsets.
[0036] z=concat(e a,b ,e c,d )
[0037] (t u ,t v )=MLP(z)
[0038] The predicted position offsets are compared with the initial position offsets using L1, and the formula for calculating the initial position offsets is L ssl .
[0039]
[0040] The cross-entropy loss L CE is used, which mainly measures the difference between the predicted class distribution of the model and the real label distribution. Cross-entropy loss is particularly suitable for multi-class classification problems due to its smooth gradient and high numerical stability. In this method, this loss function is used to optimize the backbone output of the model to have good discrimination ability. Where y i is the real label, is the model prediction probability.
[0041]
[0042] The final optimization goal is the weighted sum of the two loss functions above, with μ adjusting the weight ratio between the self-supervised loss and the supervised loss.
[0043] L total = μ·L ssl +L CE
[0044] The combination of cross-entropy loss and self-supervised loss significantly improves the model performance through collaborative optimization.
[0045] (2.3) To improve the training stability and inference efficiency of the model, a re-parameterized batch normalization method RepBN is used, which allows the model to dynamically balance the influence of BatchNorm (BN) and residual connection by introducing a learnable parameter λ. The formula definition of RepBN is as follows, X' obtained after conditional position encoding CPE is used as the input of RepBN, BN(X') is the standard batch normalization operation, and λ is the learnable parameter.
[0046] RepBN(X′)=BN(X′)+λX′
[0047] After training, RepBN can be converted to standard BN form by re-parameterization:
[0048] RepBN(X′;σ,ξ,α,β)=BN(X′;σ,ξ,α+λξ,β+λσ)
[0049] The above formula shows that RepBN integrates the additional linear term λX into the normalization process by adjusting the scaling parameter α and the translation parameter β of BN, thereby enhancing the expressive power of the model.
[0050] Further, the training and verification method of the SAEFormer model in step 3 is specifically:
[0051] (3.1) The pre-processed tomato disease data set in step 1 is input into the SAEFormer network in step 2 for training, and 300 iterations are set. After each iteration, the performance of the model generated in each iteration is verified using the validation set, and the optimal model weight file is saved by comparison.
[0052] (3.2) After the training iteration is completed, the optimal model obtained in (3.1) is used to evaluate the performance of the improved model by the parameter amount, Top1 accuracy, floating point operation (Flops), and training time of the model, to verify the effectiveness and advancement of the model.
[0053] Furthermore, the method for classifying tomato disease images using the proposed model described in step 4 is as follows: first, the tomato disease image to be classified is input into the model, and loaded into (3.1) to obtain the optimal model weight, and finally the correct tomato disease category is identified through prediction.
[0054] The present invention has the following characteristics:
[0055] 1. This paper proposes a tomato disease image recognition method based on multi-scale fusion and lightweight optimization. This method integrates key technologies such as the Multi-Scale Feature Selection Fusion Module (MSFAB), a self-supervised loss optimization mechanism, and a Reparameterizable Normalization (RepBN) method. It enables accurate classification of lesion features at different scales, improving recognition accuracy while balancing model efficiency and deployment capabilities. It is suitable for disease monitoring tasks in complex agricultural environments.
[0056] 2. This paper addresses the difficulty of traditional CNN models in effectively modeling the scale differences and contextual relationships of lesions. By constructing a multi-branch convolutional structure with different receptive fields and combining it with a channel-wise attention mechanism, this method achieves a joint modeling of local texture and global contextual features. This significantly improves the model's recognition capabilities for images with complex distributions, blurred edges, and multiple overlapping lesions, enhancing the diversity and discriminability of feature expression.
[0057] 3. This paper employs a training strategy that combines self-supervised loss with cross-entropy loss to achieve synergistic enhancement of feature extraction and classification optimization. This strategy not only improves the model's ability to model fine-grained differences, but also effectively mitigates overfitting, enhances the model's generalization performance in scenarios with unbalanced samples and complex background interference, and significantly improves the model's stability and practicality.
[0058] 4. The proposed RepBN module optimizes normalization performance while maintaining a lightweight structure. Through a structural reconstruction mechanism during the training and inference phases, the model's robustness to feature normalization errors is improved without increasing inference costs. This optimizes the stability and accuracy of the lightweight model in multi-class disease recognition tasks, making it suitable for real-time detection scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 This is a flow chart of the tomato disease classification algorithm proposed in the present invention.
[0060] Figure 2 This is the overall framework diagram of the model SAEFormer proposed in this invention.
[0061] Figure 3 This is a structural diagram of the MSFAB module proposed in the present invention.
[0062] Figure 4 A diagram of the structure of the self-supervised loss used in this invention.
[0063] Figure 5 Schematic diagram of the RepBN optimization strategy proposed in this invention.
[0064] Figure 6 This is the Top-1 Accuracy and Loss change curve of the SAEFormer proposed in this invention.
[0065] Figure 7 The attention heatmap of SAEFormer on 13 types of tomato disease images is used in this paper.
[0066] Figure 8 This is the training accuracy comparison curve of the SAEFormer proposed in this invention and the mainstream network.
[0067] Figure 9 A bubble chart comparing the training parameters, Top 1 accuracy, and computational complexity of the SAEFormer proposed in this invention and mainstream networks.
[0068] Figure 10 This is the Grad-CAM visualization analysis diagram of the SAEFormer proposed in this invention on 13 types of tomato disease images. DETAILED DESCRIPTION
[0069] The present invention is further described below with reference to the accompanying drawings and specific implementation examples.
[0070] This paper proposes an efficient tomato disease classification algorithm, combined with Figures 1 to 10 The detailed instructions are as follows:
[0071] like Figure 1 The figure shows a flowchart of the lightweight Transformer tomato disease recognition algorithm fused with self-supervised enhancement proposed in the present invention. In this process, tomato disease image data is first obtained by searching the Internet, and the data set is preprocessed. Secondly, the SAEFormer model is constructed to improve the accuracy and lightweightness of the tomato disease recognition task. This mainly includes introducing the multi-scale selection fusion attention module (MSFAB) to improve feature extraction capabilities; and introducing self-supervised learning loss to effectively improve the model's ability to model fine-grained differences; and adopting the RepBN optimization strategy to improve model deployment efficiency and reduce computational overhead. Then, the image data is input into the SAEFormer model with a fixed size of 224*224 for training and verification. Finally, the tomato disease image to be classified is input into the model weights of the tomato disease recognition method proposed in the present invention, and the classification result is output through forward calculation.
[0072] Based on DilateFormer, the present invention proposes the SAEFormer model. Figure 2 The figure shows the structural diagram of the SAEFormer model proposed in the present invention. SAEFormer uses a four-layer pyramid structure to efficiently process and abstract image features. The first two layers of the network constitute the basic feature extraction and processing modules, and each layer is composed of multiple MSFAB modules. These blocks contain multi-branch convolution structures with different receptive fields, and are combined with the channel attention mechanism to achieve joint modeling of local texture and global context features. The last two layers use the MHSAB module, which realizes long-distance modeling and multi-scale semantic extraction of features through the multi-head attention mechanism. MHSAB can capture the potential connections between distant regions in leaf disease images. Through innovative structural design, SAEFormer effectively improves the depth and breadth of feature processing, enhances the expressiveness of the model, and optimizes computational efficiency.
[0073] like Figure 3 The figure shows the structure of the MSFAB module proposed in the present invention. The MSFAB module efficiently extracts multi-scale contextual information from the input image and enhances the response of key areas through channel selective fusion and spatial attention mechanism. Specifically, with the help of the channel attention mechanism, the key feature channels related to the disease are highlighted, so that the model can focus more on the typical features of the lesion site and filter out interference information such as irrelevant background, thereby improving the accuracy of classification. It also integrates image-level semantic information through global semantic guidance, enhances the grasp of the overall characteristics of the disease, and further improves the classification performance. Its lightweight structure is also conducive to efficient deployment and application in the actual scenario of tomato disease detection.
[0074] like Figure 4 Figure 2 shows the structure of the self-supervised loss used. During training, the self-supervised loss is used in conjunction with the cross-entropy loss in the supervised task, forming a multi-task learning framework. Specifically, the model simultaneously performs an auxiliary relative position prediction task while performing image classification. This task guides the Transformer to learn spatial structure information by calculating the geometric offset between token pairs. The final total loss is a weighted sum of the two losses, with μ controlling the balance between the two, allowing the self-supervised signal to effectively improve the model's generalization ability without interfering with the main task.
[0075] like Figure 5A schematic diagram of the RepBN optimization strategy proposed in the application. Specifically, by introducing a learnable parameter λ, the model allows dynamic balancing of the influence of BatchNorm (BN) and residual connection. During the training phase, LayerNorm (LN) is replaced by RepBN, and finally BatchNorm is used completely during inference, eliminating the overhead of statistical quantity calculation while achieving efficient computation. In addition, the reparameterization mechanism in RepBN provides adaptive adjustment capability for input features, significantly improving the robustness and generalization ability of the model under complex input distribution, so that the model still maintains stable performance under different disease levels.
[0076] As Figure 6 The Top1 accuracy and loss change curve of SAEFormer proposed in the application. As can be seen from the figure, the Top1 accuracy curve of SAEFormer rises smoothly and quickly converges until it tends to fit. From the verification loss function curve, it can be seen that the model shows good convergence and stability during the entire training process. It shows that the SAEFormer model has good learning ability and training stability, and can complete rapid and effective convergence in fewer iteration rounds, providing a good optimization foundation for subsequent high classification accuracy.
[0077] As Figure 7 The attention heat map of SAEFormer used in the application on 13 categories of tomato disease images. In order to further evaluate the recognition performance of the model between categories, this matrix reflects the performance of the model in the fine-grained plant disease classification task in detail. Overall, the model has strong discrimination ability for tomato diseases, and most samples are concentrated near the diagonal line, indicating that the model can accurately predict multiple disease types. Although the overall effect is good, there is still confusion between certain categories, mainly between "different severity of the same type", which still needs to be distinguished in more detail.
[0078] To further validate the collaborative optimization effect of each innovative module on model performance, a step-by-step ablation experiment was designed to evaluate the effectiveness of the improved strategies. A controlled variable approach was used to systematically compare and analyze the three core components: the self-supervised learning module (SSLB), the multi-scale selection fusion module (MSFAB), and the feature normalization strategy (RepBN). As shown in Table 1, the experiment comprehensively evaluated the effectiveness of each module in terms of classification accuracy, parameter efficiency, and training time per epoch by gradually stacking modules. The improved strategies achieved Top-1 accuracies of 87.19%, 87.34%, and 87.86%, respectively, exceeding the baseline model. The SAEFormer model, combining all the improved strategies, achieved a Top-1 accuracy of 87.86%, a 1.64% improvement over the baseline DilateFormer, while maintaining a shorter training time than the baseline.
[0079] Table 113 Ablation experiment table on tomato disease dataset
[0080]
[0081] To verify the superiority of the present invention over other advanced classification algorithms, we conducted additional comparative experiments, and the results are shown in Tables 2 and 3. The SAEFormer model proposed in this paper achieved an accuracy rate of 87.86% on a dataset of 13 tomato diseases and 89.62% on a dataset of 8 tomato diseases. Compared to other advanced classification algorithms, it offers superior classification performance and achieves a trade-off between classification accuracy and speed.
[0082] Table 2 Performance comparison of each model on 13 types of tomato disease datasets
[0083]
[0084]
[0085] Table 3 Performance comparison of each model on 8 types of tomato disease datasets
[0086]
[0087] like Figure 8 The following figure shows the training accuracy comparison curve of the proposed SAEFormer and mainstream networks. As can be seen from the figure, the Top1 accuracy curve of SAEFormer rises steadily and converges quickly until it reaches a good fit, ultimately achieving a Top1 accuracy value that is superior to other models.
[0088] like Figure 9The bubble chart of training parameters, Top1 accuracy and computational complexity of the SAEFormer and mainstream networks is shown.
[0089] As shown in Figure 10 The Grad-CAM visualization analysis chart of the SAEFormer proposed in the application on 13 categories of tomato disease images is shown. From the figure, it can be seen that the heat map generated by the proposed SAEFormer model shows high-quality positioning on all categories, the red area accurately covers the disease spot area, the background interference is less, the heat area is clear and continuous, and the discrimination ability and the attention focusing ability to the disease are stronger.
Claims
1. A lightweight Transformer tomato disease recognition method integrating self-supervised enhancement, characterized by: It comprises the following steps: a. First, collect the tomato disease image dataset T, and perform data preprocessing on the input network image I to obtain the processed image dataset MT; b. A lightweight tomato disease recognition model SAEFormer is constructed, which comprises a multi-scale selection fusion attention module MSFAB to enhance the model's feature extraction capability, and a self-supervised learning loss to effectively improve the model's ability to model fine-grained differences; and a RepBN optimization strategy is adopted to improve the model deployment efficiency and reduce the computational overhead; c. The preprocessed tomato disease image data is input into the SAEFormer model for training and verification, and the final performance of the model is evaluated through four evaluation indicators; d. The tomato disease image to be classified is input into the SAEFormer model trained in step c, and the classification result is output through forward calculation.
2. The method of claim 1, wherein, The method for collecting the tomato disease image dataset in step a specifically comprises: The input network image I is subjected to size normalization processing, and the image size is scaled to 224*224 pixels; and the dataset is randomly divided into a training set and a validation set in a ratio of 8:
2.
3. The method of claim 1, wherein, The multi-scale selection fusion attention module MSFAB in step b specifically comprises: For the picture data X in step a of claim 1, first, a CPE conditional position encoding is performed to introduce position information based on the local neighborhood of the input token; X = X + CPE(X) Then, the fine-grained features and local textures are captured by a depthwise separable convolution with a kernel size of 3, and then in branch one, a convolution with a kernel size of 1 is used to compress the number of channels to generate a feature F1, and in branch two, a depthwise separable convolution with a kernel size of 5 is used to capture the context information in a larger area, and then a convolution with a kernel size of 1 is used to compress the number of channels to generate a feature F2, and the two features F1 and F2 are spliced in the channel dimension to form a joint feature F fuse , which retains all the information of the two scales and provides complete semantic feature information for the subsequent attention mechanism; F1 = Conv 1×1 (DWConv 3×3 (X′)) F2 = Conv 1×1 (DWConv 5×5 (DWConv 3×3 (X′))) F fuse = Concat(F1, F2) F fuse max pooling max(F fuse ) and adaptive average pooling avg(F fuse ) to obtain a spatial graph, and a spatial attention graph M is generated through a convolution kernel with a size of 1 and a Sigmoid activation function; M = σ (Concat(max(F fuse ), avg(F fuse ))) The generated spatial attention map and the fused features are element-wise multiplied to obtain a spatial feature F s ; F s = F fuse M Channel weighting is performed on F1 and F2 respectively to obtain F'1 and F'2, which are then input into a fully connected layer after global average pooling GAP to obtain a selective channel vector, and then subjected to a softmax operation to split into two weight vectors a1 and a2; and channel-level multiplication weighting is performed on F'1 and F'2 respectively; a1 = softmax(F1), a2 = softmax(F2) F'1 = a1·F1, F'2 = a2·F2 F c = F'1 + F'2 The spatial attention output F s is then added to the channel attention output F c to form a residual output Y. Y = X' + F s + F c This makes the model more focused on the typical features of the lesion site and filters out irrelevant background interference information, thereby improving the classification accuracy.
4. The method of claim 1, wherein, The self-supervised learning loss in step b specifically comprises: The training strategy of combining self-supervised loss with cross-entropy loss can improve the robustness of the model to representation and guide the model to automatically mine key features. After the feature processing of multiple MSFAB modules and multiple head self-attention modules in the above steps, the final token embedding grid is obtained where e i,j represents the token representation at the (i, j) position; next, n pairs of position indexes (a, b) and (c, d) are randomly sampled from H x , according to these indexes, the normalized real position offset s u and s v are calculated, where (s u , s v ) ∈ [0, 1] 2 , and the formula is as follows: The two patch embeddings e a,b and e c,d are concatenated into a 2D vector z, which is input into an MLP network to output t u and t v as the network's predicted offset. z = concat(e a,b , e c,d ) (t u ,t v )=MLP(z) The predicted position offset is compared to the initial position offset using LI, which is calculated as ssl ; Using cross-entropy loss L CE , which mainly measures the difference between the class distribution predicted by the model and the real label distribution. In this method, the loss function is used to optimize the backbone output of the model to have good discrimination ability; where y i is the real label, is the model prediction probability; The final optimization target is the weighted sum of the above two loss functions, and μ is used to adjust the weight ratio between the self-supervised loss and the supervised loss; μ is a parameter obtained through learning during network optimization; L total = μ · L ssl + L CE The combination of cross-entropy loss and self-supervised loss significantly improves the model performance through collaborative optimization.
5. The method of claim 1, wherein, The RepBN optimization strategy in step b specifically comprises: By introducing a learnable parameter λ, the model can dynamically balance the influence of BatchNorm and residual connection, and improve the training stability and inference efficiency of the model; wherein the formula definition of RepBN is as follows, X obtained after conditional position encoding CPE ' As the input of RepBN, BN(X') is a standard batch normalization operation, and λ is a learnable parameter; RepBN(X') = BN(X') + λX' After training, RepBN can be converted to standard BN form through reparameterization: RepBN(X;σ,ξ,α,β) = BN(X;σ,ξ,α+λξ,β+λσ) The above formula shows that RepBN integrates the additional linear term λX into the normalization process by adjusting the scaling parameter α and the translation parameter β of BN, thereby enhancing the model's expression ability.
6. The method of claim 1, wherein, The method for training and verifying the preprocessed tomato disease image data in the step c specifically comprises the following steps: The preprocessed tomato disease data set is input into the model for training for 300 iteration cycles; after each iteration, the performance of the model generated by each iteration is verified by using a verification set, and the optimal model weight file is saved by comparison; the performance of the improved model is evaluated by the parameter amount of the model, the Top1 accuracy, the floating point calculation amount and the training time, so as to verify the effectiveness and advancement of the model.
7. The method of claim 1, wherein, The method for inputting the tomato disease image to be classified into the SAEFormer model trained in the step c specifically comprises the following steps: The tomato disease image to be classified is adaptively scaled to a resolution size of 224*224 pixels and loaded into the model of the application; then the image G is input into the model loaded with the weight, and each layer module of the model uses the weight to extract features of the image and identify key features in the image; secondly, the features are finally calculated by a full connection layer to convert the features into category probabilities; finally, the model selects the category with the highest probability as the prediction result, that is, it is considered that the input tomato disease image G belongs to the category.
Citation Information
Patent Citations
Small sample tomato disease identification system and method based on image text learning
CN115050014A
Image direction recognition method fusing convolution and ViT
CN116664952A
Method for detecting plant diseases and insect pests of tomato leaves based on improved YOLOv5s
CN116994056A
Cited By
Soybean root rot fungus detection method and system based on multi-feature analysis
CN121616883A
