Three-stage pest image recognition method based on adaptive feature fusion pyramid network

Through the adaptive feature fusion pyramid network and the three-stage pest image target positioning and recognition network, the problems of low efficiency and insufficient precision in traditional agricultural pest recognition methods are solved, and efficient and accurate recognition of pests in complex backgrounds is achieved.

CN114565048BActive Publication Date: 2025-09-05ANHUI UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210201018.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-02
Publication Date
2025-09-05
Estimated Expiration
2042-03-02

AI Technical Summary

Technical Problem

Traditional agricultural pest identification methods are inefficient, easily affected by human subjective experience, and have difficulty effectively distinguishing highly similar pest categories in complex backgrounds, resulting in low identification accuracy.

Method used

A three-stage pest image recognition method based on an adaptive feature fusion pyramid network is adopted, which includes an adaptive feature fusion pyramid network and a three-stage pest image target positioning and recognition network. Feature extraction and fusion are performed through a deep residual network and a convolutional neural network, combined with anchor box generation and target detection to construct an efficient pest recognition model.

Benefits of technology

The speed and accuracy of pest image recognition have been improved, especially in complex backgrounds, which can effectively distinguish pest categories with high similarity and improve recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114565048B_ABST
    Figure CN114565048B_ABST
Patent Text Reader

Abstract

The present invention relates to a three-stage pest image recognition method based on an adaptive feature fusion pyramid network. The method comprises the following steps: obtaining a pest image dataset; constructing an adaptive feature fusion pyramid network, inputting the original pest image, and outputting a pest feature map; constructing a three-stage pest image target positioning and recognition network; forming a pest image recognition model using the adaptive feature fusion pyramid network and the three-stage pest image target positioning and recognition network; inputting a training set into the pest image recognition model; inputting a test set into the trained pest image recognition model; and outputting pest image detection results. The method enhances the pest image feature extraction capability, obtains higher quality and more accurate prediction frames, and finally constructs a three-stage pest image target positioning and recognition network, thereby enhancing the accuracy of pest target detection. The method can be applied to complex agricultural pest detection tasks with high similarity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of pest image detection, and in particular to a three-stage pest image recognition method based on an adaptive feature fusion pyramid network. Background Art

[0002] Traditional agricultural pest identification relies primarily on manual inspection by agricultural technicians. However, manual pest detection methods are inefficient and prone to misjudgment due to subjective experience, hindering timely and effective pest control. With the advancement of computer vision technology, many researchers have adopted machine learning algorithms to identify agricultural pest images, achieving promising results. However, given the complex farmland environment and the high similarity between different pest types, traditional machine learning-based methods struggle to extract pest target features, resulting in low recognition accuracy.

[0003] Therefore, it is of great significance to efficiently extract the features of pest images under complex backgrounds and distinguish different types of pests with high similarity to improve the accuracy of pest image recognition and provide timely and effective prevention and control recommendations for agricultural pests. Summary of the Invention

[0004] The purpose of the present invention is to provide a three-stage pest image recognition method based on an adaptive feature fusion pyramid network that can not only accelerate the speed and accuracy of multi-species and small-scale pest image recognition, but also be applied to complex and high-similarity agricultural pest detection work.

[0005] To achieve the above object, the present invention adopts the following technical solution: a three-stage pest image recognition method based on an adaptive feature fusion pyramid network, the method comprising the following steps in order:

[0006] (1) Obtain a pest image dataset, which is a collection of original pest images, and divide the pest image dataset into a training set and a test set in a ratio of 7:3;

[0007] (2) Constructing an adaptive feature fusion pyramid network, inputting the original pest image into the adaptive feature fusion pyramid network, and the adaptive feature fusion pyramid network outputs a pest fusion feature map;

[0008] (3) Construct a three-stage pest image target positioning and recognition network;

[0009] (4) The adaptive feature fusion pyramid network and the three-stage pest image target positioning and recognition network form a pest image recognition model. The training set is input into the pest image recognition model to train the pest image recognition model. The test set is input into the trained pest image recognition model, and the pest image recognition model outputs the results of pest image detection.

[0010] The step (2) specifically includes the following steps:

[0011] (2a) The adaptive feature fusion pyramid network consists of a pest feature extraction layer and an adaptive feature fusion layer. The pest feature extraction layer includes a deep residual network and a 1×1×256 convolution; the adaptive feature fusion layer includes a convolutional neural network and a softmax normalized exponential function.

[0012] (2b) The pest feature extraction layer extracts pest features: the original pest image is input into the pest feature extraction layer to obtain the pest feature map. The pest feature extraction layer uses a deep residual network as the backbone network to extract features from the original pest image. First, channel transformation is performed: the pest feature maps of different layers extracted from the deep residual network are subjected to a convolution operation with a convolution kernel size of 1×1×256; secondly, feature map scale transformation is performed: the pest feature map of the lth layer is upsampled or downsampled to the size of the pest feature map of the kth layer, and the pest feature map X is obtained. kl ;

[0013] (2c) The adaptive feature fusion layer performs adaptive feature fusion on the obtained pest feature map and outputs the required pest fusion feature map. The formula for adaptive feature fusion is:

[0014]

[0015] in, Indicates the output pest feature map, Y l The eigenvector at position i; It represents the feature vector at position i on the pest feature map after the scale change from the kth layer to the lth layer, and the values ​​of k are 1, 2, and 3 respectively; and are learnable weights, acquired through learning of convolutional neural networks; and The value of is between 0 and 1, and

[0016] Use the softmax normalized exponential function to calculate the learnable weights and The calculation formula is:

[0017]

[0018] in, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters, and The calculation formula and The calculation formula is similar.

[0019] The step (3) specifically includes the following steps:

[0020] (3a) Constructing a first-stage pest region recommendation network and an adaptive anchor frame generation network. Inputting the pest fusion feature map into the pest region recommendation network and the adaptive anchor frame generation network respectively. The pest region recommendation network and the adaptive anchor frame generation network are parallel. The pest region recommendation network outputs prediction information, and the adaptive anchor frame generation network outputs anchor frames. The prediction information and anchor frames are combined to obtain the prediction frame.

[0021] (3b) Construct a two-stage pest target detection network, input the prediction box into the pest target detection network, and the pest target detection network outputs a high-quality prediction box;

[0022] (3c) The two-stage pest target detection network, the one-stage pest region recommendation network and the adaptive anchor box generation network together constitute the three-stage pest image target positioning and recognition network.

[0023] The step (3a) specifically comprises the following steps:

[0024] (3a1) Construct a one-stage pest area recommendation network: The pest area recommendation network consists of a pest classification layer and a pest position regression layer; first, a 3×3×512 convolution operation is performed on the pest fusion feature map to obtain a 512-dimensional pest feature vector; the pest classification layer is composed of a 1×1×2 convolution layer, and the number of output neurons is 2, 2 representing the foreground and background; the pest position regression layer is composed of a 1×1×4 convolution layer, and the number of output neurons is 4, 4 representing the position information of the pest target; the 512-dimensional pest feature vector is input into the pest classification layer and the pest position regression layer respectively, the pest classification layer and the pest position regression layer are parallel, the pest classification layer outputs the pest target classification information, and the pest position regression layer outputs the pest position regression parameters, and the pest target classification information and the pest position regression parameters together constitute the prediction information;

[0025] (3a2) Construct a one-stage adaptive anchor frame generation network: The adaptive anchor frame generation network consists of an anchor frame position prediction layer and an anchor frame shape prediction layer, wherein the anchor frame position prediction layer consists of a 1×1 convolution and a sigmoid activation function; the anchor frame shape prediction layer consists of two 1×1 convolutions, and the two 1×1 convolutions are parallel; the anchor frame position prediction layer first compresses the pest fusion feature map to a single channel through a 1×1 convolution, and then classifies each pixel through a sigmoid activation function to predict the center point of the anchor frame in the pest fusion feature map, and outputs the anchor frame center in the pest fusion feature map; and the anchor frame shape prediction layer compresses the pest fusion feature map through two 1×1 convolutions to output the predicted d of the pest fusion feature map. w and d h , d w and d h is the predicted width and height of the anchor box. Finally, the output result is changed by formula (3), which maps the approximate [0,1000] to [-1,1], and outputs the width w and height h of the best predicted anchor box.

[0026]

[0027] Among them, σ is the scaling factor and is set to 8, and s is the downsampling step length of the pest fusion feature map;

[0028] Set the loss function to:

[0029] L=λL shape +L reg (4)

[0030] Among them, λ is the balance coefficient, L reg is the loss of the anchor box position prediction layer, L shape Loss for the anchor box shape prediction layer;

[0031] L reg The calculation formula is as follows:

[0032] L reg (R,i)=-logR i (5)

[0033] Where R is the predicted feature map probability distribution, R = R0,...,R n , n represents the anchor box category, i is the center position of the real anchor box;

[0034] L shape The calculation formula is:

[0035]

[0036] Among them, w g and h gis the width and height of the real frame;

[0037] smooth L1 The calculation formula is:

[0038]

[0039] Where x represents the error value of the input position.

[0040] The step (3b) specifically comprises the following steps:

[0041] (3b1) The two-stage pest target detection network consists of a first detection module and a second detection module. The first detection module and the second detection module have the same network structure. The first detection module and the second detection module are both composed of a classification network and a regression network. The classification network and the regression network are parallel. The classification network is composed of 1×1×2C convolutional layers, where C represents the number of classification categories. The classification network outputs the pest classification category and the corresponding classification confidence; the regression network is composed of 1×1×4C convolutional layers. The regression network outputs the position coordinates of the pest target's bounding box;

[0042] (3b2) Selection of training samples in the training set: First, calculate the intersection over union (IoU) between the predicted box and the true labeled box; determine the positive and negative samples using formula (8):

[0043]

[0044] Among them, g represents the real sample frame, a represents the predicted frame; y represents the positive and negative value of the sample;

[0045] If the IoU value is greater than the set threshold u0, the predicted box is a positive sample and marked as "1", otherwise it is a negative sample and marked as "0";

[0046] In the two-stage pest target detection network, the threshold of the first detection module is u1, and the threshold of the second detection module is u2, where u2 is greater than u1. When training the two-stage pest target detection network, the threshold u1 is first used to select positive and negative training samples to train the first detection module. Then, the output of the first detection module is used as input, and the threshold u2 is used to select positive and negative training samples to train the second detection module. The threshold u1 is set to 0.5, and the threshold u2 is set to 0.7.

[0047] (3b3) The loss function of the two-stage pest target detection network is:

[0048]

[0049] Among them, the classification loss L cls The calculation formula for (p,u) is as follows:

[0050] Lcls (p,u)=-logp u (10)

[0051] Regression loss L loc (t u ,v) is calculated as follows:

[0052]

[0053] Where p is the normalized probability distribution predicted by the classifier, p = p0,...,p k , k represents the pest species, u is the true category label of the pest, t u Represents the regression parameters of the corresponding true category of pests predicted by the bounding box regression network, expressed as v represents the regression parameter of the true bounding box of the pest, expressed as (v x ,v y ,v w ,v h ); is the balance coefficient to balance the classification loss and regression loss; [u≥1] means that only positive samples participate in the calculation of regression loss;

[0054] First, the loss function L of the first detection module is calculated by formula (9): s1 And the loss function L of the second detection module s2 , according to formula (12), the total loss function L of the two-stage pest target detection network is obtained D :

[0055] L D =L s1 +τ*L s2 (12)

[0056] Among them, L s1 and L s2 Represent the loss functions of the first detector and the second detector respectively. τ is a hyperparameter, which is set to 1 to balance the loss values ​​of the two detectors, indicating that there is no bias between the first detection module and the second detection module during training.

[0057] It can be seen from the above technical solution that the beneficial effects of the present invention are: First, the present invention enhances the ability to extract pest image features by constructing an adaptive feature fusion pyramid network, obtains higher quality and more accurate prediction frames through a two-stage pest target detection network, and finally constructs a three-stage pest image target positioning and recognition network, thereby enhancing the accuracy of pest target detection; Second, this method is significantly improved compared to the currently popular pest identification and detection methods, which fully demonstrates that this method can be applied to complex and highly similar agricultural pest detection work. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION

[0059] like Figure 1 As shown, a three-stage pest image recognition method based on an adaptive feature fusion pyramid network includes the following steps in sequence:

[0060] (1) Obtain a pest image dataset, which is a collection of original pest images, and divide the pest image dataset into a training set and a test set in a ratio of 7:3;

[0061] (2) Constructing an adaptive feature fusion pyramid network, inputting the original pest image into the adaptive feature fusion pyramid network, and the adaptive feature fusion pyramid network outputs a pest fusion feature map;

[0062] (3) Construct a three-stage pest image target positioning and recognition network;

[0063] (4) The adaptive feature fusion pyramid network and the three-stage pest image target positioning and recognition network form a pest image recognition model. The training set is input into the pest image recognition model to train the pest image recognition model. The test set is input into the trained pest image recognition model, and the pest image recognition model outputs the results of pest image detection.

[0064] The step (2) specifically includes the following steps:

[0065] (2a) The adaptive feature fusion pyramid network consists of a pest feature extraction layer and an adaptive feature fusion layer. The pest feature extraction layer includes a deep residual network and a 1×1×256 convolution; the adaptive feature fusion layer includes a convolutional neural network and a softmax normalized exponential function.

[0066] (2b) The pest feature extraction layer extracts pest features: the original pest image is input into the pest feature extraction layer to obtain the pest feature map. The pest feature extraction layer uses a deep residual network as the backbone network to extract features from the original pest image. First, channel transformation is performed: the pest feature maps of different layers extracted from the deep residual network are subjected to a convolution operation with a convolution kernel size of 1×1×256; secondly, feature map scale transformation is performed: the pest feature map of the lth layer is upsampled or downsampled to the size of the pest feature map of the kth layer, and the pest feature map X is obtained. kl ;

[0067] (2c) The adaptive feature fusion layer performs adaptive feature fusion on the obtained pest feature map and outputs the required pest fusion feature map. The formula for adaptive feature fusion is:

[0068]

[0069] in, Indicates the output pest feature map, Y l The eigenvector at position i; It represents the feature vector at position i on the pest feature map after the scale change from the kth layer to the lth layer, and the values ​​of k are 1, 2, and 3 respectively; and are learnable weights, acquired through learning of convolutional neural networks; and The value of is between 0 and 1, and

[0070] Use the softmax normalized exponential function to calculate the learnable weights and The calculation formula is:

[0071]

[0072] in, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters, and The calculation formula and The calculation formula is similar.

[0073] The step (3) specifically includes the following steps:

[0074] (3a) Constructing a first-stage pest region recommendation network and an adaptive anchor frame generation network. Inputting the pest fusion feature map into the pest region recommendation network and the adaptive anchor frame generation network respectively. The pest region recommendation network and the adaptive anchor frame generation network are parallel. The pest region recommendation network outputs prediction information, and the adaptive anchor frame generation network outputs anchor frames. The prediction information and anchor frames are combined to obtain the prediction frame.

[0075] (3b) Construct a two-stage pest target detection network, input the prediction box into the pest target detection network, and the pest target detection network outputs a high-quality prediction box;

[0076] (3c) The two-stage pest target detection network, the one-stage pest region recommendation network and the adaptive anchor box generation network together constitute the three-stage pest image target positioning and recognition network.

[0077] The step (3a) specifically comprises the following steps:

[0078] (3a1) Construct a one-stage pest area recommendation network: The pest area recommendation network consists of a pest classification layer and a pest position regression layer; first, a 3×3×512 convolution operation is performed on the pest fusion feature map to obtain a 512-dimensional pest feature vector; the pest classification layer is composed of a 1×1×2 convolution layer, and the number of output neurons is 2, 2 representing the foreground and background; the pest position regression layer is composed of a 1×1×4 convolution layer, and the number of output neurons is 4, 4 representing the position information of the pest target; the 512-dimensional pest feature vector is input into the pest classification layer and the pest position regression layer respectively, the pest classification layer and the pest position regression layer are parallel, the pest classification layer outputs the pest target classification information, and the pest position regression layer outputs the pest position regression parameters, and the pest target classification information and the pest position regression parameters together constitute the prediction information;

[0079] (3a2) Construct a one-stage adaptive anchor frame generation network: The adaptive anchor frame generation network consists of an anchor frame position prediction layer and an anchor frame shape prediction layer, wherein the anchor frame position prediction layer consists of a 1×1 convolution and a sigmoid activation function; the anchor frame shape prediction layer consists of two 1×1 convolutions, and the two 1×1 convolutions are parallel; the anchor frame position prediction layer first compresses the pest fusion feature map to a single channel through a 1×1 convolution, and then classifies each pixel through a sigmoid activation function to predict the center point of the anchor frame in the pest fusion feature map, and outputs the anchor frame center in the pest fusion feature map; and the anchor frame shape prediction layer compresses the pest fusion feature map through two 1×1 convolutions to output the predicted d of the pest fusion feature map. w and d h , d w and d h is the predicted width and height of the anchor box. Finally, the output result is changed by formula (3), which maps the approximate [0,1000] to [-1,1], and outputs the width w and height h of the best predicted anchor box.

[0080]

[0081] Among them, σ is the scaling factor and is set to 8, and s is the downsampling step length of the pest fusion feature map;

[0082] Set the loss function to:

[0083] L=λL shape +L reg (4)

[0084] Among them, λ is the balance coefficient, L reg is the loss of the anchor box position prediction layer, L shape Loss for the anchor box shape prediction layer;

[0085] L regThe calculation formula is as follows:

[0086] L reg (R,i)=-logR i (5)

[0087] Where R is the predicted feature map probability distribution, R = R0,...,R n , n represents the anchor box category, i is the center position of the real anchor box;

[0088] L shape The calculation formula is:

[0089]

[0090] Among them, w g and h g is the width and height of the real frame;

[0091] smooth L1 The calculation formula is:

[0092]

[0093] Where x represents the error value of the input position.

[0094] The step (3b) specifically comprises the following steps:

[0095] (3b1) The two-stage pest target detection network consists of a first detection module and a second detection module. The first detection module and the second detection module have the same network structure. The first detection module and the second detection module are both composed of a classification network and a regression network. The classification network and the regression network are parallel. The classification network is composed of 1×1×2C convolutional layers, where C represents the number of classification categories. The classification network outputs the pest classification category and the corresponding classification confidence; the regression network is composed of 1×1×4C convolutional layers. The regression network outputs the position coordinates of the pest target's bounding box;

[0096] (3b2) Selection of training samples in the training set: First, calculate the intersection over union (IoU) between the predicted box and the true labeled box; determine the positive and negative samples using formula (8):

[0097]

[0098] Among them, g represents the real sample frame, a represents the predicted frame; y represents the positive and negative value of the sample;

[0099] If the IoU value is greater than the set threshold u0, the predicted box is a positive sample and marked as "1", otherwise it is a negative sample and marked as "0";

[0100] Since the IoU threshold determines the performance of the detector, when it is set too large, the quality of positive samples will improve, but the number of positive samples will decrease, which is not conducive to the training of the detector. When the threshold is set too small, the number of positive samples will increase, but many false positive samples will participate in the training, reducing the performance of the detector. Therefore, in order to improve the detection quality, in the two-stage pest target detection network, the threshold of the first detection module is u1, and the threshold of the second detection module is u2, and u2 is greater than u1; when training the two-stage pest target detection network, the threshold u1 is first used to select positive and negative training samples to train the first detection module; then the output of the first detection module is used as input, and the threshold u2 is used to select positive and negative training samples to train the second detection module; the threshold u1 is set to 0.5, and the threshold u2 is set to 0.7;

[0101] (3b3) The loss function of the two-stage pest target detection network is:

[0102]

[0103] Among them, the classification loss L cls The calculation formula for (p,u) is as follows:

[0104] L cls (p,u)=-logp u (10)

[0105] Regression loss L loc (t u ,v) is calculated as follows:

[0106]

[0107] Where p is the normalized probability distribution predicted by the classifier, p = p0,...,p k , k represents the pest species, u is the true category label of the pest, t u Represents the regression parameters of the corresponding true category of pests predicted by the bounding box regression network, expressed as v represents the regression parameter of the true bounding box of the pest, expressed as (v x ,v y ,v w ,v h ); is the balance coefficient to balance the classification loss and regression loss; [u≥1] means that only positive samples participate in the calculation of regression loss;

[0108] First, the loss function L of the first detection module is calculated by formula (9): s1 And the loss function L of the second detection module s2 , according to formula (12), the total loss function L of the two-stage pest target detection network is obtained D :

[0109] L D =L s1 +τ*L s2 (12)

[0110] Among them, L s1 and L s2 Represent the loss functions of the first detector and the second detector respectively. τ is a hyperparameter, which is set to 1 to balance the loss values ​​of the two detectors, indicating that there is no bias between the first detection module and the second detection module during training.

[0111] Table 1 shows the experimental comparison results of this method and the most advanced target detection methods.

[0112]

[0113] Table 1 shows experimental results comparing this method with other object detection methods. It shows that this method achieves higher detection accuracy than other methods across all evaluation metrics. For example, this method achieves 51.0% AP (0.5:0.95), which is an improvement of 6.8%, 9.8%, 5.1%, 5.1%, and 4.6% compared to SSD, RetinaNet, FPN, Dynamic RCNN, and Cascade RCNN, respectively. This demonstrates that this method can effectively solve the problem of identifying and detecting agricultural pests of similar categories in complex backgrounds.

[0114] In summary, the present invention strengthens the feature extraction capability of pest images by constructing an adaptive feature fusion pyramid network, obtains higher quality and more accurate prediction frames through a two-stage pest target detection network, and finally constructs a three-stage pest image target positioning and recognition network, thereby enhancing the accuracy of pest target detection; this method also has significant improvements compared to the currently popular pest recognition and detection methods, which fully demonstrates that this method can be applied to complex and highly similar agricultural pest detection work.

Claims

1. A three-stage pest image recognition method based on an adaptive feature fusion pyramid network, characterized by: The method comprises the following steps in sequence: (1) Obtain a pest image dataset, which is a collection of original pest images, and divide the pest image dataset into a training set and a test set in a ratio of 7:3; (2) Constructing an adaptive feature fusion pyramid network, inputting the original pest image into the adaptive feature fusion pyramid network, and the adaptive feature fusion pyramid network outputs a pest fusion feature map; (3) Construct a three-stage pest image target positioning and recognition network; (4) An adaptive feature fusion pyramid network and a three-stage pest image target positioning and recognition network are combined to form a pest image recognition model. The training set is input into the pest image recognition model to train the pest image recognition model. The test set is input into the trained pest image recognition model, and the pest image recognition model outputs the results of pest image detection. The step (3) specifically includes the following steps: (3a) Constructing a first-stage pest region recommendation network and an adaptive anchor frame generation network. Inputting the pest fusion feature map into the pest region recommendation network and the adaptive anchor frame generation network respectively. The pest region recommendation network and the adaptive anchor frame generation network are parallel. The pest region recommendation network outputs prediction information, and the adaptive anchor frame generation network outputs anchor frames. The prediction information and anchor frames are combined to obtain the prediction frame. (3b) Construct a two-stage pest target detection network, input the prediction box into the pest target detection network, and the pest target detection network outputs a high-quality prediction box; (3c) The two-stage pest target detection network, the one-stage pest region recommendation network and the adaptive anchor box generation network together constitute the three-stage pest image target positioning and recognition network.

2. The three-stage pest image recognition method based on the adaptive feature fusion pyramid network according to claim 1 is characterized in that: The step (2) specifically includes the following steps: (2a) The adaptive feature fusion pyramid network consists of a pest feature extraction layer and an adaptive feature fusion layer. The pest feature extraction layer includes a deep residual network and a 1×1×256 convolution; the adaptive feature fusion layer includes a convolutional neural network and a softmax normalized exponential function. (2b) The pest feature extraction layer extracts pest features: the original pest image is input into the pest feature extraction layer to obtain the pest feature map. The pest feature extraction layer uses a deep residual network as the backbone network to extract features from the original pest image. First, channel transformation is performed: the pest feature maps of different layers extracted from the deep residual network are subjected to a convolution operation with a convolution kernel size of 1×1×256; secondly, feature map scale transformation is performed: the pest feature map of the lth layer is upsampled or downsampled to the size of the pest feature map of the kth layer, and the pest feature map X is obtained. kl ; (2c) The adaptive feature fusion layer performs adaptive feature fusion on the obtained pest feature map and outputs the required pest fusion feature map. The formula for adaptive feature fusion is: in, Indicates the output pest feature map, Y l The eigenvector at position i; It represents the feature vector at position i on the pest feature map after the scale change from the kth layer to the lth layer, and the values ​​of k are 1, 2, and 3 respectively; and are learnable weights, acquired through learning of convolutional neural networks; and The value of is between 0 and 1, and Use the softmax normalized exponential function to calculate the learnable weights and The calculation formula is: in, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters, It is used to control the learnable weights Parameters; and The calculation formula and The calculation formula is similar.

3. The three-stage pest image recognition method based on the adaptive feature fusion pyramid network according to claim 1 is characterized in that: The step (3a) specifically comprises the following steps: (3a1) Construct a one-stage pest area recommendation network: The pest area recommendation network consists of a pest classification layer and a pest position regression layer; first, a 3×3×512 convolution operation is performed on the pest fusion feature map to obtain a 512-dimensional pest feature vector; the pest classification layer is composed of a 1×1×2 convolution layer, and the number of output neurons is 2, 2 representing the foreground and background; the pest position regression layer is composed of a 1×1×4 convolution layer, and the number of output neurons is 4, 4 representing the position information of the pest target; the 512-dimensional pest feature vector is input into the pest classification layer and the pest position regression layer respectively, the pest classification layer and the pest position regression layer are parallel, the pest classification layer outputs the pest target classification information, and the pest position regression layer outputs the pest position regression parameters, and the pest target classification information and the pest position regression parameters together constitute the prediction information; (3a2) Construct a one-stage adaptive anchor frame generation network: The adaptive anchor frame generation network consists of an anchor frame position prediction layer and an anchor frame shape prediction layer, wherein the anchor frame position prediction layer consists of a 1×1 convolution and a sigmoid activation function; the anchor frame shape prediction layer consists of two 1×1 convolutions, and the two 1×1 convolutions are parallel; the anchor frame position prediction layer first compresses the pest fusion feature map to a single channel through a 1×1 convolution, and then classifies each pixel through a sigmoid activation function to predict the center point of the anchor frame in the pest fusion feature map, and outputs the anchor frame center in the pest fusion feature map; and the anchor frame shape prediction layer compresses the pest fusion feature map through two 1×1 convolutions to output the predicted d of the pest fusion feature map. w and d h , d w and d h is the predicted width and height of the anchor box. Finally, the output result is changed by formula (3), which maps the approximate [0,1000] to [-1,1], and outputs the width w and height h of the best predicted anchor box. Among them, σ is the scaling factor and is set to 8, and s is the downsampling step length of the pest fusion feature map; Set the loss function to: L=λL shape +L reg (4) Among them, λ is the balance coefficient, L reg is the loss of the anchor box position prediction layer, L shape Loss for the anchor box shape prediction layer; L reg The calculation formula is as follows: L reg (R,i)=-logR i (5) Where R is the predicted feature map probability distribution, R = R0,...,R n , n represents the anchor box category, i is the center position of the real anchor box; L shape The calculation formula is: Among them, w g and h g is the width and height of the real frame; smooth L1 The calculation formula is: Where x represents the error value of the input position.

4. The three-stage pest image recognition method based on the adaptive feature fusion pyramid network according to claim 1 is characterized in that: The step (3b) specifically comprises the following steps: (3b1) The two-stage pest target detection network consists of a first detection module and a second detection module. The first detection module and the second detection module have the same network structure. The first detection module and the second detection module are both composed of a classification network and a regression network. The classification network and the regression network are parallel. The classification network is composed of 1×1×2C convolutional layers, where C represents the number of classification categories. The classification network outputs the pest classification category and the corresponding classification confidence; the regression network is composed of 1×1×4C convolutional layers. The regression network outputs the position coordinates of the pest target's bounding box; (3b2) Selection of training samples in the training set: First, calculate the intersection over union (IoU) between the predicted box and the true labeled box; determine the positive and negative samples using formula (8): Among them, g represents the real sample frame, a represents the predicted frame; y represents the positive and negative value of the sample; If the IoU value is greater than the set threshold u0, the predicted box is a positive sample and marked as "1", otherwise it is a negative sample and marked as "0"; In the two-stage pest target detection network, the threshold of the first detection module is u1, and the threshold of the second detection module is u2, where u2 is greater than u1. When training the two-stage pest target detection network, the threshold u1 is first used to select positive and negative training samples to train the first detection module. Then, the output of the first detection module is used as input, and the threshold u2 is used to select positive and negative training samples to train the second detection module. The threshold u1 is set to 0.5, and the threshold u2 is set to 0.

7. (3b3) The loss function of the two-stage pest target detection network is: Among them, the classification loss L cls The calculation formula for (p,u) is as follows: L cls (p,u)=-logp u (10) Regression loss L loc (t u ,v) is calculated as follows: Where p is the normalized probability distribution predicted by the classifier, p = p0,...,p k , k represents the pest species, u is the true category label of the pest, t u Represents the regression parameters of the corresponding true category of pests predicted by the bounding box regression network, expressed as v represents the regression parameter of the true bounding box of the pest, expressed as (v x ,v y ,v w ,v h ); is the balance coefficient to balance the classification loss and regression loss; [u≥1] means that only positive samples participate in the calculation of regression loss; First, the loss function L of the first detection module is calculated by formula (9): s1 And the loss function L of the second detection module s2 According to formula (12), the total loss function L of the two-stage pest target detection network is obtained D : L D =L s1 +τ*L s2 (12) Among them, L s1 and L s2 Represent the loss functions of the first detector and the second detector respectively. τ is a hyperparameter, which is set to 1 to balance the loss values ​​of the two detectors, indicating that there is no bias between the first detection module and the second detection module during training.

Citation Information

Patent Citations

  • Pest target detection method based on decoupling classification and regression feature optimal layer technology

    CN113627269A