Image object detection method based on dual attention mechanism

By using dual attention mechanism and CutMix operation in image target detection, combined with pyramid structure and attention information, it solves the complex background and real-time detection problems in traditional methods, and achieves more efficient target detection performance.

CN114863236BActive Publication Date: 2024-09-03CHINA TOBACCO ZHEJIANG IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210614509.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2024-09-03
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

Traditional image target detection methods have problems such as untargeted region selection strategies, high time complexity, and insufficient manual features, making it difficult to achieve real-time target detection in complex background environments.

Method used

An image target detection method based on dual attention mechanism is adopted, preprocessing data is generated through CutMix operation, a bottom-up pyramid structure is constructed, and spatial and channel attention information are combined to generate a dual attention information feature map, which is used to improve the model's performance. Generalization ability and detection performance.

Benefits of technology

It improves the network's information attention ability under regression and classification tasks, enhances detection performance, can identify targets more accurately, and improves detection accuracy in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114863236B
    Figure CN114863236B
Patent Text Reader

Abstract

The present invention discloses an image target detection method based on a dual attention mechanism, comprising: performing a CutMix operation on multiple training images to obtain preprocessed data; based on a convolutional neural network, extracting image features from the preprocessed data to form a bottom-up pyramid structure to obtain a multi-scale feature map; based on the dual attention mechanism, embedding the multi-scale feature map into a detection module network of a target detection model to obtain a dual attention information feature map; generating a candidate region of an input sample according to the dual attention information feature map. The image target detection method based on the dual attention mechanism of the present invention, through a multi-directional feature fusion mechanism, allows multi-directional fusion features containing rich contextual information to be sent to a detection network; the attention mechanism is deployed in the channel and spatial dimensions, so that different branches can autonomously filter effective information from the feature map according to the training objectives, thereby improving the network's ability to focus on useful information, and improving generalization ability and detection performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning image processing, and in particular to an image target detection method based on a dual attention mechanism. Background Art

[0002] In traditional image target detection methods, researchers usually extract features manually and then use machine learning algorithms to classify manual features to achieve the purpose of target detection. Most traditional detection systems mainly identify image objects based on information such as the target's contour, color, texture, and image key point features (SIFT). Although traditional methods have achieved certain research results in target recognition tasks, there are still two main problems with traditional image target detection methods: first, the region selection strategy based on the sliding window is not targeted, has high time complexity, and has window redundancy; second, the manual features obtained by traditional methods are not rich enough, and they are not robust enough for target detection with complex backgrounds. However, most current methods do not take into account issues such as the complex and diverse background environment of the image and the real-time requirements of target detection. Therefore, how to select the detection model, optimize the detection effect, and ensure the real-time performance of target detection is the key technical difficulty in the research of target detection algorithms.

[0003] Therefore, there is an urgent need for an image object detection method based on a dual attention mechanism. Summary of the invention

[0004] The purpose of the present invention is to provide an image target detection method based on a dual attention mechanism to solve the above-mentioned problems in the prior art, which can improve the network's ability to pay attention to useful information in different regression and classification tasks, thereby improving the generalization ability and detection performance of the model and accurately identifying targets.

[0005] The present invention provides an image target detection method based on a dual attention mechanism, which includes:

[0006] Perform CutMix operation on multiple training images to obtain preprocessed data;

[0007] Based on a convolutional neural network, image features in the preprocessed data are extracted to form a bottom-up pyramid structure to obtain a multi-scale feature map;

[0008] Based on the dual attention mechanism, the multi-scale feature map is embedded into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information;

[0009] Generate a candidate region of the input sample according to the dual attention information feature map.

[0010] In the above-mentioned image target detection method based on the dual attention mechanism, preferably, the CutMix operation is performed on multiple training images to obtain preprocessed data, which specifically includes:

[0011] Read four training images and the annotation information corresponding to the four training images from the training set at a time;

[0012] Randomly crop the four training images read, retain the label information within the cropped area, and perform corresponding cropping operations on the target position information at the edge;

[0013] The four image regions are reassembled into a new image at the upper left, lower left, upper right and lower right positions in the order in which they were read, and the target position in the annotation information is adjusted to align with the coordinates in the new image;

[0014] Combine the reorganized images and the corresponding annotation information into a new dataset.

[0015] The above-mentioned method for detecting an image target based on a dual attention mechanism, wherein preferably, the method extracts image features from the preprocessed data based on a convolutional neural network to form a bottom-up pyramid structure to obtain a multi-scale feature map, specifically including:

[0016] Extracting image features from the preprocessed data through a feature extraction network, and outputting three layers of multi-scale features output by different network layers;

[0017] The multi-scale features of the three layers are channel compressed by a convolutional neural network with a convolution kernel size of 1x1 as the input of the feature pyramid network;

[0018] The feature pyramid network is used to fuse the features from the horizontal connection through a top-down path and the addition of features at the same level to obtain the final first fused feature P3, the second fused feature P4 and the third fused feature P5;

[0019] Performing two upsampling operations on the third fused feature to obtain a more abstract first high-level feature P6 and a second high-level feature P7;

[0020] The first fused feature P3, the second fused feature P4 and the third fused feature P5, the first high-level feature P6 and the second high-level feature P7 are used as the multi-scale feature map and directly used as the final input of the detection module network.

[0021] The image target detection method based on the dual attention mechanism as described above, wherein preferably, based on the dual attention mechanism, the multi-scale feature map is embedded into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information, specifically including:

[0022] Using a dual attention module, the multi-scale feature map is embedded into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information, wherein the dual attention module includes three branch networks, namely, a spatial attention branch, a channel attention branch and an original feature transmission branch.

[0023] The image target detection method based on the dual attention mechanism as described above, wherein preferably, the dual attention module is used to embed the multi-scale feature map into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information, specifically including:

[0024] The multi-scale feature map is respectively subjected to the attention mechanism network learning in two dimensions, namely, the spatial attention branch corresponding to the spatial dimension and the channel attention branch corresponding to the channel dimension include a combination structure of average pooling and maximum pooling, and in the network structures corresponding to the spatial attention branch and the channel attention branch, P l represents the output feature from the lth layer of the feature pyramid network, as the input of the dual attention module, the dimension of the input feature is expressed as H×W×C, H represents the length of the multi-scale feature map, W represents the width of the multi-scale feature map, and C represents the number of channels of the multi-scale feature map;

[0025] For the spatial attention branch, the input feature P is respectively l Perform maximum pooling and average pooling calculations to obtain weight matrices of H×W×1, respectively. Then, concatenate the matrices obtained by the maximum pooling and average pooling operations to obtain a weight matrix containing multiple feature information with a dimension of H×W×2. Then, use the convolution operation to compress the concatenated results through channels, and finally obtain a spatial attention weight matrix with a dimension of H×W×1. This process can be expressed as formula (1):

[0026] W s =Conv 1×1 (concat(S maxpool (Pl), S avgpool (P l ))) (1)

[0027] Among them, W sRepresents the weight matrix containing spatial attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, S maxpool is the maximum pooling in the spatial dimension, S avgpool is the average pooling in the spatial dimension;

[0028] For the channel attention branch, the input feature P is respectively l Perform maximum pooling and average pooling calculations, compress the matrix of dimension H×W×C on each channel into a matrix of dimension 1×1×C through different pooling operations, and then concatenate the two weight matrices obtained by the maximum pooling and average pooling operations to obtain a matrix of dimension 1×1×2C. Then use the convolution operation to reduce the dimension, and finally obtain a channel attention weight matrix of dimension 1×1×C. The process is shown in formula (2).

[0029] W c =Conv 1×1 (concat(C maxpool (P l ), C avgpool (P l ))) (2)

[0030] Among them, W c Represents the weight matrix containing channel attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, C maxpool is the maximum pooling in the channel dimension, C avgpool is the average pooling in the channel dimension;

[0031] Multiply the weight matrix containing spatial attention information and the weight matrix containing channel attention information to obtain the final dual attention weight matrix W Matrix , as shown in formula (3),

[0032]

[0033] The obtained dual attention weight matrix is ​​activated by the Sigmoid function. The Sigmoid function is defined as follows:

[0034]

[0035] The activated dual attention weight matrix is ​​weighted and summed with the original input features to obtain a feature map with rich attention information, as shown in formula (5).

[0036]

[0037] In the above-mentioned image target detection method based on the dual attention mechanism, preferably, generating a candidate region of the input sample according to the dual attention information feature map specifically includes:

[0038] Use the RPN network to output the input sample into multiple candidate regions;

[0039] The loss function of the target detection model is used to jointly train the classification probability and bounding box regression of multiple candidate regions to determine the final position and category information of the input sample.

[0040] In the above-mentioned image target detection method based on the dual attention mechanism, preferably, the loss function of the target detection model includes classification loss and regression loss, which are defined as follows:

[0041]

[0042] Among them, p x,y Represents the classification probability of pixel point (x, y), t x,y Represents the predicted value of the regression box of the pixel point (x, y), specifically the distance value from the pixel point (x, y) to the four boundaries of the regression box, t * x,y Indicates the distance from the pixel point (x, y) to the four boundaries of the calibration image frame, L cls represents the classification loss, L reg represents the regression loss, N pos represents the number of positive samples, c * x,y represents the classification category, c * x,y =1 for image target, c * x,y = 0 is the background, λ represents the regression loss L reg The weight factor is an adjustable parameter used to balance two different loss functions. The default value is 1. * x,y>0} represents the indicator function, when c * x,y When c > 0, the function value is 1. * x,y When ≤0, the function value is 0.

[0043] In the above-mentioned method for detecting an image object based on a dual attention mechanism, preferably, the step of using the RPN network to output an input sample as a plurality of candidate regions specifically includes:

[0044] The RPN network is used to map the input sample into a probability value and four coordinate values, where the probability value is used to represent the probability of an object in the anchors layer, and the four coordinate values ​​are used to regress and define the position of the object;

[0045] According to the probability value and the four coordinate values, a feature map of fixed size is obtained;

[0046] The fixed-size feature map is fed into the fully connected layer to determine the target category of the candidate region.

[0047] The image target detection method based on the dual attention mechanism as described above, wherein preferably, the loss function of the target detection model is used to perform classification probability and bounding box regression joint training on multiple candidate regions to determine the final position and category information of the input sample, specifically including:

[0048] For the candidate region, the category to which each positive sample belongs is calculated through a fully connected layer and a normalization function, and a probability vector of the category is output;

[0049] Through the regression network, the position offset of each positive sample is obtained by bounding box regression;

[0050] Use the non-maximum suppression method to remove redundant prediction boxes, retain the one with the best result, and obtain the final detection result.

[0051] The invention provides an image target detection method based on a dual attention mechanism. On the basis of a feature pyramid network, a new multi-directional feature fusion mechanism is designed, so that the single-layer feature originally sent to the detection network becomes a multi-directional fusion feature containing rich context information, so as to obtain a better image target feature representation; through a detection module network based on the dual attention mechanism, the attention mechanism is deployed on different feature dimensions of channels and spaces to form a dual attention mechanism, and then applied to different branches of the detection module respectively, so that different branches can autonomously filter effective information from feature maps according to the training objectives of each network, thereby improving the network's ability to pay attention to useful information under different regression and classification tasks, thereby improving the generalization ability and detection performance of the model, and accurately identifying the target; the invention solves the problem that the environment and background in the image are complex and diverse, and the target samples participating in the training are insufficient, thereby resulting in the network being unable to fully learn the complex and changeable scene features, low detection accuracy, and the like. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be further described below with reference to the accompanying drawings, in which:

[0053] Figure 1 A flowchart of an embodiment of an image target detection method based on a dual attention mechanism provided by the present invention;

[0054] Figure 2An algorithm logic diagram of an embodiment of an image target detection method based on a dual attention mechanism provided by the present invention;

[0055] Figure 3 It is a feature pyramid network structure;

[0056] Figure 4 Schematic diagram of the dual attention module. DETAILED DESCRIPTION

[0057] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. The description of the exemplary embodiments is merely illustrative and is in no way intended to limit the present disclosure and its application or use. The present disclosure can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to make the present disclosure thorough and complete and to fully express the scope of the present disclosure to those skilled in the art. It should be noted that unless otherwise specifically stated, the relative arrangement of the components and steps, the composition of the materials, the numerical expressions and the numerical values ​​set forth in these embodiments should be interpreted as being merely exemplary and not as limiting.

[0058] The words "first", "second" and similar words used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different parts. The words "include" or "comprises" and similar words mean that the elements before the word include the elements listed after the word, and do not exclude the possibility of including other elements. "Up", "down" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0059] In the present disclosure, when a specific component is described as being located between a first component and a second component, there may or may not be an intermediate component between the specific component and the first component or the second component. When a specific component is described as being connected to other components, the specific component may be directly connected to the other components without an intermediate component, or may not be directly connected to the other components but have an intermediate component.

[0060] All terms (including technical terms or scientific terms) used in the present disclosure have the same meanings as those understood by ordinary technicians in the field to which the present disclosure belongs, unless otherwise specifically defined. It should also be understood that terms defined in general dictionaries, such as general dictionaries, should be interpreted as having meanings consistent with their meanings in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined herein.

[0061] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0062] like Figure 1 and Figure 2 As shown, the image target detection method based on the dual attention mechanism provided in this embodiment includes the following steps in actual execution:

[0063] Step S1: Perform a CutMix operation on multiple training images to obtain preprocessed data.

[0064] The present invention randomly cuts and splices four training images, that is, performs CutMix operation on multiple images, so that the process of the model learning from one image at a time becomes the process of learning from four images at the same time, which is equivalent to the model learning four different background environments at a time, so that the model learns richer image features. In an embodiment of the image target detection method based on the dual attention mechanism of the present invention, the step S1 may specifically include:

[0065] Step S11, read four training images and the annotation information corresponding to the four training images from the training set at one time.

[0066] The annotation information includes category and location information.

[0067] Step S12: randomly crop the four training images read, retain the label information within the cropped area, and perform corresponding cropping operations on the target position information at the edge.

[0068] Step S13, recombining the four obtained image areas into a new image at the upper left, lower left, upper right and lower right positions in the order in which they were read, and adjusting the target position in the annotation information to align it with the coordinates in the new image.

[0069] Step S14: Combining the reorganized images and the corresponding annotation information into a new data set.

[0070] Step S2: Based on a convolutional neural network, extract image features from the preprocessed data to form a bottom-up pyramid structure to obtain a multi-scale feature map.

[0071] In step S2, the data preprocessed in step S1 is extracted from the original image using a feature extraction module based on a convolutional neural network to form a bottom-up pyramid structure, output multi-scale features, and construct a horizontal connection module responsible for the unification and transfer of feature scales. Figure 3 As shown, in one embodiment of the image target detection method based on the dual attention mechanism of the present invention, the step S2 may specifically include:

[0072] Step S21, extracting image features from the preprocessed data through a feature extraction network, and outputting three layers of multi-scale features output by different network layers (C3, C4 and C5).

[0073] Step S22: Channel compression is performed on the multi-scale features of the three layers by using a convolutional neural network with a convolution kernel size of 1x1 as input to the feature pyramid network.

[0074] In one embodiment of the present invention, the multi-scale features of the three layers are uniformly compressed to 256 dimensions.

[0075] Step S23: using the feature pyramid network to fuse the features from the horizontal connection through a top-down path and by adding features of the same level, to obtain the final first fused feature P3, the second fused feature P4 and the third fused feature P5.

[0076] Step S24: perform two upsampling operations on the third fused feature to obtain a more abstract first high-level feature P6 and a second high-level feature P7.

[0077] Among them, the two upsampling operations are implemented through two convolutions.

[0078] Step S25: Use the first fused feature P3, the second fused feature P4 and the third fused feature P5, the first high-level feature P6 and the second high-level feature P7 as the multi-scale feature map, and directly use them as the final input of the detection module network.

[0079] Step S3: Based on the dual attention mechanism, the multi-scale feature map is embedded into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information.

[0080] In step S3, a dual attention module (DAM) is designed for the features obtained in step S2, and the module is embedded in the detection module network of the target detection model. Specifically, in the present invention, the multi-scale feature map is embedded in the detection module network of the target detection model using the dual attention module to obtain a dual attention information feature map including spatial attention information and channel attention information, wherein the dual attention module includes three branch networks, namely, a spatial attention branch, a channel attention branch, and an original feature transmission branch. In one embodiment of the image target detection method based on the dual attention mechanism of the present invention, the step S3 may specifically include:

[0081] Step S31, learning the attention mechanism network for the multi-scale feature map in two dimensions, space and channel, respectively, wherein the spatial attention branch corresponding to the spatial dimension and the channel attention branch corresponding to the channel dimension include a combination structure of average pooling and maximum pooling, and the network structure corresponding to the spatial attention branch and the channel attention branch (such as Figure 4 As shown), P l Represents the output features from the lth layer of the feature pyramid network, as the input of the dual attention module, the dimension of the input feature is expressed as H×W×C, H represents the length of the multi-scale feature map, W represents the width of the multi-scale feature map, and C represents the number of channels of the multi-scale feature map.

[0082] For these two attention mechanism networks, the present invention selects a combination structure of average pooling and maximum pooling.

[0083] Step S32: For the spatial attention branch, the input feature P is respectively l Perform maximum pooling and average pooling calculations to obtain weight matrices of H×W×1, respectively. Then, concatenate the matrices obtained by the maximum pooling and average pooling operations to obtain a weight matrix containing multiple feature information with a dimension of H×W×2. Then, use the convolution operation to compress the concatenated results through channels, and finally obtain a spatial attention weight matrix with a dimension of H×W×1. This process can be expressed as formula (1):

[0084] W s =Conv 1×1 (concat(S maxpool (P l ), S avgpool (P l ))) (1)

[0085] Among them, W s Represents the weight matrix containing spatial attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, S maxpool is the maximum pooling in the spatial dimension, S avgpool is the average pooling in the spatial dimension.

[0086] Step S33: For the channel attention branch, the input feature P is respectively lPerform maximum pooling and average pooling calculations, compress the matrix of dimension H×W×C on each channel into a matrix of dimension 1×1×C through different pooling operations, and then concatenate the two weight matrices obtained by the maximum pooling and average pooling operations to obtain a matrix of dimension 1×1×2C. Then use the convolution operation to reduce the dimension, and finally obtain a channel attention weight matrix of dimension 1×1×C. The process is shown in formula (2).

[0087] W c =Conv 1×1 (concat(C maxpool (P l ), C avgpool (P l ))) (2)

[0088] Among them, W c Represents the weight matrix containing channel attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, C maxpool is the maximum pooling in the channel dimension, C avgpool is the average pooling in the channel dimension.

[0089] Step S34: multiply the weight matrix containing spatial attention information and the weight matrix containing channel attention information to obtain the final dual attention weight matrix W Matrix , as shown in formula (3),

[0090]

[0091] Step S35: Activate the obtained dual attention weight matrix through the Sigmoid function. The Sigmoid function is defined as follows:

[0092]

[0093] The nonlinear expression ability of the network can be improved through activation operations.

[0094] Step S36: Perform a weighted sum operation on the activated dual attention weight matrix and the original input feature to obtain a feature map with rich attention information, as shown in formula (5).

[0095]

[0096] Through step S36, the network can autonomously complete the learning of the region of interest in both channel and space dimensions.

[0097] Step S4: Generate a candidate region of the input sample based on the dual attention information feature map.

[0098] In one embodiment of the image target detection method based on the dual attention mechanism of the present invention, the step S4 may specifically include:

[0099] Step S41: Use the RPN network to output the input sample as multiple candidate regions.

[0100] In one implementation of the image target detection method based on the dual attention mechanism of the present invention, the step S41 may specifically include:

[0101] Step S411: Use the RPN network to map the input sample into a probability value and four coordinate values, where the probability value is used to represent the probability of an object in the anchors layer, and the four coordinate values ​​are used to regress and define the position of the object.

[0102] Among them, the anchors layer uses softmax to determine whether the anchor contains the target, which is a two-classification problem.

[0103] Step S412: Obtain a feature map of a fixed size according to the probability value and the four coordinate values.

[0104] Step S413: Send the fixed-size feature map to the fully connected layer to determine the target category of the candidate area.

[0105] After integrating the probability value and the four coordinate values, a feature map of a fixed size is obtained, which is then sent to the subsequent fully connected layer to determine the target category.

[0106] Step S42: Use the loss function of the target detection model to jointly train the classification probability and bounding box regression of multiple candidate regions to determine the final position and category information of the input sample.

[0107] Among them, the loss function of the target detection model includes classification loss (Softmax Loss) and regression loss (Smooth L1 Loss), which are defined as follows:

[0108]

[0109] Among them, p x,y Represents the classification probability of pixel point (x, y), t x,y Represents the predicted value of the regression box of the pixel point (x, y), specifically the distance value from the pixel point (x, y) to the four boundaries of the regression box, t * x,y Indicates the distance from the pixel point (x, y) to the four boundaries of the calibration image frame, L cls represents the classification loss, L reg represents the regression loss, N pos represents the number of positive samples, c* x,y represents the classification category, c * x,y =1 for image target, c * x,y = 0 is the background, λ represents the regression loss L reg The weight factor is an adjustable parameter used to balance two different loss functions. The default value is 1. * x,y>0} represents the indicator function, when c * x,y When c > 0, the function value is 1. * x,y When ≤0, the function value is 0.

[0110] In one implementation of the image target detection method based on the dual attention mechanism of the present invention, the step S42 may specifically include:

[0111] Step S421: For the candidate region, the category to which each positive sample belongs is calculated through a fully connected layer and a normalization function, and a probability vector of the category is output.

[0112] Step S422: Using a regression network, a bounding box is regressed to obtain the position offset of each positive sample.

[0113] Through step S422, a more accurate target detection frame can be obtained.

[0114] Step S423: Use the non-maximum suppression method to remove redundant prediction boxes, retain the one with the best result, and obtain the final detection result.

[0115] The image target detection method based on the dual attention mechanism provided by the embodiment of the present invention designs a new multi-directional feature fusion mechanism on the basis of the feature pyramid network, so that the single-layer features originally sent to the detection network are transformed into multi-directional fusion features containing rich contextual information, thereby obtaining a better image target feature representation; through the detection module network based on the dual attention mechanism, the attention mechanism is deployed on different feature dimensions of channels and spaces to form a dual attention mechanism, and then applied to different branches of the detection module respectively, so that different branches can autonomously filter effective information from the feature map according to the training objectives of each network, thereby improving the network's ability to pay attention to useful information under different regression and classification tasks, thereby improving the generalization ability and detection performance of the model, and accurately identifying targets; the present invention solves the problem that the environment and background in the image are complex and diverse, and the target samples involved in the training are insufficient, which leads to the network's inability to fully learn the complex and changeable scene features, low detection accuracy, and other shortcomings.

[0116] So far, various embodiments of the present disclosure have been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.

[0117] Although some specific embodiments of the present disclosure have been described in detail by way of examples, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified or some technical features may be replaced by equivalents without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.

Claims

1. An image object detection method based on a dual attention mechanism, characterized in that: include: Step S1, performing CutMix operation on multiple training images to obtain preprocessed data; The step S1 specifically includes: Step S11, reading four training images and the annotation information corresponding to the four training images from the training set at one time; Step S12: randomly crop the four training images read, retain the label information within the cropping area, and perform corresponding cropping operations on the target position information at the edge; Step S13, recombining the obtained four image regions into a new image at the upper left, lower left, upper right and lower right positions in the order in which they were read, and adjusting the target position in the annotation information to align it with the coordinates in the new image; Step S14, combining the reorganized image and the corresponding annotation information into a new data set; Step S2: based on a convolutional neural network, extracting image features from the preprocessed data, forming a bottom-up pyramid structure, and obtaining a multi-scale feature map; The step S2 specifically includes: Step S21, extracting image features from the preprocessed data through a feature extraction network, and outputting three layers of multi-scale features output by different network layers; Step S22: performing channel compression on the multi-scale features of the three layers by using a convolutional neural network with a convolution kernel size of 1x1 as the input of the feature pyramid network; Step S23, using the feature pyramid network to fuse the features from the horizontal connection through a top-down path and the addition of features at the same level, to obtain the final first fused feature P3, the second fused feature P4 and the third fused feature P5; Step S24, performing two upsampling operations on the third fused feature to obtain a more abstract first high-level feature P6 and a second high-level feature P7; Step S25, using the first fused feature P3, the second fused feature P4 and the third fused feature P5, the first high-level feature P6 and the second high-level feature P7 as the multi-scale feature map, directly as the final input of the detection module network; Step S3: Based on the dual attention mechanism, the multi-scale feature map is embedded into the detection module network of the target detection model to obtain a dual attention information feature map including spatial attention information and channel attention information; In step S3, for the features obtained in step S2, a dual attention module is designed, and the module is embedded in the detection module network of the target detection model. The multi-scale feature map is embedded in the detection module network of the target detection model using the dual attention module to obtain a dual attention information feature map including spatial attention information and channel attention information, wherein the dual attention module includes three branch networks, namely a spatial attention branch, a channel attention branch, and an original feature transmission branch; The step S3 specifically includes: Step S31, learning the attention mechanism network for the multi-scale feature map in two dimensions, space and channel, respectively, wherein the spatial attention branch corresponding to the spatial dimension and the channel attention branch corresponding to the channel dimension include a combination structure of average pooling and maximum pooling, and in the network structure corresponding to the spatial attention branch and the channel attention branch, P l represents the output feature from the lth layer of the feature pyramid network, as the input of the dual attention module, the dimension of the input feature is expressed as H×W×C, H represents the length of the multi-scale feature map, W represents the width of the multi-scale feature map, and C represents the number of channels of the multi-scale feature map; Step S32: For the spatial attention branch, the input feature P is respectively l Perform maximum pooling and average pooling calculations to obtain weight matrices of H×W×1, respectively. Then, concatenate the matrices obtained by the maximum pooling and average pooling operations to obtain a weight matrix containing multiple feature information with a dimension of H×W×2. Then, use the convolution operation to compress the concatenated results through channels, and finally obtain a spatial attention weight matrix with a dimension of H×W×1. The process is expressed as formula (1): W s =Conv 1×1 (concat(S maxpool (P l ),S avgpool (P l ))) (1) Among them, W s Represents the weight matrix containing spatial attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, S maxpool is the maximum pooling in the spatial dimension, S avgpool is the average pooling in the spatial dimension; Step S33: For the channel attention branch, the input feature P is respectively l Perform maximum pooling and average pooling calculations, compress the matrix of dimension H×W×C on each channel into a matrix of dimension 1×1×C through different pooling operations, and then concatenate the two weight matrices obtained by the maximum pooling and average pooling operations to obtain a matrix of dimension 1×1×2C. Then use the convolution operation to reduce the dimension, and finally obtain a channel attention weight matrix of dimension 1×1×C. The process is shown in formula (2). W c =Conv 1×1 (concat(C maxpool (P l ),C avgpool (P l ))) (2) Among them, W c Represents the weight matrix containing channel attention information, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, C maxpool is the maximum pooling in the channel dimension, C avgpool is the average pooling in the channel dimension; Step S34: multiply the weight matrix containing spatial attention information and the weight matrix containing channel attention information to obtain the final dual attention weight matrix W Matrix , as shown in formula (3), Step S35: Activate the obtained dual attention weight matrix through the Sigmoid function. The Sigmoid function is defined as follows: Step S36: Perform a weighted sum operation on the activated dual attention weight matrix and the original input feature to obtain a feature map with rich attention information, as shown in formula (5). Step S4: Generate a candidate region of the input sample based on the dual attention information feature map.

2. The image target detection method based on the dual attention mechanism according to claim 1 is characterized in that: Generating a candidate region of the input sample according to the dual attention information feature map specifically includes: Use the RPN network to output the input sample into multiple candidate regions; The loss function of the target detection model is used to jointly train the classification probability and bounding box regression of multiple candidate regions to determine the final position and category information of the input sample.

3. The image target detection method based on the dual attention mechanism according to claim 2 is characterized in that: The loss function of the target detection model includes classification loss and regression loss, which are defined as follows: Among them, p x,y Represents the classification probability of pixel point (x, y), t x,y Represents the predicted value of the regression box of the pixel point (x, y), specifically the distance value from the pixel point (x, y) to the four boundaries of the regression box, t * x,y Indicates the distance value from the pixel point (x, y) to the four boundaries of the calibration image frame, L cls represents the classification loss, L reg represents the regression loss, N pos represents the number of positive samples, c * x,y represents the classification category, c * x,y =1 for image target, c * x,y = 0 is the background, λ represents the regression loss L reg The weight factor is an adjustable parameter used to balance two different loss functions. The default value is 1. * x,y>0 } represents the indicator function, when c * x,y When c > 0, the function value is 1. * x,y When ≤0, the function value is 0.

4. The image target detection method based on the dual attention mechanism according to claim 2, characterized in that: The RPN network is used to output the input sample into multiple candidate regions, specifically including: The RPN network is used to map the input sample into a probability value and four coordinate values, where the probability value is used to represent the probability of an object in the anchors layer, and the four coordinate values ​​are used to regress and define the position of the object; According to the probability value and the four coordinate values, a feature map of fixed size is obtained; The fixed-size feature map is fed into the fully connected layer to determine the target category of the candidate region.

5. The image target detection method based on the dual attention mechanism according to claim 3 is characterized in that: The loss function of the target detection model is used to perform classification probability and bounding box regression joint training on multiple candidate regions to determine the final position and category information of the input sample, specifically including: For the candidate region, the category to which each positive sample belongs is calculated through a fully connected layer and a normalization function, and a probability vector of the category is output; Through the regression network, the position offset of each positive sample is obtained by bounding box regression; Use the non-maximum suppression method to remove redundant prediction boxes, retain the one with the best result, and obtain the final detection result.