Small sample pest detection method based on multi-dimensional hyperspherical feature consistency regularization

The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization solves the problem of large intra-class differences and small inter-class differences in crop pest detection, and achieves accurate detection and differentiation when labeled data is insufficient, thereby improving the accuracy and efficiency of pest detection.

CN117611903BActive Publication Date: 2026-11-27SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311601178.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-27
Publication Date
2026-11-27
Estimated Expiration
2043-11-27

AI Technical Summary

Technical Problem

Existing small-sample pest detection methods struggle to accurately detect and distinguish between known and unknown pest classes when there is insufficient labeled data, especially when there are large intra-class differences and small inter-class differences in the characteristics of crop pests.

Method used

A small-sample pest detection method using multidimensional hyperspherical feature consistency regularization is proposed. This method constructs a base class support set, a query set, a small-sample support set, and a query set, and performs two-stage training optimization using the total loss function. It also combines an embedding network, a variational autoencoder, and a hyperspherical feature consistency regularization module to improve feature discrimination capability.

Benefits of technology

In the absence of sufficient pest marker data, it can accurately detect known pest types and distinguish between known and unknown pest types, thus improving detection accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117611903B_ABST
    Figure CN117611903B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on multi-dimensional hyperspherical surface feature consistency regularization small sample pest detection method, it is related to the technical field of small sample detection, including obtaining existing pest dataset, constructing base class support set, base class query set, small sample support set and small sample query set;Utilize base class support set and base class query set to the small sample pest detection model constructed is carried out first stage training optimization, when total loss function value reaches minimum, obtain preliminary training small sample pest detection model;Utilize small sample support set and small sample query set to preliminary training small sample pest detection model is carried out second stage training optimization, when total loss function value reaches minimum, obtain after optimization small sample pest detection model;The small sample pest picture to be detected is input in after optimization small sample pest detection model, obtains detection result.The application can accurately and quickly detect the kind of small sample pest under the scene that pest mark data is insufficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of small sample detection, and more specifically, to a small sample pest detection method based on multidimensional hyperspherical feature consistency regularization. Background Technology

[0002] Real-time pest monitoring is a crucial part of crop production. Traditionally, pest monitoring is done manually, which is time-consuming and labor-intensive. In recent years, there has been a trend towards using deep learning to achieve intelligent pest monitoring. However, the acquisition of labeled pest data required for developing intelligent pest monitoring methods is costly.

[0003] Currently, target detection methods based on few-shot learning require first training a deep model on common classes with sufficient samples, and then transferring the trained deep model to learning new classes with only a few examples. Target detection methods based on few-shot learning are mainly divided into the following two types: (1) Meta-learning-based methods; among them, the method proposed by Yan et al. is called Meta R-CNN, which uses the Faster R-CNN network as the base network, adds a meta-learner to the base network, and designs a Predictor-head Remodeling Network (PRN); it uses K samples from each of the C labeled categories as the support set, performs a channel-wise dot product with the features to be detected, and weights the results to the detection head; in addition, the Attention RPN proposed by Fan et al. also uses the Faster R-CNN network as the base network, and similar to the PRN in Meta R-CNN, it averages the support set features to... The vector is used to perform sliding convolution on the feature to be detected, which associates the support set features with the feature to be detected. A contrastive training strategy is proposed to suppress false positives of the detection head to the background class by using the association between the support set and the feature to be detected. Han added variational autoencoders (VAE) to the Meta R-CNN to reconstruct the features, so as to expand the number of data samples and learn deeper feature information. (2) Based on the Two-stage Fine-tuning Approach (TFA); For example, Wang et al. first trained the Faster R-CNN network in the first stage, and then froze the parameters of the trained Faster R-CNN network except for the last layer in the second stage, and only fine-tuned the parameters of the last layer of the network, which can significantly improve the performance of the network when the sample size is small; Sun et al. added a contrast network parallel to the classification network at the end of the network during the second stage training, used a multi-layer perceptron head to calculate the similarity score between the features to be detected, and used CPE (Contrastive Proposal Encoding, CPE) loss to optimize the contrast network, so as to maximize the consistency between the same category and promote the difference between different categories.

[0004] However, existing studies are all based on public datasets, where the categorical features have significant inter-class differences, making them relatively easy to distinguish and achieving good detection performance. But the features of crop pests are characterized by large intra-class differences and small inter-class differences, which leads to poor performance of target detection models designed based on public datasets when directly transferred to small-sample pest detection tasks. The models cannot distinguish between new and old classes well, that is, the detection accuracy is low when known and unknown classes are mixed. Summary of the Invention

[0005] To overcome the shortcomings of existing technologies that cannot accurately detect small samples of pests in scenarios with insufficient pest labeling data, and that cannot distinguish between known and unknown pest classes, this invention provides a small sample pest detection method based on multidimensional hyperspherical feature consistency regularization. This method can accurately detect not only known pest classes but also accurately distinguish between known and unknown pest classes in scenarios with insufficient pest labeling data.

[0006] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows: This invention provides a small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization, comprising: S1: Obtain an existing pest dataset, and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset; S2: Construct a small-sample pest detection model and set the total loss function; S3: Input the base class support set and base class query set into the constructed small sample pest detection model for the first stage of training and optimization. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. S4: Input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches the minimum, the optimized small sample pest detection model is obtained. S5: Input the small sample pest images to be detected into the optimized small sample pest detection model to obtain the detection results.

[0007] Preferably, the existing pest dataset includes a base class dataset and a new class dataset; Based on the base class dataset, construct a base class support set and a base class query set; based on the base class dataset and the new class dataset, construct a small sample support set and a small sample query set.

[0008] The base class dataset includes pest data for known classes, while the new class dataset includes pest data for newly added classes with unknown classes; data is randomly drawn from the base class dataset. There are 10 categories, and each category is randomly selected. Images of pests form the base class support set, from which images are extracted. A base class query set is composed of unique images of pests; random samples are then drawn from the base class dataset and the new class dataset. There are 10 categories, and each category is randomly selected. A small sample support set is composed of images of pests; samples are drawn from the selected categories. A small sample query set is composed of unique images of pests.

[0009] Preferably, the small sample pest detection model includes a first Embedding network module, a second Embedding network module, a variational autoencoder module, a first feature aggregation point, a hyperspherical feature consistency regularization module, a first fully connected layer, and a second fully connected layer. The input terminals of the first Embedding network module and the second Embedding network module are the input terminals of the small sample pest detection model; The output of the first Embedding network module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the second Embedding network module is connected to the input of the variational autoencoder module, and the output of the variational autoencoder module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the first feature aggregation point is connected to the input of the first fully connected layer; The output of the hyperspherical feature consistency regularization module is connected to the input of the second fully connected layer. The outputs of the first and second fully connected layers are the outputs of the small-sample pest detection model.

[0010] Preferably, the first Embedding network module and the second Embedding network module have the same structure and share parameters, both including a backbone network, an RPN network, and a region of interest pooling layer; The input of the backbone network is the input of the Embedding network module, and the output of the backbone network is connected to the input of the RPN network and the Region of Interest (ROI) pooling layer, respectively. The output of the RPN network is connected to the input of the RPI pooling layer, and the output of the RPI pooling layer is the output of the Embedding network module.

[0011] Preferably, the variational autoencoder module includes an encoder, a sampling layer, and a decoder connected in sequence.

[0012] The variational autoencoder module performs variational autoencoding on the input features to enhance generalization.

[0013] Preferably, the hyperspherical feature consistency regularization module includes a multilayer perceptron and a second feature aggregation point connected in sequence.

[0014] The hyperspherical feature consistency regularization module uses a multilayer perceptron as the mapping head to project features onto hyperspheres of different dimensions. This reduces the distance between features of the same category while increasing the distance between features of different categories. It then applies multidimensional hyperspherical feature consistency regularization constraints, followed by a dot product operation at the second feature aggregation point to achieve feature aggregation. This further shortens the distance between similar features, allowing for full utilization of the information contained in pest features from multiple dimensions. The module not only measures the distance between features and other features within the same dimension but also between features from multiple different dimensions. This fully utilizes limited data while significantly increasing the distance between different categories, improving the expressive power of features without significantly increasing computational load, thereby enhancing the ability to distinguish pest features.

[0015] Preferably, the total loss function includes a classification loss function, a cosine loss function, and a binary cross-entropy loss function, specifically:

[0016] In the formula This represents the total loss function value. This represents the classification loss function value. This represents the value of the cosine loss function. Represents the binary cross-entropy loss function. These represent the first, second, and third loss weights, respectively.

[0017] Preferably, step S3 includes: S3.1: Input the base class query set into the first Embedding network module for feature extraction to obtain base class query set instance features; input the base class support set into the second Embedding network module, and sequentially perform feature extraction through the second Embedding network module and encoding through the variational autoencoder module to obtain base class support set instance variational features; S3.2: Input the base class query set instance features and base class support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first base class aggregated features; input the query set instance features and support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second base class aggregated features; S3.3: Input the first base class aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the base class query set; input the second base class aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the base class query set; S3.4: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the base class query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the base class query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value in different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the base class query set, and use the prediction probability loss value to apply consistency constraints to the first fully connected layer. S3.5: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S3.6: Update the model parameters of the small sample pest detection model. Repeat steps S3.1-3.5 until the total loss function value reaches its minimum. Save the corresponding model parameters as the initial model parameters to obtain the initially trained small sample pest detection model.

[0018] Preferably, step S4 includes: S4.1: Freeze the initial model parameters of the first Embedding network module, the second Embedding network module, the variational autoencoder module, the first feature aggregation point, and the hyperspherical feature consistency regularization module in the initially trained small sample pest detection model; S4.2: Input the small sample query set into the first Embedding network module for feature extraction to obtain small sample query set instance features, calculate the initial class weights of the first fully connected layer based on the small sample query set instance features and save them; S4.3: The small sample support set is input into the second Embedding network module, and features are extracted by the second Embedding network module and encoded by the variational autoencoder module in sequence to obtain the variational features of the small sample support set instances; S4.4: Input the small sample query set instance features and the small sample support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first small sample aggregated features; input the small sample query set instance features and the small sample support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second small sample aggregated features; S4.5: Input the first small sample aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the small sample query set; input the second small sample aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the small sample query set; S4.6: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the small sample query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the small sample query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value of different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the small sample query set, and use the prediction probability loss value to apply consistency constraints to the first fully connected layer. S4.7: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S4.8: Update the network parameters of the first fully connected layer and the second fully connected layer. Repeat steps S4.3-4.7 until the total loss function value reaches its minimum. Save the corresponding network parameters of the first fully connected layer and the second fully connected layer as the final network parameters of the first fully connected layer and the second fully connected layer to obtain the optimized small sample pest detection model.

[0019] The training optimization process of the small sample pest detection model in two stages involves finding a centroid for each category using features extracted from the new class dataset. This centroid is then used to initialize the weight parameters of the newly added categories in the fully connected layer. This avoids performance degradation caused by random parameter initialization, while improving the utilization of prior knowledge during the second stage of training. This approach better separates features of different categories and narrows the distance between features of the same category.

[0020] This invention also provides a small-sample pest detection system based on multidimensional hyperspherical feature consistency regularization, for implementing the above detection method, comprising: The data acquisition and construction module is used to acquire an existing pest dataset and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset. The model building module is used to build a small-sample pest detection model and set the total loss function; The first-stage training module is used to perform the first-stage training optimization of the small sample pest detection model constructed by inputting the base class support set and the base class query set. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. The model two-stage training module is used to input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches the minimum, the optimized small sample pest detection model is obtained. The pest detection module is used to input small sample images of pests to be detected into the optimized small sample pest detection model to obtain the detection results.

[0021] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention utilizes existing pest datasets to construct a base class support set, a base class query set, a few-sample support set, and a few-sample query set; it then constructs a few-sample pest detection model and sets a total loss function; the few-sample pest detection model is trained and optimized in the first stage using the base class support set and the base class query set to obtain an initially trained few-sample pest detection model; a second stage of training and optimization is then performed using the few-sample support set and the few-sample query set to obtain an optimized few-sample pest detection model; the optimized few-sample pest detection model can narrow the distance between features of the same category while widening the distance between features of different categories, improving the ability to distinguish pest features; based on the initially trained few-sample pest detection model obtained in the first stage, a second stage of training and optimization is performed using the few-sample support set and the few-sample query set, which avoids performance degradation caused by random parameter initialization while improving the utilization rate of prior knowledge during the second stage of training, better widening the distance between features of different categories and narrowing the distance between features of the same category; finally, the few-sample pest images to be detected are input into the optimized few-sample pest detection model to obtain the detection results. This invention can accurately and quickly detect the types of pests in small samples even when pest marker data is insufficient. Attached Figure Description

[0022] Figure 1 This is a flowchart of a small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization as described in Example 1; Figure 2 This is a schematic diagram of the structure of the small sample pest detection model described in Example 2.

[0023] Figure 3 This is a schematic diagram of the Embedding network module described in Example 2.

[0024] Figure 4 This is a schematic diagram of the variational autoencoder module described in Example 2.

[0025] Figure 5 This is a schematic diagram of the structure of the hyperspherical feature consistency regularization module described in Example 2.

[0026] Figure 6 This is a schematic diagram of the structure of a small-sample pest detection system based on multidimensional hyperspherical feature consistency regularization as described in Example 3. Detailed Implementation

[0027] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions; It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.

[0028] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0029] Example 1 This embodiment provides a small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization, such as... Figure 1 As shown, it includes: S1: Obtain an existing pest dataset, and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset; S2: Construct a small-sample pest detection model and set the total loss function; S3: Input the base class support set and base class query set into the constructed small sample pest detection model for the first stage of training and optimization. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. S4: Input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches the minimum, the optimized small sample pest detection model is obtained. S5: Input the small sample pest images to be detected into the optimized small sample pest detection model to obtain the detection results.

[0030] In this implementation, the following steps are taken: First, a base class support set, a base class query set, a few-sample support set, and a few-sample query set are constructed using an existing pest dataset. A few-sample pest detection model is then built, and a total loss function is set. The model is then trained and optimized in the first stage using the base class support set and the base class query set to obtain an initially trained model. Next, the model is trained and optimized in the second stage using the few-sample support set and the few-sample query set to obtain an optimized model. This optimized model can narrow the distance between features of the same category while widening the distance between features of different categories, thus improving the ability to distinguish pest features. Based on the initially trained model obtained in the first stage, the model is further trained and optimized in the second stage using the few-sample support set and the few-sample query set. This avoids performance degradation due to random parameter initialization while improving the utilization of prior knowledge during the second stage of training, better widening the distance between features of different categories and narrowing the distance between features of the same category. Finally, the few-sample pest images to be detected are input into the optimized model to obtain the detection results. This embodiment can accurately and quickly detect the types of pests in a small sample even when there is insufficient pest marker data.

[0031] Example 2 This embodiment provides a small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization, including: S1: Obtain an existing pest dataset, and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset; The existing pest dataset includes a base class dataset and a new class dataset; Based on the base class dataset, construct a base class support set and a base class query set; based on the base class dataset and the new class dataset, construct a small sample support set and a small sample query set. The base class dataset includes pest data for known classes, while the new class dataset includes pest data for newly added classes with unknown classes; data is randomly drawn from the base class dataset. There are 10 categories, and each category is randomly selected. Images of pests form the base class support set, from which images are extracted. A base class query set is composed of unique images of pests; random samples are then drawn from the base class dataset and the new class dataset. There are 10 categories, and each category is randomly selected. A small sample support set is composed of images of pests; samples are drawn from the selected categories. A small sample query set is composed of non-repeating images of pests. S2: Construct a small-sample pest detection model and set the total loss function; specifically: like Figure 2 The small-sample pest detection model shown includes a first Embedding network module, a second Embedding network module, a variational autoencoder module, a first feature aggregation point, a hyperspherical feature consistency regularization module, a first fully connected layer, and a second fully connected layer. The input terminals of the first Embedding network module and the second Embedding network module are the input terminals of the small sample pest detection model; The output of the first Embedding network module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the second Embedding network module is connected to the input of the variational autoencoder module, and the output of the variational autoencoder module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the first feature aggregation point is connected to the input of the first fully connected layer; The output of the hyperspherical feature consistency regularization module is connected to the input of the second fully connected layer. The outputs of the first and second fully connected layers are the outputs of the small-sample pest detection model. like Figure 3 As shown, the first Embedding network module and the second Embedding network module have the same structure and share parameters, both including a backbone network, an RPN network, and a region of interest pooling layer; The input of the backbone network is the input of the Embedding network module, and the output of the backbone network is connected to the input of the RPN network and the Region of Interest (ROI) pooling layer, respectively. The output of the RPN network is connected to the input of the RIO pooling layer, and the output of the RIO pooling layer is the output of the Embedding network module. like Figure 4 As shown, the variational autoencoder module includes an encoder, a sampling layer, and a decoder connected in sequence; the variational autoencoder module performs variational autoencoding on the input features to enhance generalization. like Figure 5 As shown, the hyperspherical feature consistency regularization module includes a multilayer perceptron and a second feature aggregation point connected in sequence. The hyperspherical feature consistency regularization module uses a multilayer perceptron as the mapping head to project features onto hyperspheres of different dimensions. This reduces the distance between features of the same category while increasing the distance between features of different categories. It then applies multidimensional hyperspherical feature consistency regularization constraints, followed by a dot product operation at the second feature aggregation point to achieve feature aggregation. This further shortens the distance between similar features, allowing for full utilization of the information contained in pest features from multiple dimensions. The module not only measures the distance between features and other features within the same dimension but also between features from multiple different dimensions. This fully utilizes limited data while significantly increasing the distance between different categories, improving the expressive power of features without significantly increasing computational load, thereby enhancing the ability to distinguish pest features.

[0032] The total loss function includes a classification loss function, a cosine loss function, and a binary cross-entropy loss function, specifically:

[0033] In the formula This represents the total loss function value. This represents the classification loss function value. This represents the value of the cosine loss function. Represents the binary cross-entropy loss function. These represent the first, second, and third loss weights, respectively. The formula for calculating the binary cross-entropy loss function is as follows:

[0034] In the formula, They refer to two different dimensions respectively. This represents the predicted probability of the output in this dimension.

[0035] S3: The base class support set and base class query set are input into the constructed small sample pest detection model for the first stage of training and optimization. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained, including: S3.1: The base class query set is input into the first Embedding network module for feature extraction to obtain the base class query set instance features; the base class support set is input into the second Embedding network module, and features are extracted by the second Embedding network module and encoded by the variational autoencoder module to obtain the base class support set instance variational features; S3.2: Input the base class query set instance features and base class support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first base class aggregated features; input the query set instance features and support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second base class aggregated features; S3.3: Input the first base class aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the base class query set; input the second base class aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the base class query set; S3.4: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the base class query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the base class query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value of different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the base class query set, and use the loss value to apply consistency constraints to the first fully connected layer. S3.5: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S3.6: Update the model parameters of the small sample pest detection model. Repeat steps S3.1-3.5 until the total loss function value reaches the minimum. Save the corresponding model parameters as the initial model parameters to obtain the initially trained small sample pest detection model. S4: Input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches its minimum, the optimized small sample pest detection model is obtained, including: S4.1: Freeze the initial model parameters of the first Embedding network module, the second Embedding network module, the variational autoencoder module, the first feature aggregation point, and the hyperspherical feature consistency regularization module in the initially trained small sample pest detection model; S4.2: Input the small sample query set into the first Embedding network module for feature extraction to obtain the small sample query set instance features. Calculate and save the initial class weights of the first fully connected layer based on the small sample query set instance features; specifically: The formula for calculating the feature mean of the new class weights of the new class dataset in a fully connected layer is:

[0036] in, The feature mean representing the weights of the new class. Indicates the new class dataset number Zhang Image The total number of images in the new class dataset. Indicates the first Data augmentation strategies For hyperparameters, Indicates the new class dataset number Instance features of a single image; The base class weights and new class weights are normalized and then concatenated. The concatenated weight parameters are used as the initial class weights.

[0037] in, This represents the weight parameters after concatenation. The base class weights obtained in step S3; S4.3: The small sample support set is input into the second Embedding network module, and features are extracted by the second Embedding network module and encoded by the variational autoencoder module in sequence to obtain the variational features of the small sample support set instances; S4.4: Input the small sample query set instance features and the small sample support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first small sample aggregated features; input the small sample query set instance features and the small sample support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second small sample aggregated features; S4.5: Input the first small sample aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the small sample query set; input the second small sample aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the small sample query set; S4.6: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the small sample query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the small sample query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value of different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the small sample query set, and use the prediction probability loss value to apply consistency constraints to the first fully connected layer. S4.7: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S4.8: Update the network parameters of the first fully connected layer and the second fully connected layer. Repeat steps S4.3-4.7 until the total loss function value reaches the minimum. Save the corresponding network parameters of the first fully connected layer and the second fully connected layer as the final network parameters of the first fully connected layer and the second fully connected layer to obtain the optimized small sample pest detection model. S5: Input the small sample pest images to be detected into the optimized small sample pest detection model to obtain the detection results.

[0038] In the specific implementation process, a base class support set, a base class query set, a small sample support set, and a small sample query set are constructed based on the existing IP102 pest dataset; the statistical data of the IP102 pest dataset are shown in Table 1 below: Table 1

[0039] The method provided in this embodiment is used to compare the few-shot learning results of traditional TFA, Meta R-CNN, and benchmark networks on the IP102 pest dataset. The number of support set instances extracted for each class is [not specified]. Set to 1 to determine the number of instances of each class in the query set. The values ​​were set to 1, 5, and 10; during testing, the evaluation metric was the Mean of Average Precision (mAP), and the average precision was AP50. The comparison results are shown in Table 2 below: Table 2

[0040] In the specific training process, different dimensions and numbers of hyperspherical feature consistency regularization modules can be added to the classification network of the baseline network. Specifically, this can be done by not adding a hyperspherical feature consistency regularization module, adding one module in 1024 dimensions, adding one module in 4096 dimensions, or adding one module each in 1024 and 4096 dimensions. The number of support set instances extracted for each class can also be adjusted. Set to 1 to determine the number of instances of each class in the query set. The values ​​were set to 1, 5, and 10; during testing, the evaluation metric was Mean of Average Precision (mAP), and the average precision was AP50. The comparison results are shown in Table 3 below: Table 3

[0041] Further testing and comparison of the detection results using the two-stage optimization training feature mean initialization method and the network parameter random initialization method of this implementation, and the number of support set instances extracted for each class. Set to 1 to determine the number of instances of each class in the query set. The values ​​were set to 1, 5, and 10; during testing, the evaluation metric was the Mean of Average Precision (mAP), and the average precision was AP50. The comparison results are shown in Table 4 below: Table 4

[0042] As can be seen, the average accuracy of the detection results provided by the method in this embodiment is significantly higher than that of traditional TFA, Meta R-CNN, and the few-shot learning methods of the baseline network. The method provided in this embodiment adds a multilayer perceptron as a mapping head after the feature extraction network and the instance localization network to project features to multiple different dimensions, and then adds multi-dimensional hyperspherical consistency regularization constraints. Through multi-dimensional feature consistency constraints, the information contained in the pest features can be fully utilized from multiple dimensions. The network's ability to express features can be improved without significantly increasing the amount of computation, thereby improving the network's ability to distinguish pest features. The use of feature mean initialization allows the network to have a good ability to distinguish the features of newly added pest categories without significantly increasing the amount of computation.

[0043] Example 3 This embodiment provides a small-sample pest detection system based on multidimensional hyperspherical feature consistency regularization, used to implement the detection method described in Embodiment 1 or 2, such as... Figure 6 As shown, it includes: The data acquisition and construction module is used to acquire an existing pest dataset and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset. The model building module is used to build a small-sample pest detection model and set the total loss function; The first-stage training module is used to perform the first-stage training optimization of the small sample pest detection model constructed by inputting the base class support set and the base class query set. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. The model two-stage training module is used to input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches the minimum, the optimized small sample pest detection model is obtained. The pest detection module is used to input small sample images of pests to be detected into the optimized small sample pest detection model to obtain the detection results.

[0044] The same or similar labels correspond to the same or similar parts; The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent. Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization, characterized in that, include: S1: Obtain an existing pest dataset, and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset; S2: Construct a small-sample pest detection model and set the total loss function; The small-sample pest detection model includes a first Embedding network module, a second Embedding network module, a variational autoencoder module, a first feature aggregation point, a hyperspherical feature consistency regularization module, a first fully connected layer, and a second fully connected layer. The input terminals of the first Embedding network module and the second Embedding network module are the input terminals of the small sample pest detection model; The output of the first Embedding network module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the second Embedding network module is connected to the input of the variational autoencoder module, and the output of the variational autoencoder module is connected to the input of the first feature aggregation point and the hyperspherical feature consistency regularization module, respectively. The output of the first feature aggregation point is connected to the input of the first fully connected layer; The output of the hyperspherical feature consistency regularization module is connected to the input of the second fully connected layer. The outputs of the first and second fully connected layers are the outputs of the small-sample pest detection model. The hyperspherical feature consistency regularization module includes a multilayer perceptron and a second feature aggregation point connected in sequence. S3: Input the base class support set and base class query set into the constructed small sample pest detection model for the first stage of training and optimization. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. S4: Input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches its minimum, the optimized small sample pest detection model is obtained, including: S4.1: Freeze the initial model parameters of the first Embedding network module, the second Embedding network module, the variational autoencoder module, the first feature aggregation point, and the hyperspherical feature consistency regularization module in the initially trained small sample pest detection model; S4.2: Input the small sample query set into the first Embedding network module for feature extraction to obtain small sample query set instance features, calculate the initial class weights of the first fully connected layer based on the small sample query set instance features and save them; S4.3: The small sample support set is input into the second Embedding network module, and features are extracted by the second Embedding network module and encoded by the variational autoencoder module in sequence to obtain the variational features of the small sample support set instances; S4.4: Input the small sample query set instance features and the small sample support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first small sample aggregated features; input the small sample query set instance features and the small sample support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second small sample aggregated features; S4.5: Input the first small sample aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the small sample query set; input the second small sample aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the small sample query set; S4.6: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the small sample query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the small sample query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value of different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the small sample query set, and use the prediction probability loss value to apply consistency constraints to the first fully connected layer. S4.7: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S4.8: Update the network parameters of the first fully connected layer and the second fully connected layer. Repeat steps S4.3-4.7 until the total loss function value reaches the minimum. Save the corresponding network parameters of the first fully connected layer and the second fully connected layer as the final network parameters of the first fully connected layer and the second fully connected layer to obtain the optimized small sample pest detection model. S5: Input the small sample pest images to be detected into the optimized small sample pest detection model to obtain the detection results.

2. The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization according to claim 1, characterized in that, The existing pest dataset includes a base class dataset and a new class dataset; Based on the base class dataset, construct a base class support set and a base class query set; based on the base class dataset and the new class dataset, construct a small sample support set and a small sample query set.

3. The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization according to claim 2, characterized in that, The first Embedding network module and the second Embedding network module have the same structure and share parameters, both including a backbone network, an RPN network, and a region of interest pooling layer; The input of the backbone network is the input of the Embedding network module, and the output of the backbone network is connected to the input of the RPN network and the Region of Interest (ROI) pooling layer, respectively. The output of the RPN network is connected to the input of the RPI pooling layer, and the output of the RPI pooling layer is the output of the Embedding network module.

4. The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization according to claim 2, characterized in that, The variational autoencoder module includes an encoder, a sampling layer, and a decoder connected in sequence.

5. The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization according to claim 2, characterized in that, The total loss function includes a classification loss function, a cosine loss function, and a binary cross-entropy loss function, specifically: In the formula This represents the total loss function value. This represents the classification loss function value. This represents the value of the cosine loss function. Represents the binary cross-entropy loss function. These represent the first, second, and third loss weights, respectively.

6. The small-sample pest detection method based on multidimensional hyperspherical feature consistency regularization according to claim 5, characterized in that, S3 includes: S3.1: Input the base class query set into the first Embedding network module for feature extraction to obtain base class query set instance features; input the base class support set into the second Embedding network module, and sequentially perform feature extraction through the second Embedding network module and encoding through the variational autoencoder module to obtain base class support set instance variational features; S3.2: Input the base class query set instance features and base class support set instance variational features into the first feature aggregation point for feature aggregation to obtain the first base class aggregated features; input the query set instance features and support set instance variational features into the hyperspherical feature consistency regularization module for multi-dimensional hyperspherical mapping to obtain the second base class aggregated features; S3.3: Input the first base class aggregated feature into the first fully connected layer to obtain the first image prediction label and its prediction probability of the base class query set; input the second base class aggregated feature into the second fully connected layer to obtain the second image prediction label and its prediction probability of the base class query set; S3.4: Based on the classification loss function, calculate the classification loss function value according to the first image predicted label and the image true label of the base class query set; based on the cosine loss function, calculate the cosine loss function value according to the second image predicted label and the image true label of the base class query set; based on the binary cross-entropy loss function, calculate the prediction probability loss value of different dimensions according to the prediction probability of the first image predicted label and the prediction probability of the second image predicted label of the base class query set, and use the prediction probability loss value to apply consistency constraints to the first fully connected layer. S3.5: Calculate the total loss function value based on the classification loss function value, cosine loss function value, and prediction probability loss value; S3.6: Update the model parameters of the small sample pest detection model. Repeat steps S3.1-3.5 until the total loss function value reaches its minimum. Save the corresponding model parameters as the initial model parameters to obtain the initially trained small sample pest detection model.

7. A small-sample pest detection system based on multidimensional hyperspherical feature consistency regularization, used to implement the detection method according to any one of claims 1-6, characterized in that, include: The data acquisition and construction module is used to acquire an existing pest dataset and construct a base class support set, a base class query set, a small sample support set, and a small sample query set based on the existing pest dataset. The model building module is used to build a small-sample pest detection model and set the total loss function; The first-stage training module is used to perform the first-stage training optimization of the small sample pest detection model constructed by inputting the base class support set and the base class query set. When the total loss function value reaches the minimum, the initially trained small sample pest detection model is obtained. The model two-stage training module is used to input the small sample support set and small sample query set into the initially trained small sample pest detection model for the second stage of training optimization. When the total loss function value reaches the minimum, the optimized small sample pest detection model is obtained. The pest detection module is used to input small sample images of pests to be detected into the optimized small sample pest detection model to obtain the detection results.

Citation Information

Patent Citations

  • Small sample pest image recognition method based on causal intervention technology

    CN114863280A

  • Pest identification method based on migration element learning

    CN115019175A