Corn complex pest detection and identification method and system based on lightweight ViT model
By adopting a knowledge distillation network based on the lightweight VIT model in the cornworm detection system, the existing system has the problem of poor performance in the corn growth cycle and cannot recognize insect pests, and achieves efficient cornworm pest testing and identification.
Patent Information
- Application Number
- CN202410559045.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-05-08
AI Technical Summary
The existing corn pest detection system performs poorly during the corn growth cycle and cannot effectively identify the pest categories, resulting in the inability to take timely prevention and control measures.
A method for detecting and identifying complex corn pests based on lightweight ViT models is adopted. By constructing a knowledge distillation network model, the pre-trained large ViT model is used as a teacher model and the lightweight ViT model is used as a student model to perform feature extraction and classifier construction to achieve pest control. Detection and identification.
Through knowledge distillation technology, the lightweight ViT model can effectively learn the attention features and class label knowledge of the pre-trained large model, improve detection performance, identify corn pests in real time and issue alarms, and convey pest type and quantity information.
Smart Images

Figure QLYQS_1 
Figure QLYQS_2 
Figure QLYQS_3
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection, and in particular to a method and system for detecting and identifying complex corn pests based on a lightweight ViT model. Background Art
[0002] Corn is an important food crop and feed source in my country, and its annual total output is related to national food security. Therefore, corn pest control is crucial to ensure corn yield and quality safety. However, corn will be attacked by different pests at different stages of its growth. In the seedling stage, it may be threatened by pests such as aphids, corn thrips, and cutworms, which will cause spots and deformation on corn leaves, or even the whole plant to die; in the jointing stage, it may be threatened by pests such as armyworms, fall armyworms, and corn borers, which will cause corn stalks to break and leaves to be eaten; in the heading and maturity stages, it may be threatened by pests such as corn borers, cotton bollworms, and corn spider mites, which will lead to a significant decrease in corn yield and quality.
[0003] Therefore, corn is threatened by a variety of pests during its growth process. These pests are characterized by smallness, complexity, strong reproduction, strong ecological adaptability and pesticide resistance. On smart agricultural equipment with limited computing power and insufficient memory space, the existing corn pest detection system performs poorly throughout the corn growth cycle. When the system detects pest threats, the pests have already caused serious losses. At the same time, the existing system cannot identify the types of pests well, and thus cannot take corn pest control measures according to local conditions. Summary of the invention
[0004] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0005] In view of the problems existing in the existing corn complex insect pest detection and identification method and system based on the lightweight ViT model, the present invention is proposed.
[0006] In order to solve the above technical problems, the present invention provides the following technical solution: a method for detecting and identifying complex corn pests based on a lightweight ViT model, comprising the following steps:
[0007] Step 1: Obtain corn pest image sample data;
[0008] Step 2: Construct the ViT model knowledge distillation network model, which includes the teacher network model and the student network model;
[0009] Step 3: Extract sample features;
[0010] Step 4: Extract students’ new attention features;
[0011] Step 5: Construct a student classifier, that is, perform multi-layer perception on the teacher class mark and the student's new attention features to form a student classifier, which is used for the corn complex pest detection and recognition task;
[0012] Step 6: Construct the attention feature distillation loss; use the mean square error loss function to calculate the distance loss between the teacher's attention feature and the new student's attention feature;
[0013] Step 7: Construct the knowledge distillation loss of the student network output logits; that is, construct the cross entropy loss between the prediction results of the student network model and the label data, the Kullback-Leibler difference loss between the teacher and student output logits, and the neighborhood relationship knowledge distillation loss;
[0014] Step 8: Construct the total loss function; the total loss includes the attention feature loss and the student output logits distillation loss;
[0015] Step 9: Train the student model; use the total loss function calculated in step 8 to train the student network model, and back-propagate, update the parameters of the student network model, and iterate the student classifier to obtain the trained student network model and student classifier;
[0016] Step 10: Real-time detection and identification of corn pest images; detect and identify real-time monitoring images of corn leaves and roots, use the student model classifier to output the detection results, issue an alarm when a pest threat is detected, and pass information such as the number of detected pest types to the smart agriculture platform.
[0017] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model described in the present invention, wherein: during the step one, the acquired corn pest image sample data is preprocessed, and the preprocessing includes random image cropping, image fusion and image regularization.
[0018] As a preferred solution of the corn complex insect pest detection and identification method based on the lightweight ViT model described in the present invention, wherein: during the step three, the preprocessed corn pest image sample data is respectively input into the pretrained teacher network model and the untrained student network model to obtain the feature map of the middle layer of the encoder output of the teacher network model and the student network model, which includes attention features and class marks, as well as the logits features output by the teacher network model and the student network model through the multi-layer perceptron.
[0019] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model described in the present invention, in which: in the process of step 4, the method of extracting the new attention features of students is:
[0020] Output feature f through the student encoder s After the linear alignment module Align(·), the student feature dimension D s Alignment of teacher characteristics dimension D t , summarized as:
[0021] Align(f s )→f t ;
[0022] Among them, Align(·) will reshape the student features f with a small cost s With f t The dimensions of teacher characteristics are the same;
[0023] The aligned student attention features are transformed into null values by the feature mask module Mask(·), which can be summarized as follows:
[0024]
[0025] Among them, i takes the value of [0, N-1] to represent the student attention characteristics of each module, r i is a random number in [0,1];
[0026] After alignment and masking, the student attention features will be transformed into new student attention features through the generation module G(·). Finally, the new student attention features are summarized as follows:
[0027]
[0028] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model described in the present invention, in which: in the step six, the mean square error loss L between the teacher's attention feature and the new student's attention feature gen It can be summarized as:
[0029]
[0030] Where N represents the number of modules of the teacher's attention feature, and D represents the dimension of each module of the teacher's attention feature.
[0031] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model of the present invention, in which: in the process of step 7, the cross entropy loss L between the prediction result of the student network model and the label data CE, and the Kullback-Leibler difference loss L between the teacher and student output logits KL , summarized as:
[0032]
[0033] in, and represents the final prediction results of the student and teacher networks, y represents the real label data; γ1 and γ2 are hyperparameters for balancing the two loss weights; the temperature T is the cross entropy loss L CE is set to 1 in the Kullback-Leibler difference loss L KL is set to more than 1; T 2 This is to compensate for the temperature-induced L KL The weights set to reduce the loss value.
[0034] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model of the present invention, in which: in the process of step eight, when constructing the total loss function, the total loss function L total for:
[0035] L total =αL gen +βL KD ;
[0036] Among them, α and β represent the hyperparameters of the balance loss term, L gen represents the mean square error loss between the teacher's attention features and the student's new attention features, L KD Represents the knowledge distillation loss of the student network output logits.
[0037] As a preferred solution of the corn complex pest detection and identification method based on the lightweight ViT model of the present invention, the specific method of updating the parameters of the student network model during the step is as follows:
[0038] Use the total loss function to train the student network model, and back propagate to update the parameters of the student network model and iterate the student classifier, where the parameters are:
[0039] θ s =θ s -εθ s L total ;
[0040] Among them, θ s represents the parameters of the student network model, ε represents the learning rate, Represents the total loss function L total Compute the gradients of the student network parameters.
[0041] A system applied to the above-mentioned corn complex pest detection and identification method based on the lightweight ViT model comprises the following steps:
[0042] Corn pest image sample data acquisition module, used to acquire various corn pest image sample data and label data;
[0043] The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes a teacher network model and a student network model. The teacher network model adopts a large ViT model, and the student network model adopts a lightweight ViT model. The teacher model is pre-trained on the IDADP (Index Database of Agricultural Diseases and Insects).
[0044] The sample feature extraction module inputs the preprocessed corn pest image sample data into the pre-trained teacher network model and the untrained student network model respectively, and obtains the feature map of the middle layer of the encoder output of the teacher network model and the student network model, which contains the attention feature and class mark, as well as the logits feature output by the teacher network model and the student network model through the multi-layer perceptron;
[0045] The student feature alignment module uses a linear network to align student features with teacher feature dimensions;
[0046] The student attention feature masking module changes half of the student attention feature values to null values through the masking module to eliminate the student attention feature errors;
[0047] The student new attention feature generation module uses the convolutional projection method to fully map the teacher's attention features to the student network, so that the student's attention features can fully learn from the teacher and generate new student attention features;
[0048] The student classifier building module uses the teacher class mark and the student's new attention features for multi-layer perception to build a student classifier;
[0049] The attention feature distillation loss building block is used to calculate the mean squared error loss between the new student attention features and the teacher attention features;
[0050] The student output loss function building block is used to calculate the cross entropy loss between the prediction results of the student network model and the labeled data, the Kullback-Leibler difference loss between the teacher and student output logits (output prediction probabilities), and the neighborhood relation knowledge distillation loss;
[0051] The total loss function building module is used to build the total loss function. The total loss includes the attention feature loss and the student output loss.
[0052] The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model and iterate the student classifier to obtain a mature student network model and student classifier;
[0053] The corn pest image real-time detection and identification module is used to detect and identify real-time monitoring images of corn leaves and roots. It uses the student model classifier to output the detection results. When a pest threat is detected, an alarm will be issued and information such as the number of detected pest types will be transmitted to the smart agriculture platform.
[0054] Beneficial effects of the present invention:
[0055] 1. The present invention uses the intermediate layer feature knowledge and output layer decision knowledge of the pre-trained large model to guide the lightweight model training, so that the performance of the lightweight model is greatly improved. For the output layer decision knowledge, the lightweight model is trained and learned by calculating the Kullback-Leibler difference loss between it and the output logits (output prediction probability) of the pre-trained large model. For the intermediate layer feature knowledge, the lightweight model of the present invention can use different knowledge transfer methods to learn the intermediate layer attention feature knowledge and the rich classification knowledge contained in the class mark from the pre-trained large model;
[0056] 2. The present invention enables the lightweight ViT model to effectively learn the rich classification knowledge contained in the middle-layer attention feature knowledge and class mark of the pre-trained large model. In the constructed ViT knowledge distillation network model, the pre-trained ViT large model is called the teacher model, and the lightweight ViT model is called the student model. For the transfer of attention feature knowledge, the student attention feature is first aligned with the teacher's deep attention feature through a linear module, and then half of it is masked, and finally the teacher's attention feature is learned to generate the student's new attention feature by convolution projection. By calculating the mean square error loss between the new student attention feature and the teacher's attention feature, the student model can fully learn the teacher model's attention feature knowledge. For the transfer of class mark classification knowledge, the teacher's class mark is completely copied to the student model, and through multi-layer perception with the student's new attention feature, the student model will generate an excellent classifier for the detection and identification task of corn complex pests. Finally, by calculating the total distillation loss, the student model back-propagates the gradient, thereby updating the network parameters, changing the classifier, and improving the effect of corn complex pest detection and identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0058] Figure 1 This is a schematic diagram of the main process of the corn complex pest detection and identification method based on the lightweight ViT model proposed in the present invention. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0060] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0061] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0062] Reference Figure 1 , is an embodiment of the present invention, and provides a method and system for detecting and identifying complex corn pests based on a lightweight ViT model, the method comprising the following steps:
[0063] Step 1: Obtain corn pest image sample data, and preprocess the acquired corn pest image sample data, the preprocessing includes image random cropping, image fusion and image regularization;
[0064] Step 2: Construct the ViT model knowledge distillation network model, which includes a teacher network model and a student network model. Use the knowledge distillation network model construction module to construct the ViT model knowledge distillation network model, including a teacher network model and a student network model. The teacher network model uses a large ViT model, and the student network model uses a lightweight ViT model. The teacher model is pre-trained on the Agricultural Pest and Disease Research Database (IDADP);
[0065] Step 3: Extract sample features. Input the preprocessed corn pest image sample data into the pre-trained teacher network model and the untrained student network model respectively to obtain the feature map of the middle layer of the encoder output of the teacher network model and the student network model, which contains the attention features and class marks, as well as the logits features output by the teacher network model and the student network model through the multi-layer perceptron.
[0066] Step 4: Extract new student attention features. The student attention features are first aligned with the teacher attention features through a linear module. Then, half of the student attention feature values are changed to null values through a student attention feature mask module. Finally, the convolution projection method is used to fully map the teacher attention features to the student network, so that the student can fully learn from the teacher and generate new student attention features.
[0067] The way to extract new attention features of students is:
[0068] Output feature f through the student encoder s After the linear alignment module Align(·), the student feature dimension D s Alignment of teacher characteristics dimension D t , summarized as:
[0069] Align(f s )→f t ;
[0070] Among them, Align(·) will reshape the student features f with a small cost s With f t The dimensions of teacher characteristics are the same;
[0071] The aligned student attention features are transformed into null values by the feature mask module Mask(·), which can be summarized as follows:
[0072]
[0073] Among them, i takes the value of [0, N-1] to represent the student attention characteristics of each module, r i is a random number in [0,1];
[0074] After alignment and masking, the student attention features will be transformed into new student attention features through the generation module G(·). Finally, the new student attention features are summarized as follows:
[0075]
[0076] Step 5: Construct a student classifier, that is, perform multi-layer perception on the teacher class mark and the student's new attention features to form a student classifier, which is used for the corn complex pest detection and recognition task;
[0077] Step 6: Construct the attention feature distillation loss; use the mean square error loss function to calculate the distance loss between the teacher's attention feature and the new student's attention feature, the mean square error loss L between the teacher's attention feature and the new student's attention feature gen It can be summarized as:
[0078]
[0079] Where N represents the number of modules of the teacher's attention feature, and D represents the dimension of each module of the teacher's attention feature;
[0080] Step 7: Construct the knowledge distillation loss of the student network output logits; that is, construct the cross entropy loss between the prediction results of the student network model and the label data, the Kullback-Leibler difference loss between the teacher and student output logits, and the neighborhood relationship knowledge distillation loss;
[0081] The cross entropy loss L between the prediction results of the student network model and the labeled data CE , and the Kullback-Leibler difference loss L between the teacher and student output logits KL , summarized as:
[0082]
[0083] in, and represents the final prediction results of the student and teacher networks, y represents the real label data; γ1 and γ2 are hyperparameters for balancing the two loss weights; the temperature T is the cross entropy loss L CE is set to 1 in the Kullback-Leibler difference loss L KL is set to more than 1; T 2 This is to compensate for the temperature-induced L KL The weights set to reduce the loss value.
[0084] Step 8: Construct the total loss function; the total loss includes the attention feature loss and the student output logits distillation loss. When constructing the total loss function, the total loss function L total for:
[0085] L total =αL gen +βL KD ;
[0086] Among them, α and β represent the hyperparameters of the balance loss term, L gen represents the mean square error loss between the teacher's attention features and the student's new attention features, L KDRepresents the knowledge distillation loss of the student network output logits;
[0087] Step 9: Train the student model; use the total loss function calculated in step 8 to train the student network model, and back-propagate, update the parameters of the student network model, and iterate the student classifier to obtain the trained student network model and student classifier;
[0088] The specific method for updating the parameters of the student network model is:
[0089] Use the total loss function to train the student network model, and back propagate to update the parameters of the student network model and iterate the student classifier, where the parameters are:
[0090] θ s =θ s -εθ s L total ;
[0091] Among them, θ s represents the parameters of the student network model, ε represents the learning rate, Represents the total loss function L total Compute the gradients of the student network parameters.
[0092] Step 10: Real-time detection and identification of corn pest images; detect and identify real-time monitoring images of corn leaves and roots, use the student model classifier to output the detection results, issue an alarm when a pest threat is detected, and pass information such as the number of detected pest types to the smart agriculture platform.
[0093] In summary, the identification system of corn complex pest detection and identification method based on lightweight ViT model includes the following steps:
[0094] Corn pest image sample data acquisition module, used to acquire various corn pest image sample data and label data;
[0095] The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes a teacher network model and a student network model. The teacher network model adopts a large ViT model, and the student network model adopts a lightweight ViT model. The teacher model is pre-trained on the IDADP (Index Database of Agricultural Diseases and Insects).
[0096] The sample feature extraction module inputs the preprocessed corn pest image sample data into the pre-trained teacher network model and the untrained student network model respectively, and obtains the feature map of the middle layer of the encoder output of the teacher network model and the student network model, which contains the attention feature and class mark, as well as the logits feature output by the teacher network model and the student network model through the multi-layer perceptron;
[0097] The student feature alignment module uses a linear network to align student features with teacher feature dimensions;
[0098] The student attention feature masking module changes half of the student attention feature values to null values through the masking module to eliminate the student attention feature errors;
[0099] The student new attention feature generation module uses the convolutional projection method to fully map the teacher's attention features to the student network, so that the student's attention features can fully learn from the teacher and generate new student attention features;
[0100] The student classifier building module uses the teacher class mark and the student's new attention features for multi-layer perception to build a student classifier;
[0101] The attention feature distillation loss building block is used to calculate the mean squared error loss between the new student attention features and the teacher attention features;
[0102] The student output loss function building block is used to calculate the cross entropy loss between the prediction results of the student network model and the labeled data, the Kullback-Leibler difference loss between the teacher and student output logits (output prediction probabilities), and the neighborhood relation knowledge distillation loss;
[0103] The total loss function building module is used to build the total loss function. The total loss includes the attention feature loss and the student output loss.
[0104] The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model and iterate the student classifier to obtain a mature student network model and student classifier;
[0105] The corn pest image real-time detection and identification module is used to detect and identify real-time monitoring images of corn leaves and roots. It uses the student model classifier to output the detection results. When a pest threat is detected, an alarm will be issued and information such as the number of detected pest types will be transmitted to the smart agriculture platform.
[0106] In summary, the specific application of this system is that multiple cameras set up in the corn field will monitor the corn leaves and roots in real time, and transmit the monitoring images to the corn pest detection and identification system every 30 seconds. The system uses a lightweight ViT model classifier to output the detection results. When the system detects a certain pest threat, it will issue an alarm prompt and transmit information such as the number of detected pest species to the smart agriculture platform. The smart agriculture platform will adopt corresponding corn pest control strategies for the corresponding areas based on the pest information received. At the same time, the smart agriculture platform can use pest information to reversely infer soil and meteorological conditions, thereby helping to formulate more scientific and reasonable agricultural production plans.
[0107] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for detecting and identifying complex corn pests based on a lightweight ViT model, characterized in that: The following steps are involved: Step 1: Obtain corn pest image sample data; Step 2: Construct the ViT model knowledge distillation network model, which includes the teacher network model and the student network model; Step 3: Extract sample features; Step 4: Extract new attention features of students by: The student encoder outputs the feature f and passes through the linear alignment module Align(·) to convert the student feature dimension D s Alignment of teacher characteristics dimension D t , summarized as: Align(f s )→f t ; Among them, Align(·) will reshape the student features f at a small cost s With f t The dimensions of teacher characteristics are the same; The aligned student attention features are transformed into null values by the feature mask module Mask(·), which can be summarized as follows: Among them, i takes the value of [0, N-1] to represent the student attention characteristics of each module, r i is a random number in [0,1]; After alignment and masking, the student attention features will be transformed into new student attention features through the generation module G(·). Finally, the new student attention features are summarized as follows: Step 5: Construct a student classifier, that is, perform multi-layer perception on the teacher class mark and the student's new attention features to form a student classifier, which is used for the corn complex pest detection and recognition task; Step 6: Construct the attention feature distillation loss; use the mean square error loss function to calculate the distance loss between the teacher's attention feature and the new student's attention feature; Step 7: Construct the student network to output logits knowledge distillation loss; Step 8: Construct the total loss function; the total loss includes the attention feature loss and the student output logits distillation loss; Step 9: Train the student model; use the total loss function calculated in step 8 to train the student network model, and back-propagate, update the parameters of the student network model, and iterate the student classifier to obtain the trained student network model and student classifier; Step 10: Real-time detection and identification of corn pest images; detect and identify real-time monitoring images of corn leaves and roots, use the student model classifier to output the detection results, issue an alarm when a pest threat is detected, and pass the detected pest type and quantity information to the smart agriculture platform.
2. The method for detecting and identifying complex corn pests based on a lightweight ViT model according to claim 1, characterized in that: In the process of step 1, the acquired corn insect pest image sample data is preprocessed, and the preprocessing includes random image cropping, image fusion and image regularization.
3. The method for detecting and identifying complex corn pests based on the lightweight ViT model according to claim 2, characterized in that: During the step three, the preprocessed corn pest image sample data is respectively input into a pretrained teacher network model and an untrained student network model to obtain feature maps of the middle layer of the encoder output of the teacher network model and the student network model, which include attention features and class labels, as well as logits features output by the teacher network model and the student network model through a multi-layer perceptron.
4. The method for detecting and identifying complex corn pests based on a lightweight ViT model according to claim 3, characterized in that: In the process of step 6, the mean square error loss L between the teacher's attention feature and the new student's attention feature gen It can be summarized as: Where N represents the number of modules of the teacher's attention feature, and D represents the dimension of each module of the teacher's attention feature.
5. The method for detecting and identifying complex corn pests based on a lightweight ViT model according to claim 4, characterized in that: In step 7, the cross entropy loss L between the prediction results of the student network model and the label data is CE , and the Kullback-Leibler difference loss L between the teacher and student output logits KL , summarized as: in, and represents the final prediction results of the student and teacher networks, y represents the real label data; γ1 and γ2 are hyperparameters that balance the weights of the two losses; the temperature T is the cross entropy loss L CE is set to 1 in the Kullback-Leibler difference loss L KL is set to more than 1; T 2 This is to compensate for the temperature-induced L KL The weights set to reduce the loss value.
6. The method for detecting and identifying complex corn pests based on a lightweight ViT model according to claim 5, characterized in that: In the process of step 8, when constructing the total loss function, the total loss function L total for: L total =αL gen +βL KD ; Among them, α and β represent the hyperparameters of the balance loss term, L gen represents the mean square error loss between the teacher's attention features and the student's new attention features, L KD Represents the knowledge distillation loss of the student network output logits.
7. The method for detecting and identifying complex corn pests based on a lightweight ViT model according to claim 6, characterized in that: In the process of step nine, the specific method of updating the parameters of the student network model is as follows: Use the total loss function to train the student network model, and back propagate to update the parameters of the student network model and iterate the student classifier, where the parameters are: i s =θ s -eth s L total ; Among them, θ s represents the parameters of the student network model, ε represents the learning rate, Represents the total loss function L total Compute the gradients of the student network parameters.
8. The identification system of the corn complex pest detection and identification method based on the lightweight ViT model according to claim 7 is characterized in that: The system includes the following modules: Corn pest image sample data acquisition module, used to acquire various corn pest image sample data and label data; The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes a teacher network model and a student network model. The teacher network model adopts a large ViT model, and the student network model adopts a lightweight ViT model. The teacher model is pre-trained on the agricultural pest research image library. The sample feature extraction module inputs the preprocessed corn pest image sample data into the pre-trained teacher network model and the untrained student network model respectively, and obtains the feature map of the middle layer of the encoder output of the teacher network model and the student network model, which contains the attention feature and class mark, as well as the logits feature output by the teacher network model and the student network model through the multi-layer perceptron; The student feature alignment module uses a linear network to align student features with teacher feature dimensions; The student attention feature masking module changes half of the student attention feature values to null values through the masking module to eliminate the student attention feature errors; The student new attention feature generation module uses the convolutional projection method to fully map the teacher's attention features to the student network, so that the student's attention features can fully learn from the teacher and generate new student attention features; The student classifier building module uses the teacher class mark and the student's new attention features for multi-layer perception to build a student classifier; The attention feature distillation loss building block is used to calculate the mean squared error loss between the new student attention features and the teacher attention features; The student output loss function building block is used to calculate the cross entropy loss between the prediction results of the student network model and the labeled data, the Kullback-Leibler difference loss between the teacher and student output logits, and the neighborhood relation knowledge distillation loss; The total loss function building module is used to build the total loss function. The total loss includes the attention feature loss and the student output loss. The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model and iterate the student classifier to obtain a mature student network model and student classifier; The corn pest image real-time detection and identification module is used to detect and identify real-time monitoring images of corn leaves and roots. It uses the student model classifier to output the detection results. When a pest threat is detected, an alarm will be issued and the number of detected pest types will be transmitted to the smart agriculture platform.
Citation Information
Patent Citations
Plant leaf disease detection and classification method based on Vision Transform model
CN115100468A
Joint training of network architecture search and multi-task dense prediction models for edge deployment
US20230409867A1