Tomato disease and pest identification method based on improved ControlNeXt lightweight classification model
By optimizing the structure and improving the lightweight design of the YOLOv8s-CLS model, and integrating the lightweight ControlNeXt layer and the label smoothing cross-entropy loss function, the problem of high model complexity is solved, enabling efficient pest and disease identification in resource-constrained environments, and making it suitable for agricultural edge devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2026-02-27
- Publication Date
- 2026-05-29
AI Technical Summary
Existing deep learning models have high computational complexity and a large number of parameters in tomato pest and disease identification, making them difficult to deploy on resource-constrained agricultural edge devices. Furthermore, lightweight models do not perform well in practical applications and cannot meet actual needs.
By removing redundant modules at the end of the YOLOv8s-CLS backbone network, integrating a lightweight ControlNeXt layer, and employing multi-path feature collaborative processing and label smoothing cross-entropy loss function, the model structure and training strategy are optimized, achieving both lightweighting and improved accuracy.
While reducing the number of model parameters by 37.5%, the accuracy was improved to 99.4%, and the computational efficiency was significantly improved, making it suitable for real-time deployment on agricultural edge devices.
Smart Images

Figure CN122115976A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pest and disease identification technology, and in particular to a method for identifying tomato pests and diseases based on an improved ControlNeXt lightweight classification model. Background Technology
[0002] As a vital global economic crop, tomatoes continue to suffer from severe threats to their yield and quality due to pests and diseases, resulting in significant economic losses and market chaos. Traditional pest and disease detection relies primarily on manual visual inspection, a method that is inefficient, subjective, costly, and difficult to apply on a large scale.
[0003] In recent years, deep learning technology has achieved remarkable results in the field of plant disease and pest classification, with convolutional neural networks (CNNs), recurrent neural networks (RNNs), and Transformers models demonstrating strong application potential. However, existing deep learning solutions still face the following serious challenges:
[0004] (1) High computational complexity: Although models such as ResNet50 and ViT have high recognition accuracy, they have a huge number of parameters and high computational requirements, making them difficult to deploy in real time in resource-constrained environments such as agricultural edge devices.
[0005] (2) Insufficient lightweightness: Although lightweight architectures such as MobileNet and ShuffleNet have achieved a good balance between accuracy and complexity, their performance in the actual application of tomato pest and disease classification is still not ideal and cannot meet the requirements of actual application.
[0006] (3) High model redundancy: Existing lightweight models such as YOLOv8s-CLS still have parameter redundancy problems, resulting in wasted computing power.
[0007] In practical agricultural applications, edge-deployed models must be able to run efficiently and with high quality on edge devices with limited computing resources. Based on the above analysis, this application proposes a lightweight improvement to the YOLOv8s-CLS model. By removing redundant modules and integrating an efficient feature extraction mechanism, it aims to achieve a balance between accuracy and efficiency, providing a feasible technical solution for intelligent detection of tomato diseases and pests. Summary of the Invention
[0008] In view of the above-mentioned defects or deficiencies in the existing technology, it is desirable to provide a tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model. By making targeted improvements to the YOLOv8s-CLS model, the outstanding problems in model complexity, computational efficiency and practical deployment adaptability can be solved, and a balance between accuracy and lightweightness can be achieved.
[0009] This invention provides a method for identifying tomato diseases and pests based on an improved ControlNeXt lightweight classification model, comprising the following steps:
[0010] 1) Model structure optimization;
[0011] Remove the C2f layer at the end of the YOLOv8s-CLS backbone network and use the output of the convolutional layer preceding the C2f layer as the output feature;
[0012] 2) Lightweight module integration;
[0013] A lightweight ControlNeXt layer is integrated into the second C2f layer of the YOLOv8s-CLS backbone network;
[0014] 3) Training strategy optimization;
[0015] A lightweight classification model was obtained by training the model using the label smooth cross-entropy loss function.
[0016] 4) Performance verification;
[0017] The performance of the lightweight classification model was evaluated on the test set using Accuracy, Precision, Recall and F1 score. FLOPS and Parameters were also calculated to evaluate the computational efficiency of the lightweight classification model.
[0018] 5) Identification of diseases and pests;
[0019] A lightweight classification model was used to identify tomato diseases and pests.
[0020] Furthermore, in step 2), the integration of the lightweight ControlNeXt layer specifically involves replacing the second convolutional layer of the first bottleneck layer in the second C2f layer of the YOLOv8s-CLS backbone network with the lightweight ControlNeXt layer, and replacing the first convolutional layer of the second bottleneck layer with the lightweight ControlNeXt layer.
[0021] Furthermore, in step 2), the lightweight ControlNeXt layer employs a multi-path feature collaborative processing mechanism, as shown in the following formula:
[0022] Y1=ReLU(CrossNorm(PWConv(DWSeparableConv(PWConv(X)))))+X);
[0023] Where Y1 is the output feature of the lightweight ControlNeXt layer;
[0024] ReLU is the activation function;
[0025] CrossNorm represents cross-normalization used for feature stabilization;
[0026] PWConv represents pointwise convolution used for channel dimensionality reduction;
[0027] DWSeparableConv stands for Depthwise Separable Convolution, used for spatial feature extraction;
[0028] X∈ R^{H×W×C} is the input feature map.
[0029] Furthermore, the depthwise separable convolution decomposes the standard convolution into depthwise convolution and pointwise convolution, as shown in the following formula:
[0030] Y2=PWConv(DWConv(X));
[0031] Where Y2 is the output feature of the depthwise separable convolution;
[0032] PWConv represents pointwise convolution used for channel dimensionality reduction;
[0033] DWConv represents depthwise convolution;
[0034] X∈ R^{H×W×C} is the input feature map.
[0035] Furthermore, the cross-normalization uses CrossNorm to achieve cross-path feature consistency, as shown in the formula: ;
[0036] Where X∈ R^{H×W×C} is the input feature map;
[0037] μ min The channel average value of the main branch feature map;
[0038] σ max The standard deviation of the main branch feature map;
[0039] ω is a small constant added to avoid division by zero.
[0040] Furthermore, in step 3), the formula for the label smoothing cross-entropy loss function is: ;
[0041] in, ε is the smoothing coefficient, 0 ≤ ε ≤ 1;
[0042] p k This represents the model's predicted probability of the true class.
[0043] C represents the total number of categories;
[0044] This represents the summation of predicted probabilities for all non-true categories.
[0045] Furthermore, in step 3), during model training, the smoothing coefficient ε is set to 0.1; and a learning rate decay strategy is used, with the initial learning rate set to 0.01 and decaying by 0.1 times every 30 epochs.
[0046] Compared with the prior art, the beneficial effects of the present invention are:
[0047] (1) This invention addresses the redundancy of the last layer of YOLOv8s-CLS in practical use by implementing a structural trimming strategy to achieve model lightweighting. Through experimental analysis of the information density and contribution of each layer of the model, it was found that the marginal benefit of the last C2f layer for classification tasks is diminishing; therefore, this redundant module was removed, which greatly reduced the model complexity, reduced the number of parameters to 3.18 million, a reduction of 37.5%, while maintaining the feature representation capability, laying the foundation for the deployment of the model in resource-constrained environments;
[0048] (2) This invention designs a lightweight module based on the ControlNeXt concept and integrates it into YOLOv8s-CLS, thereby optimizing and improving feature extraction efficiency. This is mainly reflected in three aspects:
[0049] Channel compression technology: Intelligent compression of the channel dimension is achieved by using a bottleneck structure (1×1-3×3-1×1), which reduces the amount of computation while retaining key feature information;
[0050] Depthwise separable convolution: Decomposes standard convolution into depthwise convolution and pointwise convolution, significantly reducing computational complexity;
[0051] Cross-normalization technique: Employing the CrossNorm mechanism, utilizing the main branch statistic (mean μ) min and standard deviation σ max Normalizing the current branch enhances feature consistency and enables efficient feature transformation, thereby reducing computational costs while improving feature representation capabilities.
[0052] (3) In view of the complex data distribution and class imbalance in agricultural application scenarios, this invention introduces a label smoothing cross-entropy loss function, which significantly improves the model's generalization ability on unknown data. This strategy reduces the tendency of the model to overfit by smoothing the label distribution and improves the accuracy.
[0053] It should be understood that the description in the Summary of the Invention is not intended to limit the key or essential features of the embodiments of the present invention, nor is it intended to restrict the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0054] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0055] Figure 1 This is a schematic diagram of a lightweight classification model based on the improved ControlNeXt.
[0056] Figure 2 This is a structural diagram of the lightweight ControlNeXt layer;
[0057] Figure 3 This is a schematic diagram of depthwise separable convolution. Detailed Implementation
[0058] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0059] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0060] Please refer to Figures 1-3 The present invention provides a method for identifying tomato diseases and pests based on an improved ControlNeXt lightweight classification model, comprising the following steps:
[0061] S1: Model structure optimization;
[0062] Based on the analysis of the information density of each layer of YOLOv8s-CLS, it was found that the C2f layer at the end has a very low contribution to the classification task. Therefore, the C2f layer at the end of the YOLOv8s-CLS backbone network was removed, and the output of the convolutional layer before the C2f layer was used as the output feature, which significantly reduced the number of model parameters.
[0063] S2: Lightweight module integration;
[0064] Integrate a lightweight ControlNeXt layer (ControlNeXt_Lightweight) into the second C2f layer of the YOLOv8s-CLS backbone network. Specifically, replace the second convolutional layer of the first bottleneck layer (Bottleneck) in the second C2f layer of the YOLOv8s-CLS backbone network with a lightweight ControlNeXt layer, and replace the first convolutional layer of the second bottleneck layer (Bottleneck) with a lightweight ControlNeXt layer.
[0065] The lightweight ControlNeXt layer employs a multi-path feature collaborative processing mechanism, as shown in the formula:
[0066] Y1=ReLU(CrossNorm(PWConv(DWSeparableConv(PWConv(X)))))+X);
[0067] Where Y1 is the output feature of the lightweight ControlNeXt layer;
[0068] ReLU is the activation function;
[0069] CrossNorm represents cross-normalization used for feature stabilization, and its design motivation lies in the pursuit of feature consistency.
[0070] PWConv represents pointwise convolution used for channel dimensionality reduction;
[0071] DWSeparableConv stands for Depthwise Separable Convolution, used for spatial feature extraction. Its design motivation is to decouple the spatial and channel operations of standard convolution.
[0072] X∈ R^{H×W×C}, which is the input feature map;
[0073] Depthwise separable convolution decomposes standard convolution into depthwise convolution and pointwise convolution, significantly reducing computational complexity. The formula is as follows:
[0074] Y2=PWConv(DWConv(X));
[0075] Where Y2 is the output feature of the depthwise separable convolution;
[0076] PWConv represents pointwise convolution used for channel dimensionality reduction;
[0077] DWConv represents depthwise convolution;
[0078] X∈ R^{H×W×C}, which is the input feature map;
[0079] Cross-normalization uses CrossNorm to achieve cross-path feature consistency, and the formula is as follows: ;
[0080] Where X∈ R^{H×W×C} is the input feature map;
[0081] μ min The channel average value of the main branch feature map;
[0082] σ max The standard deviation of the main branch feature map;
[0083] ω is a small constant added to avoid division by zero;
[0084] CrossNorm uses statistics from the main branch to normalize the features of the current branch, thereby improving feature consistency and training stability across paths.
[0085] CrossNorm(X) represents the output of the "cross-normalization" operation performed on the input feature map X;
[0086] S3: Training strategy optimization;
[0087] A lightweight classification model was obtained by training the model using the label smooth cross-entropy loss function.
[0088] Label smoothing cross-entropy loss function (L LS-CE By softening the hard label distribution, model overfitting is reduced. The formula is as follows: ;
[0089] in, ε is the smoothing coefficient, 0 ≤ ε ≤ 1;
[0090] p k This represents the model's predicted probability of the true class.
[0091] C represents the total number of categories;
[0092] This represents the summation of predicted probabilities for all non-true categories;
[0093] During model training, the smoothing coefficient ε was set to 0.1; and a learning rate decay strategy was used, with the initial learning rate set to 0.01 and decaying by a factor of 0.1 every 30 epochs.
[0094] S4: Performance verification;
[0095] The performance of the lightweight classification model was evaluated on the test set using Accuracy, Precision, Recall and F1 score. FLOPS and Parameters were also calculated to evaluate the computational efficiency of the lightweight classification model.
[0096] S5: Pest and disease identification;
[0097] A lightweight classification model was used to identify tomato diseases and pests.
[0098] In this embodiment, a lightweight improvement is made based on the YOLOv8s-CLS architecture, and the core components include:
[0099] 1) Basic framework: The YOLOv8s-CLS classification network is used as the basic architecture;
[0100] 2) Dataset: The Kaggle Tomato Diseases and Pests Dataset is used, which contains 10 categories, 10,000 training images and 1,000 test images;
[0101] 3) Data augmentation: Conditional Generative Adversarial Networks (cGANs) and traditional image processing techniques are used to generate 1000 augmented images each;
[0102] 4) Hardware requirements: NVIDIA GPU (32GB VRAM), PyTorch framework, Python 3.12, CUDA 12.1;
[0103] The effectiveness of each improved module was verified using ablation experiments:
[0104] 1) Module A (removing the terminal C2f layer): The number of parameters was reduced to 3.25 million, with an accuracy of 95.6%;
[0105] 2) Module B (ControlNeXt_Lightweight): 5.02 million parameters, accuracy 97.3%;
[0106] 3) Module A+B combination: 3.18 million parameters, F1 score reaches 0.990;
[0107] Compared to the original YOLOv8s-CLS (5.09 million parameters, 96.8% accuracy), the lightweight classification model in this application has 37.5% fewer parameters (3.18 million) and improves accuracy to 99.4%.
[0108] Use common evaluation metrics such as accuracy, precision, recall, F1 score, number of parameters, and floating-point numbers to evaluate the detection performance of the model.
[0109] Accuracy: This is the core metric for the overall classification performance of the model, representing the proportion of correctly predicted samples out of the total number of samples. The calculation formula is: ;
[0110] Where TP represents the number of samples correctly predicted as pests and diseases by the model;
[0111] TN represents the number of samples correctly predicted as healthy by the model;
[0112] FP represents the number of samples that were incorrectly predicted as pests or diseases by the model;
[0113] FN represents the number of samples that were incorrectly predicted as healthy by the model;
[0114] The lightweight classification model of this application achieved an accuracy of 0.9941 on the test set, indicating that most samples (regardless of whether they have pests or diseases) can be correctly identified and can achieve excellent results in practical tasks.
[0115] Precision: Represents the proportion of samples that the model predicts as positive, but which are actually positive. It measures the model's ability to control false positives. The formula is: ;
[0116] Tested on the test set, the accuracy of the lightweight classification model in this application is 0.9940, which is 2.6% better than the baseline model, indicating that the control of misdiagnosis has been significantly improved.
[0117] Recall: Represents the proportion of tomato leaves actually infected with pests or diseases that the model can successfully detect. The formula is: ;
[0118] Tested on the test set, the lightweight classification model of this application has a recall rate of 0.9940, indicating that it can identify the vast majority of pest and disease samples and has a significant inhibitory effect on missed detections.
[0119] F1 score: Represents the harmonic mean of precision and recall, used to evaluate the accuracy of binary or multi-class classification models; the closer the F1 score is to 1, the better the balance between precision and recall. The calculation formula is: ;
[0120] Parameters: This is a key indicator for measuring model complexity and storage requirements. It represents the total number of all weights and biases that need to be learned in the model, and directly determines the size of the model and memory usage. The lightweight classification model in this application has 3.18 million parameters, which is 37.5% less than the original model's 5.09 million, making outstanding achievements in lightweighting.
[0121] Floating-point operations (FLOPS): Used to evaluate the computational complexity of a model, representing the total number of floating-point operations required to complete one forward propagation; the lower the FLOPS, the faster the model inference speed and the lower the energy consumption.
[0122] Experiments showed that the lightweight classification model proposed in this application achieved 6.37M FLOPS on the test set, demonstrating its excellent performance in terms of computational complexity. Multiple rounds of experiments further confirmed that the superior technical indicators indicate that this scheme has a significant competitive advantage and widespread application value compared to similar technologies.
[0123] The lightweight classification model in this application is only 3.18MB in size, making it suitable for deployment on mobile and edge devices. It achieves real-time inference speed on NVIDIA GPUs and performs stably on augmented datasets (1000 augmented images generated using cGANs and 1000 images generated using traditional image processing techniques), adapting to various field environments.
[0124] The lightweight classification model of this application can also be applied to the classification and identification of other crop diseases and pests, industrial product quality inspection, medical image classification and diagnosis, and any scenario that requires lightweight and high-precision classification.
[0125] The lightweight classification model in this application adopts a modular design, allowing each improved component to be used independently or in combination, providing flexible technical solutions for different application scenarios. Performance can be further optimized in the future by adjusting parameters such as channel compression ratio and normalization strategy.
[0126] A complete alternative implementation scheme for the lightweight classification model of this application:
[0127] 1) A complete alternative to EfficientNet-B0: Conduct experimental analysis of the contribution of each layer, remove the high-level MBConv module with the smallest contribution, integrate a lightweight ControlNeXt layer (channel compression ratio of 4) in the middle layer, and adopt the same label smoothing training strategy.
[0128] 2) Multimodal fusion alternative method: Construct a dual-branch network architecture to achieve multimodal feature fusion. Use the improved YOLOv8s-CLS architecture of this application to process RGB images and use the lightweight ViT architecture to process near-infrared spectral features. A weighted fusion of dual-branch features is achieved through a cross-modal attention mechanism (this scheme is particularly suitable for agricultural drone detection systems equipped with multispectral cameras).
[0129] Regarding the alternative implementation scheme for the lightweight classification model of this application:
[0130] 1) A simplified version of the CrossNorm mechanism, using GroupNorm or other methods to replace CrossNorm; or using adaptive depthwise separable convolution, which introduces learnable weights on the basis of depthwise separable convolution;
[0131] 2) Dynamic skipping mechanism: The last C2f layer is retained, but a dynamic skipping mechanism is introduced. For example, the last C2f layer is skipped directly for simple samples, and the last C2f module is enabled for complex samples.
[0132] Regarding hardware replacement / optimization solutions:
[0133] Three optimization schemes are proposed for edge devices with different computing power:
[0134] 1) High-end edge devices (such as Jetson Nano): Use the full version model;
[0135] 2) Mid-range devices (such as Raspberry Pi 4B): Channel count reduced to 75%;
[0136] 3) Low-end devices (such as ARM Cortex-A53): The number of channels is compressed to 50%, while using 8-bit or higher integer quantization.
[0137] Application Scenario Expansion Implementation Plan:
[0138] This technology can be applied to the detection of other crop diseases and pests by fine-tuning parameters, domain adaptation (using adversarial training to reduce inter-domain differences), and few-shot learning (using pre-trained models for rapid adaptation).
[0139] The key highlight of this invention lies in the synergistic optimization of multiple key indicators. While reducing the number of parameters by 37.5%, the accuracy rate increased from 96.8% to 99.4%, and computational efficiency was significantly improved. This comprehensive performance enhancement makes the model suitable for deployment on agricultural edge computing devices, providing a feasible technical solution for precision agriculture. It resolves the contradiction between high accuracy requirements and limited computing resources in existing technologies, offering a new technical path for real-time and accurate detection of tomato diseases and pests.
[0140] In the description of this specification, the terms "one embodiment," "some embodiments," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0141] The above are merely preferred embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for identifying tomato diseases and pests based on an improved ControlNeXt lightweight classification model, characterized in that, Includes the following steps: 1) Model structure optimization; Remove the C2f layer at the end of the YOLOv8s-CLS backbone network and use the output of the convolutional layer preceding the C2f layer as the output feature; 2) Lightweight module integration; A lightweight ControlNeXt layer is integrated into the second C2f layer of the YOLOv8s-CLS backbone network; 3) Training strategy optimization; A lightweight classification model was obtained by training the model using the label smooth cross-entropy loss function. 4) Performance verification; The performance of the lightweight classification model was evaluated on the test set using Accuracy, Precision, Recall and F1 score. FLOPS and Parameters were also calculated to evaluate the computational efficiency of the lightweight classification model. 5) Identification of diseases and pests; A lightweight classification model was used to identify tomato diseases and pests.
2. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 1, characterized in that, In step 2), the integration of the lightweight ControlNeXt layer specifically involves replacing the second convolutional layer of the first bottleneck layer in the second C2f layer of the YOLOv8s-CLS backbone network with the lightweight ControlNeXt layer, and replacing the first convolutional layer of the second bottleneck layer with the lightweight ControlNeXt layer.
3. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 1, characterized in that, In step 2), the lightweight ControlNeXt layer employs a multi-path feature collaborative processing mechanism, as shown in the following formula: Y1=ReLU(CrossNorm(PWConv(DWSeparableConv(PWConv(X)))))+X); Where Y1 is the output feature of the lightweight ControlNeXt layer; ReLU is the activation function; CrossNorm represents cross-normalization used for feature stabilization; PWConv represents pointwise convolution used for channel dimensionality reduction; DWSeparableConv stands for Depthwise Separable Convolution, used for spatial feature extraction; X∈ R^{H×W×C} is the input feature map.
4. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 3, characterized in that, The depthwise separable convolution decomposes the standard convolution into depthwise convolution and pointwise convolution, with the following formula: Y2=PWConv(DWConv(X)); Where Y2 is the output feature of the depthwise separable convolution; PWConv represents pointwise convolution used for channel dimensionality reduction; DWConv represents depthwise convolution; X∈ R^{H×W×C} is the input feature map.
5. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 3, characterized in that, The cross-normalization uses CrossNorm to achieve cross-path feature consistency, and the formula is as follows: ; Where X∈ R^{H×W×C} is the input feature map; μ min The channel average value of the main branch feature map; σ max The standard deviation of the main branch feature map; ω is a small constant added to avoid division by zero.
6. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 1, characterized in that, In step 3), the formula for the label smoothing cross-entropy loss function is: ; in, ε is the smoothing coefficient, 0 ≤ ε ≤ 1; p k This represents the model's predicted probability of the true class. C represents the total number of categories; This represents the summation of predicted probabilities for all non-true categories.
7. The tomato pest and disease identification method based on the improved ControlNeXt lightweight classification model according to claim 6, characterized in that, In step 3), during model training, the smoothing coefficient ε is set to 0.1; and a learning rate decay strategy is used, with the initial learning rate set to 0.01 and decaying by 0.1 times every 30 epochs.