A real-time target detection method based on Pearson coefficient matrix and attention fusion
Through the fusion method of Pearson coefficient matrix and attention, the DETR network structure is improved, solving the problems of high computational complexity and insufficient extraction of global context features, and improving the performance and speed of target detection.
Patent Information
- Application Number
- CN202111458521.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-02
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-12-02
AI Technical Summary
The DETR network structure has the problems of high computational complexity and insufficient global context feature extraction in target detection, resulting in performance degradation.
Using the method of fusion of Pearson coefficient matrix and attention, by constructing a combination of Pearson coefficient matrix and multi-layer perceptron, global context information is extracted, and the number of Transformer encoder layers is reduced to reduce computational overhead, forming a four-layer structure. Transformer encoder fused with Pearson coefficient matrix and attention.
It improves the global context extraction capability of target detection, reduces the computational overhead of the model, and improves detection performance and speed.
Smart Images

Figure CN114187569B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision technology, and in particular relates to a real-time target detection method, which can be used in scenarios of autonomous driving and traffic flow analysis. Technical Background
[0002] With the rapid development of deep learning, computer vision and its related fields have ushered in huge opportunities and challenges. As an important subfield of computer vision, the development of object detection has made great progress. The task of object detection is to find all objects of interest in the image and determine their locations and categories. Object detection algorithms based on convolutional neural networks are typical representatives of this. They can be divided into two categories. One is the two-stage method, and its representative algorithms include Faster R-CNN, etc. This algorithm needs to generate candidate boxes of the target first, and then perform target classification and bounding box regression on the candidate boxes; the other is the one-stage method, and its representative algorithms include YOLO, etc., which only requires one operation to directly predict the category and location of the target.
[0003] Convolutional neural networks extract image features by performing local linear weighting on the input image, but it is difficult to effectively extract global context information. As the number of convolutional layers increases, the local receptive field of the feature map pixel increases, but the feature information of small targets will be lost. The feature pyramid FPN proposed by Lin et al. compensates for this deficiency by combining the image texture information extracted by the lower convolutional layer with the image semantic information extracted by the higher convolutional layer through upsampling, downsampling, and lateral connections to obtain richer image features. Dai et al. use deformable convolution to dynamically adjust the sampling points of the convolution kernel in the feature map to extract effective features at a long distance. Although both methods have alleviated the problem of the convolutional neural network's insufficient ability to extract global contextual relationships to a certain extent, the extracted image information still omits a large amount of global context information.
[0004] In order to solve the above problems, the Facebook team proposed the DETR network structure at the 2020 ECCV conference, which uses the Transformer's multi-head self-attention mechanism to extract the global context information of the feature image, bringing a new direction to the research of target detection. However, the shortcomings of the DETR network structure are: each encoder layer in the Transformer has a multi-head self-attention calculation, and the core of the multi-head self-attention mechanism lies in the attention matrix obtained by multiplying the query vector and the key vector, that is, the relationship between the point and the global context. The computational complexity is proportional to the square of the input feature map size, so the attention calculation will consume a lot of time, and the query vector and the key vector are linear changes in the feature map, and the data change rules and connections between the channels of the feature map are not taken into account, resulting in insufficient extraction of global context features by the encoder layer, which reduces the target detection performance of the DETR network structure. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and propose a real-time target detection method that combines the Pearson coefficient matrix with attention to improve the DETR network structure, fully extract encoder features, reduce computational complexity, and improve target detection performance.
[0006] To achieve the above object, the technical solution of the present invention includes:
[0007] (1) Obtain a public dataset of real-time vehicle detection, randomly reverse, scale, and crop the training set and test set images of the dataset, and normalize the images according to the set mean and standard deviation;
[0008] (2) ResNet-50 is used as the backbone network to extract features from the normalized image, and a feature map matrix X with a dimension of (B, C, H, W) is obtained, where B is the number of feature maps, H and W are the height and width of the feature map, respectively, and C is the number of channels of the feature map;
[0009] (3) Constructing a target detection model that integrates the Pearson coefficient matrix and attention:
[0010] (3a) Obtain the feature map matrix F with global context information:
[0011] Calculate the Pearson coefficient between each eigenvalue and all other eigenvalues in the feature map matrix X to form the Pearson coefficient matrix P;
[0012] The Pearson coefficient matrix P is input into a multi-layer perceptron MLP with the same input and output layer dimensions for transformation;
[0013] The transformed Pearson coefficient matrix MP is matrix-multiplied with the feature map matrix X, and the matrix multiplication result MF is residually connected with the feature map matrix X and layer-normalized to obtain the layer-normalized residual connection matrix F′;
[0014] The normalized residual connection matrix F′ is input to the forward feedback layer FFN, and the output of the forward feedback layer is a feature map matrix F with global context information;
[0015] (3b) Select the original Transformer encoder containing six identical encoder layers, remove its first three encoder layers, connect the feature map matrix F with global context information obtained in (3a) to the fourth encoder layer of the Transformer encoder, and form a Transformer encoder with a four-layer structure of Pearson coefficient matrix and attention fusion, and connect it to the decoder in the DETR network structure to form a target detection model with Pearson coefficient matrix and attention fusion;
[0016] (4) Setting the loss function Loss of the target detection model that integrates the Pearson coefficient matrix and attention, and training the model using the gradient descent method to obtain a trained target detection model;
[0017] (5) Input the normalized test set images into the trained target detection model to obtain the target classification and target location coordinates in the image to be predicted. Draw the target bounding box in the image and mark the target category using the target location coordinates.
[0018] Compared with the prior art, the present invention has the following advantages:
[0019] First, the present invention uses an encoder layer based on the Pearson coefficient matrix to extract shallow relationships between pixels, and uses the original Transformer encoder layer to extract deep relationships between pixels. By fusing the Pearson coefficient matrix with the attention mechanism to encode the input image features, the present invention has a stronger ability to extract global contextual relationships of images than the original Transformer encoder.
[0020] Secondly, the present invention uses a multi-branch multi-layer perceptron to transform the Pearson coefficient matrix, thereby enhancing the flexibility of the Pearson coefficient matrix in extracting global contextual relationships.
[0021] Third, since the present invention replaces the first three encoder layers of the original Transformer with an encoder layer based on the Pearson coefficient matrix, compared with the original Transformer encoder containing six encoder layers, the computational overhead of the encoder is reduced and the training and reasoning speed of the model is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart for realizing the present invention;
[0023] Figure 2 The structure diagram of the encoder of the Pearson coefficient matrix and attention fusion in the present invention;
[0024] Figure 3 This is a structural diagram of the target detection model that integrates the Pearson coefficient matrix and attention in the present invention;
[0025] Figure 4 This is a comparison chart of the average accuracy changes during the training process of the target detection model in the present invention and the DETR model;
[0026] Figure 5 This is a diagram showing the effect of the target detection model in the present invention on the test set images. DETAILED DESCRIPTION
[0027] The embodiments and effects of the present invention are further described in detail below with reference to the accompanying drawings.
[0028] Reference Figure 1 , the implementation steps of this example are as follows:
[0029] Step 1: Obtain the experimental training set and test set.
[0030] 1.1) Download the public vehicle detection dataset from the Internet;
[0031] 1.2) Randomly reverse the training set and test set images of the dataset, randomly crop the reversed images into different sizes and aspect ratios, and then randomly scale the cropped image size to one of 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, and 800;
[0032] 1.3) Set the mean to 0.485, 0.456, and 0.406, and the standard deviation to 0.229, 0.224, and 0.225. Normalize the scaled image according to the set mean and standard deviation to obtain a normalized three-channel image.
[0033] Step 2: Use the backbone network to extract image features.
[0034] The ResNet-50 network is selected as the backbone network, which consists of one convolutional layer, one maximum pooling layer, and four residual modules. The four residual modules are composed of 9 convolutional layers, 12 convolutional layers, 18 convolutional layers, and 9 convolutional layers respectively.
[0035] The normalized three-channel image is input into the first convolutional layer of the ResNet-50 network, and the output of the convolutional layer is input into the first maximum pooling layer, and the output of the maximum pooling layer is input into the first residual module, and the output of the residual module is input into the next residual module in turn. The output of the last residual module is the feature map matrix X with a dimension of (B, C, H, W), where B is the number of feature maps, H and W are the height and width of the feature map respectively, and C is the number of channels of the feature map.
[0036] Step 3: Construct a target detection model that integrates the Pearson coefficient matrix and attention.
[0037] 3.1) According to the feature map matrix X, obtain the feature map matrix F with global context information:
[0038] 3.1.1) Calculate the Pearson coefficient between each eigenvalue and all other eigenvalues in the feature map matrix X to form the Pearson coefficient matrix P:
[0039] Transform the feature map matrix X from 4 dimensions (B, C, H, W) to 3 dimensions (B, H*W, C), where H*W represents the resolution of the feature map.
[0040] Calculate the mean of the last dimension of the feature map matrix after dimension transformation:
[0041]
[0042] in, represents the mean of the eigenvector at position s in the b-th feature map matrix, X b,s,c represents the eigenvalue of the cth channel of the eigenvector at position s in the bth feature map matrix, b = 1, 2, ..., B, s = 1, 2, ..., H*W;
[0043] According to the mean of the last dimension of the feature map matrix and the eigenvalue X b,s,c Calculate the Pearson coefficient:
[0044]
[0045] in, represents the Pearson coefficient between the eigenvectors at positions s1 and s2 in the b-th feature map matrix, They represent the eigenvalues of the cth channel of the eigenvectors at positions s1 and s2 in the bth feature map matrix, respectively. They represent the mean of the eigenvectors at positions s1 and s2 in the b-th feature map matrix, b = 1, 2, ..., B; s1 = 1, 2, ..., H*W; s2 = 1, 2, ..., H*W;
[0046] Using the calculation formula of the Pearson coefficient, calculate the Pearson coefficients between all positions in the feature map matrix to obtain a Pearson coefficient matrix P with a dimension of (B, H*W, H*W);
[0047] 3.1.2) Input the Pearson coefficient matrix P into a multi-layer perceptron MLP with the same input and output layer dimensions for transformation:
[0048] Perform softmax normalization on the last dimension of the Pearson coefficient matrix P:
[0049]
[0050] in, represents the Pearson coefficient between the eigenvectors at positions s1 and s2 in the b-th feature map matrix after normalization, b = 1, 2, ..., B; s1 = 1, 2, ..., H*W; s2 = 1, 2, ..., H*W;
[0051] Using the calculation formula of softmax normalization, all positions of the Pearson coefficient matrix P are normalized to obtain the normalized Pearson coefficient matrix P′;
[0052] According to the feature map resolution H*W of different feature map matrices, a multi-branch structure is used to select the corresponding multi-layer perceptron MLP. The MLP consists of an input layer, a hidden layer and an output layer. The input dimension of the input layer and the output dimension of the output layer are both H*W, ensuring that the dimension of the Pearson coefficient matrix before and after the transformation remains unchanged. The activation function between the input layer and the hidden layer is RELU, and no activation function is set between the hidden layer and the output layer. The normalized Pearson coefficient matrix P′ is input into the input layer of the MLP, and the output result of the MLP is the transformed Pearson coefficient matrix MP:
[0053] MP=W2*f(W1*P′+b1)+b2
[0054] Where W1 and b1 represent the weight parameter and bias term between the input layer and the hidden layer, W2 and b2 represent the weight parameter and bias term between the hidden layer and the output layer, and f(·) represents the activation function RELU.
[0055] 3.1.3) The transformed Pearson coefficient matrix MP is matrix-multiplied with the feature map matrix X, and the matrix multiplication result MF is residually connected with the feature map matrix X and layer-normalized to obtain the layer-normalized residual connection matrix F′:
[0056] Perform matrix multiplication on the second and third dimensions of the Pearson coefficient matrix after multilayer perceptron transformation and the feature map matrix:
[0057] MF b =MP b ×X b ,
[0058] Among them, MF b MP represents the matrix multiplication result of the Pearson coefficient matrix after the b-th multi-layer perceptron transformation and the feature map matrix. b represents the Pearson coefficient matrix after the b-th multilayer perceptron transformation, X b represents the b-th feature map matrix, b = 1, 2, ..., B;
[0059] Using the calculation formula of matrix multiplication, all Pearson coefficient matrices and feature map matrices are matrix multiplied to obtain the matrix multiplication result MF. The matrix multiplication result MF is residually connected with the feature map matrix X and layer normalized to obtain the layer-normalized residual connection matrix F′:
[0060] F′=LayerNorm(MF+X)
[0061] Among them, LayerNorm(·) represents the layer normalization function, and X represents the feature map matrix.
[0062] 3.1.4) The layer-normalized residual connection matrix F′ is input to the forward feedback layer FFN, which consists of two fully connected layers. The input dimension of the first fully connected layer is consistent with the output dimension of the second fully connected layer. The activation function of the first fully connected layer is set to RELU, and the second fully connected layer has no activation function. The dropout parameters of the two fully connected layers are set to 0.1; the output result of the forward feedback layer is residually connected with the residual connection matrix F′ and layer-normalized to obtain a feature map matrix F with global context information:
[0063] F = LayerNorm(F′+FFN(F′))
[0064] Among them, LayerNorm(·) represents the layer normalization function, and FFN(·) represents the forward feedback layer calculation of F′;
[0065] 3.2) The original Transformer encoder is selected, which consists of six attention-based encoder layers with the same structure. The first three encoder layers are removed, and the feature map matrix F with global context information obtained in 3.1) is connected to the fourth encoder layer of the Transformer encoder to form a Transformer encoder with a four-layer structure of Pearson coefficient matrix and attention fusion, as shown in Figure 2 As shown;
[0066] 3.3) A DETR network is selected, which includes an encoder and a decoder, wherein the decoder consists of six decoder layers with the same structure. The Transformer encoder in 3.2) is connected to the decoder in the DETR network to form a target detection model that integrates the Pearson coefficient matrix and attention.
[0067] The structure of the above target detection model is: backbone network → Transformer encoder with Pearson coefficient matrix and attention fusion → decoder, where the Transformer encoder with Pearson coefficient matrix and attention fusion consists of an encoder layer based on Pearson coefficient matrix and three encoder layers based on attention, and the decoder consists of six decoder layers with the same structure, such as Figure 3 shown.
[0068] Step 4: Train the target detection model that integrates the Pearson coefficient matrix and attention.
[0069] 4.1) Set the loss function Loss of the target detection model with Pearson coefficient matrix and attention fusion to the sum of the cross entropy loss function and the L1 norm loss function, set the maximum number of iterations to T = 50, and set the initial number of iterations t = 0;
[0070] 4.2) Select two images and their corresponding true labels from the training set in order, input the images into the backbone network in step 2 for feature extraction, input the obtained feature map matrix into the target detection model that integrates the Pearson coefficient matrix and attention, output the prediction result of the image, and use the loss function Loss to calculate the loss value between the prediction result and the corresponding true label;
[0071] 4.3) Using the Adam optimizer, setting the learning rate to 0.001, the Pearson coefficient matrix and the attention fusion target detection model parameters are updated through the loss value;
[0072] 4.4) Determine whether all images in the training set are updated: If yes, execute 4.5), otherwise, return to 4.2);
[0073] 4.5) Determine whether the current number of iterations reaches the maximum number of iterations T: If so, obtain the trained Pearson coefficient matrix and the target detection model fused with attention, and execute step 5; if not, set t = t + 1 and return to 4.2).
[0074] Step 5: Use the trained object detection model to perform object detection on the input image.
[0075] The image to be detected is input into the target detection model that has been trained with the Pearson coefficient matrix and attention fusion. The features of the input image are extracted through its backbone network. The feature map extracts the global context information through the encoder layer based on the Pearson coefficient matrix. The feature map with global context information further extracts the global context information through the attention-based encoder layer. The output result of the attention-based encoder layer is then passed through the decoder to obtain the target category and target positioning coordinates in the image to be detected. The target positioning coordinates are used to draw the target bounding box in the image and mark the target category.
[0076] The effect of the present invention can be further verified by the following experiments.
[0077] 1. Experimental conditions:
[0078] The CPU uses Intel Xwon(R) Gold 6240CPU 2.60GHz×72, the GPU uses NVIDIA GeForceGTX 2080Ti×3, the operating system uses Ubuntu 16.04, the deep learning framework uses Pytorch1.8, and the NVIDIA computing package selects CUDA10.0+cuDNN7.4.1.
[0079] Use some public vehicle detection datasets as training data and test data.
[0080] 2. Experimental content
[0081] Experiment 1. The target detection model of the present invention and the existing DETR model are trained using the above training data set, and the accuracy, average training time and average test time during the training process are recorded respectively. The average training time and average test time are shown in Table 1, and the accuracy during the training process is shown in Table 2. Figure 4 As shown, where:
[0082] Figure 4 a is the mean accuracy mAP curve of the target detection model training in the present invention;
[0083] Figure 4 b is the mAP curve of the existing DETR model training;
[0084] As can be seen from 4a, as the number of iterations increases, mAP gradually increases and stabilizes to 0.30;
[0085] As can be seen from 4b, as the number of iterations increases, the mAP gradually decreases and stabilizes to 0.29, which is lower than the convergence accuracy of the present invention;
[0086] Depend on Figure 4 a and Figure 4 From the comparison of Fig. 1 and Fig. 2 , it can be seen that as the number of training iterations increases, the conversion effect of the multi-layer perceptron of the Pearson coefficient matrix of the target detection model in the present invention becomes better and better, so the mAP gradually increases; since the DETR model has loaded the trained model parameters, it has excellent fitting ability for the data set. When the data set is only a part of the original, as the number of training iterations increases, the model's fitting ability for the data set gradually decreases, and the mAP gradually decreases.
[0087] Table 1 shows the comparison results of training time and test time of the two models.
[0088] Existing DETR model Target detection model of the present invention Training time (seconds / image) 0.1974 0.1925(↑2.48%) Test time (seconds / image) 0.0837 0.0815(↑2.63%)
[0089] As can be seen from Table 1, compared with the DETR model, the target detection model proposed in the present invention has a training speed 2.48% higher than the DETR model and a test speed 2.63% higher.
[0090] Experiment 2: Randomly select a picture from the above test data set and input it into the target detection model of the present invention for target detection. The detection results are as follows: Figure 5 shown.
[0091] from Figure 4 It can be seen that the target detection model in the present invention can identify the categories of all vehicles in the input image and locate them.
[0092] In summary, the target detection model in the present invention has good detection effect, and compared with the existing DETR model, it has improvements in accuracy, training speed and testing speed, indicating that the present invention is better than the existing DETR model in practical applications.
Claims
1. A real-time target detection method combining Pearson coefficient matrix and attention, characterized in that: include: (1) Obtain a public vehicle detection dataset, randomly invert, scale, and crop the training set and test set images of the dataset, and normalize the images according to the set mean and standard deviation; (2) ResNet-50 is used as the backbone network to extract features from the normalized image, and a feature map matrix X with a dimension of (B, C, H, W) is obtained, where B is the number of feature maps, H and W are the height and width of the feature map, respectively, and C is the number of channels of the feature map; (3) Constructing a target detection model that integrates the Pearson coefficient matrix and attention: (3a) Obtain the feature map matrix F with global context information: Calculate the Pearson coefficient between each eigenvalue and all other eigenvalues in the feature map matrix X to form the Pearson coefficient matrix P; The Pearson coefficient matrix P is input into a multi-layer perceptron MLP with the same input and output layer dimensions for transformation; The transformed Pearson coefficient matrix MP is matrix-multiplied with the feature map matrix X, and the matrix multiplication result MF is residually connected with the feature map matrix X and layer-normalized to obtain the layer-normalized residual connection matrix F′; The normalized residual connection matrix F′ is input to the forward feedback layer FFN, and the output of the forward feedback layer is a feature map matrix F with global context information; (3b) Select the original Transformer encoder containing six identical encoder layers, remove the first three encoder layers, connect the feature map matrix F with global context information obtained in (3a) to the fourth encoder layer of the Transformer encoder, and form a Transformer encoder with a four-layer structure of Pearson coefficient matrix and attention fusion, and connect it to the decoder in the DETR network structure to form a target detection model with Pearson coefficient matrix and attention fusion; (4) Setting the loss function Loss of the target detection model that integrates the Pearson coefficient matrix and attention, and training the model using the gradient descent method to obtain a trained target detection model; (5) Input the normalized test set images into the trained target detection model to obtain the target classification and target location coordinates in the image to be predicted. Draw the target bounding box in the image and mark the target category using the target location coordinates.
2. The method according to claim 1, characterized in that In (2), ResNet-50 is used as the backbone network to extract features from the normalized image. The normalized image is input into the first convolutional layer of the ResNet-50 network, and the output of the convolutional layer is input into the first maximum pooling layer. The output of the maximum pooling layer is then input into four residual modules in sequence. The output of the last residual module is the feature map matrix X.
3. The method according to claim 1, characterized in that In (3a), the Pearson coefficient between each eigenvalue and all other eigenvalues in the feature map matrix X is calculated, and the obtained Pearson coefficient matrix P is implemented as follows: (3a1) Transform the dimension of the feature map matrix X, that is, transform its 4 dimensions (B, C, H, W) into 3 dimensions (B, H*W, C), where H*W represents the resolution of the feature map; Calculate the mean of the last dimension of the feature map matrix after dimension transformation: in, represents the mean of the eigenvector at position s in the b-th feature map matrix, X b,s,c represents the eigenvalue of the cth channel of the eigenvector at position s in the bth feature map matrix, b = 1, 2, ..., B; s = 1, 2, ..., H*W; (3a2) According to the mean of the last dimension of the feature map matrix and the eigenvalue X b,s,c Calculate the Pearson coefficient: in, represents the Pearson coefficient between the eigenvectors at positions s1 and s2 in the b-th feature map matrix, They represent the eigenvalues of the cth channel of the eigenvectors at positions s1 and s2 in the bth feature map matrix, respectively. They represent the mean of the eigenvectors at positions s1 and s2 in the b-th feature map matrix, b = 1, 2, ..., B; s1 = 1, 2, ..., H*W; s2 = 1, 2, ..., H*W; (3a3) Using formula (3a2), calculate the Pearson coefficients between all positions in the feature map matrix and obtain the Pearson coefficient matrix P with dimension (B, H*W, H*W).
4. The method according to claim 1, characterized in that: In (3a), the Pearson coefficient matrix P is input into a multilayer perceptron MLP with the same input and output layer dimensions for transformation, which is implemented as follows: (3a4) Perform softmax normalization on the last dimension of the Pearson coefficient matrix P: in, represents the Pearson coefficient between the eigenvectors at positions s1 and s2 in the b-th feature map matrix after normalization, b = 1, 2, ..., B; s1 = 1, 2, ..., H*W; s2 = 1, 2, ..., H*W; (3a5) Using formula (3a4), all positions of the Pearson coefficient matrix P are normalized to obtain the normalized Pearson coefficient matrix P′; (3a6) According to the feature map resolution H*W of different feature map matrices, a multi-branch structure is used to select the corresponding multi-layer perceptron MLP, and the normalized Pearson coefficient matrix P′ is input into the input layer of the MLP. The output result of the MLP is the transformed Pearson coefficient matrix MP: MP=W2*f(W1*P′+b1)+b2 Among them, W1 and b1 represent the weight parameter and bias term between the input layer and the hidden layer, W2 and b2 represent the weight parameter and bias term between the hidden layer and the output layer, and f(·) represents the activation function RELU.
5. The method according to claim 1, characterized in that The matrix multiplication result MF is obtained in (3a), which is implemented as follows: (3a7) Perform matrix multiplication on the second and third dimensions of the Pearson coefficient matrix after multilayer perceptron transformation and the feature map matrix: MF b =MP b ×X b , Among them, MF b MP represents the matrix multiplication result of the Pearson coefficient matrix after the b-th multi-layer perceptron transformation and the feature map matrix. b represents the Pearson coefficient matrix after the b-th multilayer perceptron transformation, X b represents the b-th feature map matrix, b = 1, 2, ..., B; (3a8) Using formula (3a7), matrix multiplication is performed on all Pearson coefficient matrices and feature map matrices to obtain the matrix multiplication result MF.
6. The method according to claim 1, characterized in that The residual connection matrix F′ after layer normalization is obtained in (3a) and is expressed as follows: F′=LayerNorm(MF+X) Among them, LayerNorm(·) represents the layer normalization function, and X represents the feature map matrix.
7. The method according to claim 1, characterized in that The feature map matrix F with global context information obtained in (3a) is expressed as follows: F = LayerNorm(F′+FFN(F′)) Among them, F represents the feature map matrix with global context information, LayerNorm(·) represents the layer normalization function, and FFN(·) represents the forward feedback layer calculation of F′.
8. The method according to claim 1, characterized in that The target detection model with the Pearson coefficient matrix and attention fusion obtained in (3b) has the following structure: backbone network → Transformer encoder with the Pearson coefficient matrix and attention fusion → decoder, where the Transformer encoder with the Pearson coefficient matrix and attention fusion consists of an encoder layer based on the Pearson coefficient matrix and three encoder layers based on attention.
9. The method according to claim 1, characterized in that In (4), the gradient descent method is used to train the target detection model that integrates the Pearson coefficient matrix and attention, which is implemented as follows: (4a) Set the loss function Loss of the target detection model that combines the Pearson coefficient matrix with attention to be the sum of the cross entropy loss function and the L1 norm loss function, set the maximum number of iterations to T = 50, and set the initial number of iterations t = 0; (4b) Select two images and their corresponding true labels from the training set in order, input the images into the backbone network in (2) for feature extraction, input the obtained feature map matrix into the target detection model that combines the Pearson coefficient matrix with attention, output the prediction result of the image, and use the loss function Loss to calculate the loss value between the prediction result and the corresponding true label; (4c) Using the Adam optimizer, the learning rate is set to 0.001, and the Pearson coefficient matrix and the attention fusion target detection model parameters are updated through the loss value; (4d) Determine whether all images in the training set have been updated: If yes, execute (4e); otherwise, return to (4b); (4e) Determine whether the current number of iterations reaches the maximum number of iterations T: If so, obtain the trained Pearson coefficient matrix and the target detection model fused with attention, and execute (5); if not, set t = t + 1 and return to (4b).
