Tomato leaf tier moth larva leaf indirect detection method based on light weight model

By transferring knowledge from the teacher model to a lightweight student model through knowledge distillation technology, and combining multiple loss functions and multi-stage fine-tuning, the problems of large model size, low detection efficiency and insufficient generalization ability of existing pest detection methods in agricultural scenarios are solved, and efficient and real-time pest detection is achieved.

CN122347746APending Publication Date: 2026-07-07QINGDAO AGRI UNIV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
QINGDAO AGRI UNIV
Filing Date
2026-04-14
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing deep learning-based pest detection methods in agricultural scenarios suffer from problems such as excessively large model size, high computational resource requirements, insufficient real-time detection, and insufficient accuracy of lightweight models. In particular, their generalization ability is limited in real-world field scenarios such as complex lighting and overlapping leaves.

Method used

Knowledge distillation technology is used to transfer the knowledge of the pre-trained ResNet34 teacher model to the ShuffleNet_v2_x1_0 student model. By combining cross-entropy loss, soft target loss and neighborhood knowledge distillation loss function, the student model is optimized through multi-stage fine-tuning to build a lightweight tomato leafminer larvae pest detection model. Dynamic quantization is then used to make it suitable for resource-constrained devices.

Benefits of technology

It achieves model parameter compression of more than 15 times while maintaining high detection accuracy, reaching an average precision of 91.7% and a recall of 96.3%, with an inference time of less than 0.5 seconds, meeting the needs of real-time field detection and suitable for mobile devices and embedded systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122347746A_ABST
    Figure CN122347746A_ABST
Patent Text Reader

Abstract

The present application relates to the field of intelligent detection of agricultural diseases and pests, and provides a tomato leaf leaf-roller larva leaf level indirect detection method based on a lightweight model. The method transfers the knowledge of a pre-training teacher model to a lightweight student model through a knowledge distillation algorithm, combines cross-entropy loss, soft target loss and neighborhood knowledge distillation loss for joint optimization, and constructs a tomato leaf-roller larva pest image level detection model through multi-stage fine-tuning. The verification shows that the accuracy is 91.7%, the F1 value is 91.2%, the recall rate is 96.3%, and the model volume is compressed to 1.2MB. The detection object of the method covers the leaf-roller larva stage, and it can adapt to complex light and leaf overlap scenes in the field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent detection of agricultural pests and diseases. Specifically, this invention relates to a leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model. Background Technology

[0002] The tomato leafminer is a pest that damages tomatoes and other solanaceous crops. Its larvae bore into the leaves, feeding on the leaf tissue and creating irregular tunnels, severely impacting photosynthesis and leading to reduced yield and quality. Traditional pest detection methods rely primarily on manual observation, which is inefficient and its accuracy is limited by the experience of the inspectors. With the development of computer vision and deep learning technologies, automated pest detection methods based on image recognition are gradually emerging.

[0003] Existing deep learning-based pest detection methods still have significant shortcomings in practical agricultural scenarios:

[0004] First, the model size is too large and the computational resource requirements are high: high-precision deep neural networks, such as ResNet and VGG, generally have more than 10M parameters, which are difficult to deploy directly on mobile devices and embedded agricultural terminals.

[0005] Second, the detection real-time performance is insufficient: the inference latency of complex models is high, which cannot meet the detection speed requirements of real-time field inspections;

[0006] Third, the lightweight model lacks accuracy: the detection accuracy of the directly trained lightweight model drops significantly under actual field scenarios such as complex lighting and overlapping leaves, and its generalization ability is limited.

[0007] Knowledge distillation is a model compression technique that significantly reduces model parameters and computational load by transferring knowledge from a complex teacher model to a simple student model, while maintaining high accuracy. Existing knowledge distillation methods have limited application research in agricultural pest detection and lack optimized solutions for specific larval pests such as the tomato leafminer.

[0008] Therefore, there is a need to develop an efficient and accurate method for detecting tomato leafminer pests that can be deployed on resource-constrained equipment. Summary of the Invention

[0009] This invention provides a leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model, which at least solves the problems of existing pest detection methods such as complex models, low detection efficiency, and insufficient generalization ability.

[0010] To achieve the above objectives, this invention provides a leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model, comprising the following steps:

[0011] Data acquisition and processing steps: Acquire the first historical image data of the sample tomato leaves and perform data preprocessing to obtain the second historical image data;

[0012] Model building steps: Construct a pre-trained teacher model and a lightweight student model. Transfer the knowledge of the teacher model to the student model by combining cross-entropy loss, soft target loss, and neighborhood knowledge distillation loss function. Then, fine-tune and optimize the student model in multiple stages using second historical image data to build an image-level detection model for tomato leafminer larvae pests.

[0013] Pest detection steps: Input the image data of the leaf to be tested into the pest image-level detection model to obtain the pest image-level detection results.

[0014] Furthermore, the data acquisition and processing steps include:

[0015] Healthy tomato plants were artificially inoculated with pests, and photos were taken every 12 hours until the leaf tissue was completely consumed, thus obtaining a series of pest-infected samples. The RGB image data of the tomato leaves obtained from the samples were used as the first historical image data. The first historical image data was preprocessed to obtain the second historical image data.

[0016] The data preprocessing includes: denoising and enhancing the first historical image data;

[0017] Image data of a single leaf is obtained from the first historical image data after denoising and enhancement processing;

[0018] Individual leaf images were normalized to 224×224 pixels; based on leaf pest feature annotations, the image category labels (healthy / pested) were obtained; the image data were normalized using ImageNet means: 0.485, 0.456, 0.406 and standard deviations: 0.229, 0.224, 0.225, to obtain normalized image data as the second historical image data.

[0019] Furthermore, the model construction steps specifically include:

[0020] The initial steps of model building are as follows: construct a pre-trained deep convolutional neural network as the teacher model and a lightweight convolutional neural network as the student model, and define the number of network layers and structure;

[0021] Model knowledge distillation steps: Input the second historical image data and the category labels of the image into the teacher model and student model, and obtain the distilled student model based on the knowledge distillation optimization algorithm;

[0022] Model fine-tuning steps: Based on tomato leaf image data of different pest levels, the distilled student model is fine-tuned to obtain an image-level detection model for tomato leafminer pests.

[0023] Furthermore, the initial model building steps include:

[0024] The ResNet34 teacher model is constructed as follows: The network starts with a convolutional layer with a 3×3 kernel, 64 output channels, and a stride of 1 as the initial feature extraction layer. It then goes through four residual stages, which contain 3, 4, 6, and 3 BasicBlock modules, respectively. Each BasicBlock consists of two 3×3 convolutional layers with batch normalization and ReLU activation function to accelerate convergence and alleviate the gradient vanishing problem. Each stage retains the original information and learns the residual mapping through residual connections. Finally, the feature map is compressed into a fixed-dimensional vector through a global average pooling layer, and the prediction results for two classes are output by a fully connected layer.

[0025] The student model ShuffleNet_v2_x1_0 is constructed as follows: The network first downsamples the input image and extracts initial features through an initial convolutional layer with a 3×3 convolutional kernel, 24 output channels, and a stride of 2. Then, it goes through three InvertedResidual stages, with the number of output channels set to 116, 232, and 464 respectively to expand the feature dimension layer by layer. Within each stage, a channel shuffling mechanism is used to promote information flow between different grouped channels, thereby improving the feature representation ability. Finally, a global average pooling layer aggregates the multidimensional feature map into a one-dimensional vector, and a fully connected layer outputs the prediction results for two categories. This architecture is used to build the teacher model and the student model respectively.

[0026] Furthermore, the model knowledge distillation steps include:

[0027] Teacher model training: The teacher model is pre-trained using the second historical image data, employing the cross-entropy loss function and the Adam optimizer, and trained until the accuracy on the validation set converges;

[0028] Knowledge distillation training: Fix the weights of the teacher model and set it to evaluation mode. Input the image into both the teacher model and the student model simultaneously. Use the Adam optimizer with a learning rate of 0.001 to update the weights of the student model.

[0029] Termination conditions and output: Training continues until the accuracy on the validation set shows no improvement for 50 consecutive epochs, then the distilled student model is obtained.

[0030] Furthermore, the model fine-tuning step includes:

[0031] The model fine-tuning steps adopt a multi-stage fine-tuning strategy, specifically including the following three stages: (1) Layer selection stage: calculate the cosine similarity between the weights of each network layer of the student model and the data distribution of the target task, evaluate the contribution of each layer to the tomato leafminer pest detection task, select the network layer with the highest contribution as the fine-tuning target layer, and freeze the parameters of the remaining layers to prevent overfitting; (2) Layer fine-tuning stage: conduct supervised training on the selected network layers with a small learning rate, use the cross-entropy loss function to supervise the classification performance, and enable the model to quickly adapt to the specific data distribution of tomato leaf pest detection; (3) Knowledge distillation fine-tuning stage: in a longer training period, determine the optimal combination of learning rate and loss weight through the automatic hyperparameter search method, and dynamically adjust the learning rate in combination with the cosine annealing hot restart strategy, while continuing to apply knowledge distillation constraints to further improve the detection accuracy and generalization ability of the student model on the target task.

[0032] Furthermore, the method of the present invention further includes a model deployment optimization step:

[0033] Model Quantization: Dynamic quantization is performed on the fine-tuned pest image-level detection model, converting floating-point operations into integer operations, significantly reducing computational overhead and memory usage. The quantized model is exported in ONNX format, leveraging its universal intermediate representation advantage to achieve cross-platform compatibility. It can be deployed in resource-constrained environments such as mobile devices and edge computing devices, meeting the needs of real-time field detection.

[0034] Application Integration: Develop a visual detection interface based on MATLAB App Designer, supporting image uploading, real-time detection, and result visualization. Detection results are displayed with health indicators (green) or pest indicators (red).

[0035] Furthermore, this invention provides a leaf-level indirect detection system for tomato leafminer larvae based on a lightweight model, which applies the above method and includes:

[0036] Data acquisition and processing module: used to acquire the first historical image data of sample tomato leaves and perform data preprocessing to obtain the second historical image data;

[0037] Model building module: used to build a pre-trained teacher model and a lightweight student model. It transfers knowledge from the teacher model to the student model by combining knowledge distillation algorithms with multiple loss functions, and performs multi-stage fine-tuning and optimization on the student model to obtain an image-level detection model for tomato leafminer larvae pests.

[0038] Pest detection visualization module: It is used to receive images of leaves to be detected uploaded by users, call the pest image-level detection model to perform inference, and output the detection results in the form of different color labels and confidence scores.

[0039] Furthermore, the model building module includes:

[0040] Initial model building unit: Construct a pre-trained deep convolutional neural network as the teacher model and a lightweight convolutional neural network as the student model, and define the number of network layers and structure;

[0041] Model knowledge distillation unit: Input the second historical image data into the teacher model and student model, and obtain the distilled student model based on the knowledge distillation optimization algorithm;

[0042] Model fine-tuning unit: Based on tomato leaf image data of different pest levels, the distilled student model is fine-tuned to obtain an image-level detection model for tomato leafminer pests.

[0043] Beneficial effects

[0044] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0045] To address the problem that existing high-precision models are bulky and difficult to deploy in the field, this invention uses knowledge distillation technology to transfer knowledge from the ResNet34 teacher model (21.29M parameters) to the ShuffleNet_v2_x1_0 student model (1.26M parameters), achieving more than 15 times parameter compression while maintaining high detection accuracy. This allows the model to be easily deployed on mobile devices and embedded systems.

[0046] To address the issue of insufficient accuracy when directly training lightweight models, this invention utilizes five-fold cross-validation, achieving an average accuracy of 91.7%, an F1 score of 91.2%, and a recall of 96.3% in the tomato leafminer pest detection task, which is superior to lightweight models trained directly on the same scale.

[0047] To address the issue that a single loss function is insufficient for fully transferring knowledge from the teacher model, this invention combines cross-entropy loss with real labels as supervision signals to ensure the student model possesses basic discriminative capabilities. Soft target loss scales the outputs of both the teacher and student models using a temperature parameter T, and utilizes KL divergence to measure the difference between their soft probability distributions, enabling the student model to learn from the teacher model's knowledge. Neighborhood feature loss and neighborhood response loss align the local neighborhood representations of the teacher and student models in the intermediate feature layer, achieving fine-grained feature-level knowledge transfer. This comprehensive optimization of the student model across both classification performance and feature representation significantly enhances its generalization performance in complex field scenarios.

[0048] This invention provides a complete end-to-end technical solution covering data acquisition, model training, knowledge distillation, fine-tuning and optimization, quantization and compression to cross-platform deployment, and has developed a supporting visualization detection application, which has strong practical engineering application value.

[0049] Through dynamic quantization and ONNX format conversion, the size of the pest image-level detection model of this invention is compressed from 4.8MB to 1.2MB, and the inference time is less than 0.5 seconds. It can be deployed on multiple platforms such as Windows, Linux and mobile devices to meet the lightweight deployment needs of different application scenarios. Attached Figure Description

[0050] Figure 1 This is a schematic diagram of the leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to the present invention.

[0051] Figure 2 This is a schematic diagram of the overall process of knowledge distillation according to the present invention.

[0052] Figure 3 This is a flowchart illustrating the calculation of the knowledge distillation loss function for this invention.

[0053] Figure 4 This is a bar chart comparing the detection performance of the knowledge distillation-based tomato leafminer pest detection method of this invention with other detection methods. Detailed Implementation

[0054] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0055] Example 1: As Figure 1 As shown, this invention provides a leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model, comprising the following steps:

[0056] Data acquisition and processing step S100: Acquire first historical image data and perform data processing to obtain second historical image data;

[0057] Model building step S200: Construct a deep convolutional neural network as the teacher model and a lightweight convolutional neural network as the student model, and obtain the optimized student model based on the knowledge distillation algorithm; train the student model with second historical image data, perform multi-stage fine-tuning of the model, and obtain an image-level detection model for tomato leafminer pests, whose detection performance is better than the student model before distillation.

[0058] Pest detection step S300: Input the image of the leaf to be tested into the pest image-level detection model to obtain the pest image-level detection results.

[0059] Preferably, the data acquisition and processing step S100 includes: acquiring sample tomato leaf plants, artificially inoculating the plants with pests, taking leaf images every 12 hours until the leaf tissue is completely consumed, thereby obtaining a series of pest-infested leaf samples, while also collecting healthy leaf samples; preprocessing the acquired image data: adjusting the image size to 224×224 pixels, ensuring RGB three-channel format, normalizing using ImageNet normalization parameters with mean: 0.485, 0.456, 0.406, standard deviation: 0.229, 0.224, 0.225, and labeling the images as healthy or pest-infested to obtain second historical image data.

[0060] Preferably, the model construction step S200 specifically includes:

[0061] Model initial setup step S210: Construct a deep convolutional neural network as the teacher model and a lightweight convolutional neural network as the student model, and define the number of network layers and structure;

[0062] The structural comparison of the student model before and after distillation is as follows: Before distillation, the student model uses the standard ShuffleNet_v2_x1_0 architecture to perform multi-stage feature extraction on the input image. After initial convolutional layer downsampling, it goes through three InvertedResidual stages in sequence. Each stage promotes the exchange of feature information through channel shuffling mechanism. Finally, after global average pooling, the fully connected layer outputs the binary classification result. After distillation, a feature adapter is introduced on the basis of the original architecture to receive soft target and intermediate layer feature maps from the teacher model. Through cross-architecture feature alignment mechanism, the teacher's knowledge is injected into the corresponding layer of the student model to achieve multi-level knowledge transfer and significantly improve the classification accuracy and generalization ability of the student model.

[0063] Model knowledge distillation step S220: as follows Figure 2 As shown, the overall knowledge distillation process encompasses three stages: teacher model pre-training, knowledge distillation training, and early stopping; for example... Figure 3 As shown, the loss function calculation process specifically includes: 1. Teacher model pre-training: The teacher model is pre-trained using the second historical image data, and cross-entropy loss and Adam optimizer are adopted. The training is usually completed within 10 to 100 cycles until the accuracy of the validation set converges.

[0064] 2. Knowledge Distillation Training: In the knowledge distillation training phase, the teacher model weights are fixed and set to evaluation mode. Each batch of input images is simultaneously fed into both the teacher and student models for forward propagation. The loss function consists of three parts: neighborhood knowledge distillation loss (neighborhood feature loss with a weight of 0.5), neighborhood response loss (with a weight of 1.0), and cross-entropy loss to supervise the hard label classification performance of the student model. The soft target loss is scaled to logits using the temperature parameter T, and the difference in soft probability distribution is measured by KL divergence and multiplied by the square of the temperature for gradient compensation. The Adam optimizer is used with a learning rate of 0.001, and training lasts for 100 epochs.

[0065] 3. Early stopping strategy: During training, continuously monitor the accuracy of the validation set. When there is no performance improvement for 50 consecutive cycles, automatically terminate training to avoid overfitting and save the current best model weights.

[0066] Enter the model fine-tuning step S230, and use a multi-stage fine-tuning strategy to fine-tune the distilled student model. Specifically, it includes the following three stages: (1) Layer selection stage: calculate the cosine similarity between the weights of each network layer of the student model and the data distribution of the tomato leafminer target task, evaluate the contribution of each layer to the detection task, select the network layer with the highest contribution as the fine-tuning target layer, and freeze the parameters of the remaining layers to prevent overfitting; (2) Layer fine-tuning stage: load the weights of the knowledge-distilled student model as initial parameters, conduct supervised training on the selected network layers with a small learning rate of 0.0001, use the cross-entropy loss function to supervise the classification performance, and use data augmentation operations such as random pruning, horizontal flipping and color jittering to improve the generalization ability, so that the model can quickly adapt to the specific data distribution of tomato leaf pest detection; (3) Knowledge distillation fine-tuning stage: in a longer training period (a total of 100 periods), determine the optimal learning rate and loss weight combination through the automatic hyperparameter search method, and dynamically adjust the learning rate in combination with the cosine annealing hot restart strategy, while continuing to apply knowledge distillation constraints. The training process includes an early stopping mechanism, which automatically terminates the training when there is no performance improvement for several consecutive cycles to prevent overfitting. After training, the model weights with the best validation set accuracy and F1 score are saved to obtain an optimized model for tomato leafminer pest detection, achieving image-level pest detection.

[0067] Example 2: To verify the effectiveness of the method of the present invention, a five-fold cross-validation experiment was conducted, as follows:

[0068] 1. Dataset partitioning: The tomato leaf dataset was divided into 5 subsets according to the class balance principle. Each subset was used as the validation set in turn, and the rest were used for training.

[0069] 2. Experimental setup: Batch size was set to 16, training period was 100, the optimizer was Adam, the learning rate during the fine-tuning phase was 0.0001, and the knowledge distillation temperature parameter was T=3.

[0070] 3. Performance metrics: accuracy, F1 score, recall, model size, and inference time.

[0071] 4. Experimental results: such as Figure 4 As shown, the performance comparison results of the method of this invention with other detection methods are as follows: The knowledge distillation benchmark method has a validation set accuracy of 90.4%, an F1 score of 89.8%, a recall of 84.9%, and a loss of 0.291; the multi-loss function method has an accuracy of 90.4%, an F1 score of 89.8%, a recall of 95.1%, and a loss of 0.276; the module replacement + knowledge distillation method has an accuracy of 90.7%, an F1 score of 89.9%, a recall of 96.4%, and a loss of 0.285; the distillation pre-training method has an accuracy of 91.2%, an F1 score of 90.6%, a recall of 96.0%, and a loss of 0.275; and the non-distillation cross-entropy pre-training method has an accuracy of 91.2% and an F1 score of 90.6%. The accuracy of the cross-entropy method (91.6%), recall of 96.1%, and loss of 0.267 were achieved. The cross-entropy + soft target loss + KL divergence method achieved an accuracy of 91.3%, an F1 score of 90.8%, a recall of 87.3%, and a loss of 0.273. The cross-entropy + soft target loss + functional API method achieved an accuracy of 91.3%, an F1 score of 90.8%, a recall of 86.7%, and a loss of 0.276. The optimal method of this invention, using cross-entropy pre-training with an increased learning rate, achieved the best overall performance under five-fold cross-validation: a validation set accuracy of 91.7%, an F1 score of 91.2%, a recall of 96.3%, and a loss of 0.256. All key indicators were superior to other comparative methods, verifying the effectiveness of the method of this invention.

[0072] 5. Model Deployment Optimization: After dynamic quantization, the model size was compressed from the original 4.8MB to 1.2MB, a compression ratio of about 4 times, and the inference time was reduced from about 1 second to less than 0.5 seconds, meeting the deployment requirements for real-time field detection.

[0073] Example 3: This invention provides a leaf-level indirect detection system for tomato leafminer larvae based on a lightweight model, integrating the detection method described in Example 1 into a complete, deployable system. The system adopts a modular architecture design, with each module having independent functions and clear interfaces, facilitating engineering expansion and maintenance. The system comprises three core components: a data acquisition and processing module S100, a model building module S200, and a pest detection visualization module S300. These modules collaborate through standardized data interfaces to achieve a complete detection process from image input to result output.

[0074] The data acquisition and processing module S100 is responsible for the system's data input and preprocessing. It receives RGB images of tomato leaves from field image acquisition equipment, performs size normalization to 224×224 pixels, ImageNet standardization, and format conversion, and outputs standardized image data that conforms to the model input specifications. The model building module S200 encapsulates a complete knowledge distillation training process, including pre-training of the teacher model ResNet34, knowledge distillation training based on multiple loss functions, and multi-stage fine-tuning optimization for the tomato leafminer specific task. Finally, it outputs a compressed and optimized pest image-level detection model. The pest detection visualization module S300 is responsible for inference deployment. It loads the quantized pest image-level detection model in ONNX format, performs forward inference on the input image, and outputs the classification result of health or pest and the corresponding confidence score.

[0075] The model building module includes:

[0076] The initial model building unit constructs a pre-trained deep convolutional neural network as the teacher model and a lightweight convolutional neural network as the student model, defining the number of network layers and structure. The model knowledge distillation unit inputs the second historical image data into the teacher model and student model, and obtains the distilled student model based on the knowledge distillation optimization algorithm. The model fine-tuning unit fine-tunes the distilled student model based on tomato leaf image data with different levels of pest damage, obtaining an image-level detection model for tomato leafminer pests.

[0077] This system utilizes a visual detection interface developed using MATLAB App Designer and supports automatic loading of ONNX format models. Users upload images of tomato leaves to be detected (JPG, PNG, and BMP formats are supported). The system automatically performs preprocessing operations such as resizing to 224×224 and normalization, then calls a pest image-level detection model to infer and output the classification results (healthy or pest-infested) and their confidence scores. The results are displayed on the interface in green and red, respectively, with an inference time of less than one second. The interface layout is modular, easy to operate, and expandable to support batch image detection.

[0078] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments for application in other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model, comprising: Step 1: a data acquisition and processing step, acquiring RGB image data of the tomato leaf pest as first historical image data, and performing data preprocessing to obtain second historical image data; Step 2: a model construction step, constructing a pest image-level detection model including a teacher model and a student model; Step 3: a pest detection step, inputting the leaf image to be tested into the pest image-level detection model to obtain the pest image-level detection result; characterized in that: The model building steps transfer the knowledge of the pre-trained teacher model to the lightweight student model through a knowledge distillation algorithm based on cross-entropy loss, soft target loss, and neighborhood knowledge distillation loss, and construct an image-level detection model for tomato leafminer larvae pests through multi-stage fine-tuning.

2. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The data acquisition and processing steps include: acquiring RGB image data of insect pests on sample tomato leaves as first historical image data; performing preprocessing operations on the RGB images: noise reduction and data enhancement processing, image cropping, normalization and labeling processing, uniformly normalizing the leaf area to a preset uniform size, labeling based on insect pest characteristics, and obtaining preprocessed second historical image data.

3. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The teacher model is a deep convolutional neural network pre-trained on a large-scale image dataset, which has feature extraction capabilities and classification performance; the student model is a lightweight convolutional neural network with fewer parameters than the teacher model, which is suitable for deployment on resource-constrained mobile devices or embedded systems.

4. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The knowledge distillation algorithm achieves multi-level knowledge transfer by combining the following three types of loss functions: cross-entropy loss, soft target loss, and neighborhood knowledge distillation loss. These three loss functions are combined in a weighted manner, and the optimal combination is determined through automatic hyperparameter search.

5. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 4, characterized in that, In the knowledge distillation process, feature representations of the intermediate layer between the teacher model and the student model are aligned using a feature adapter. The feature adapter consists of a convolutional layer, a batch normalization layer, and an average pooling layer, which are used to adapt the dimension of the feature map of the intermediate layer of the teacher model to the dimension of the corresponding layer of the student model, thereby realizing multi-level feature knowledge transfer across architectures.

6. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The multi-stage fine-tuning includes the following three stages: (1) Layer selection stage: Calculate the cosine similarity between the weights of each network layer of the student model and the data distribution of the target task, thereby evaluating the contribution of each layer to the tomato leafminer pest detection task, selecting the network layer with the highest contribution as the fine-tuning target layer, and freezing the parameters of the remaining layers to prevent overfitting; (2) Layer fine-tuning stage: Supervised training of the selected network layers with a small learning rate, using the cross-entropy loss function to supervise the classification performance, so that the model can quickly adapt to the specific data distribution of tomato leaf pest detection; (3) Knowledge distillation fine-tuning stage: In a longer training period, determine the optimal combination of learning rate and loss weight through the automatic hyperparameter search method, and dynamically adjust the learning rate in combination with the cosine annealing hot restart strategy, while continuing to apply knowledge distillation constraints to further improve the detection accuracy and generalization ability of the student model on the target task.

7. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The leaf image to be tested is an RGB image of a tomato leaf containing signs of infestation by tomato leafminer larvae. The larvae feed on the leaf tissue inside the leaf, forming characteristic signs of pest damage on the leaf surface, such as tunnels that are difficult to observe directly with the naked eye. The pest image-level detection model indirectly infers the infestation status of the larvae by identifying the above-mentioned tunnel features, thereby achieving early detection of tomato leafminer larvae damage.

8. The leaf-level indirect detection method for tomato leafminer larvae based on a lightweight model according to claim 1, characterized in that, The pest detection step also includes: performing dynamic quantization processing on the fine-tuned pest image-level detection model, converting floating-point operations into integer operations to reduce computational overhead and memory usage, and then exporting the quantized model in ONNX format to achieve cross-platform compatibility, enabling the model to be easily deployed in resource-constrained hardware environments such as mobile devices and edge computing devices.

9. A leaf-level indirect detection system for tomato leafminer larvae based on a lightweight model, characterized in that, include: The data acquisition and processing module is used to acquire RGB image data of sample tomato leaves and preprocess them, normalize the leaf images to a uniform size and complete the category labeling, and output standardized image data. The model building module is used to build a pre-trained teacher model and a lightweight student model. It transfers knowledge from the teacher model to the student model by combining knowledge distillation algorithms with multiple loss functions, and performs multi-stage fine-tuning on the student model to obtain an image-level detection model for tomato leafminer larvae. The pest detection visualization module is used to receive leaf images uploaded by users, call the pest image-level detection model for inference, and output the detection results in the form of different color labels and confidence scores.