A target detection method and system based on a transformer and a fusion attention mechanism

By fusing local and global features using the Swing Transformer and AGFF method in object detection tasks, and combining it with the YOLOX detector, the problem of insufficient local feature extraction in object detection by convolutional neural networks and Transformers is solved, achieving more efficient low signal-to-noise ratio object detection.

CN115908772BActive Publication Date: 2026-04-17SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN
Filing Date
2022-11-23
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing convolutional neural networks struggle to effectively capture local edge texture features in object detection tasks, and the Transformer model lacks the ability to extract local information, resulting in poor object detection performance with low signal-to-noise ratio.

Method used

The Swin Transformer is used as the backbone network, combined with the attention global feature fusion method (AGFF) and the YOLOX detector. Local and global features are fused through cross-layer cascading. A 1×1 convolutional layer is introduced to improve feature extraction capability, and the SimOTA method is used to self-adapt the ground truth feature map.

Benefits of technology

It improves the model's feature capture capability in target detection tasks, enhances the detection performance of targets with low signal-to-noise ratio, improves the model's flexibility and adaptability, and improves the convergence speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115908772B_ABST
    Figure CN115908772B_ABST
Patent Text Reader

Abstract

This invention proposes a target detection method based on Transformer and a fusion attention mechanism, comprising: acquiring a target image for preprocessing; inputting the preprocessed target image into a trained target detection model and outputting the detection result; wherein the target detection model includes a Swing Transformer module, an attention fusion module, and a detection module, the Swing Transformer module is used to extract global features of the target image, the attention fusion module is used for local feature extraction, and the global and local features are fused in a cross-layer cascade manner, the detection module is used to output the detection result based on the fused features. By fusing the local receptive field with the global information of the Transformer, the ability to fuse local features with global information is further improved, enhancing the detection effect of low signal-to-noise ratio targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of deep learning computer vision technology, and in particular relates to a target detection method and system based on Transformer and fusion attention mechanism. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] With the development of deep learning technology in the past two years, increasingly sophisticated model structures have emerged. Before 2020, the field of image vision mostly used Convolutional Neural Networks (CNNs) for image feature extraction. CNNs use a hierarchical approach to feature representation. Compared to Natural Language Processing (NLP), which uses sequences for feature representation, CNNs need to accumulate features layer by layer, extracting higher-level semantic information features from shallow to deep. Even so, the actual receptive field obtained by CNNs is still much smaller than the theoretical receptive field, which is not conducive to capturing feature information and instead leads to a dramatic increase in computational cost. To address this, many scholars began to try applying the Transformer model, used in NLP, to the field of computer vision (CV). In 2020, Google proposed the ViT model, which verified the effectiveness of the Transformer model in image classification. Thus, the era of CV based on Transformers began. The Swin Transformer model, proposed at CVPR 2021, uses shifted windows for computation. Addressing the scale transformation of visual entities and high-resolution image problems, it leverages the Shifted Windows Multi-Head Self-Attention (SW-MSA) concept to transfer information between adjacent windows, strengthening contextual connections. While Swin Transformer demonstrates good performance, it tends to extract global image features and is less effective at extracting local information. Object detection tasks often involve low signal-to-noise ratio target features, resulting in weak extraction capabilities for local edge textures and other feature information. Summary of the Invention

[0004] To overcome the shortcomings of the existing technologies, this invention provides a target detection method and system based on Transformer and a fusion attention mechanism. The Swing Transformer is used as the backbone network for target detection tasks. The AGFF method is proposed to fuse local receptive fields with global information from the Transformer, further enhancing the ability to fuse local features with global information and improving the detection performance of low signal-to-noise ratio targets. A YOLOX detector is employed to complete the detection task.

[0005] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solution: a target detection method based on Transformer and fusion attention mechanism, comprising:

[0006] Acquire the image to be detected and perform preprocessing;

[0007] The preprocessed image to be detected is input into the trained target detection model, and the detection result is output.

[0008] The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse global and local features in a cross-layer cascade manner. The detection module is used to output detection results based on the fused features.

[0009] A second aspect of the present invention provides a target detection system based on Transformer and fusion attention mechanism, comprising:

[0010] Image acquisition module: Acquires the image to be detected and performs preprocessing;

[0011] Object detection module: Inputs the preprocessed image to be detected into the trained object detection model and outputs the detection results;

[0012] The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse global and local features in a cross-layer cascade manner. The detection module is used to output detection results based on the fused features.

[0013] A third aspect of the present invention provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, perform the steps described in the above method.

[0014] A fourth aspect of the present invention provides an electronic device including a memory and a processor, and computer instructions stored in the memory and running on the processor, wherein the computer instructions, when executed by the processor, perform the steps described in the above method.

[0015] The above one or more technical solutions have the following beneficial effects:

[0016] In this invention, the Transformer model is applied to object detection tasks, and a convolutional neural network is integrated to improve the model's feature capture capability. Firstly, the Swing Transformer utilizes Shifted Windows to enable information interaction and transfer between adjacent windows, overcoming the limitation of ViT, which only performs feature interaction within a window. Simultaneously, three 1×1 convolutional layers are introduced at the detection layer branch to achieve dimensionality transformation while acquiring local edge texture features, thereby enhancing the model's feature extraction capability.

[0017] In this invention, an attention global feature fusion method (AGFF) is proposed. This method fuses local receptive field information with global information. This method adopts a cross-layer cascade approach to fuse features with inconsistent semantics and scale. While fusing semantic information from different layers, it obtains global information obtained from the Transformer. On this basis, the local receptive field information and global information are further fused to achieve feature fusion.

[0018] In this invention, the YOLOX detector is employed, which utilizes an anchor-free mechanism for greater flexibility and adaptability. Furthermore, a branch-decoupled head is used, significantly improving convergence speed. The SimOTA method is introduced to automatically analyze the number of samples required for each ground truth (GT) and automatically adapt the GT-corresponding feature map to complete the detection task.

[0019] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0020] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0021] Figure 1 This is a schematic diagram of data preprocessing for the Mosaic operation in Embodiment 1 of the present invention;

[0022] Figure 2 This is a schematic diagram of data preprocessing in the MixUP operation of Embodiment 1 of the present invention;

[0023] Figure 3 This is a schematic diagram of the overall structure of the target detection model in Embodiment 1 of the present invention;

[0024] Figure 4 This is a structural diagram of the Swing Transformer block in Embodiment 1 of the present invention;

[0025] Figure 5 This is a structural diagram of the AGFF in Embodiment 1 of the present invention;

[0026] Figure 6 This is a diagram showing the prediction effect of the model in Embodiment 1 of the present invention. Detailed Implementation

[0027] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0028] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations of the present invention.

[0029] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.

[0030] Example 1

[0031] like Figure 3 As shown, this embodiment discloses a target detection method based on Transformer and fused attention mechanism, including:

[0032] Acquire the image to be detected and perform preprocessing;

[0033] The preprocessed image to be detected is input into the trained target detection model, and the detection result is output.

[0034] The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse global and local features in a cross-layer cascade manner. The detection module is used to output detection results based on the fused features.

[0035] In this embodiment, the data is first divided into training samples and test samples, with 80% being training samples and 20% being test samples.

[0036] Preprocessing employs methods such as data shape transformation and color gamut transformation to enhance the image, including conventional geometric transformations (such as image flipping, scaling, rotation, and shifting), color transformations (such as blurring, color gamut processing, noise reduction, and fill), and mixed-class enhancement (such as the Mixup operation). Figure 1-2 As shown, this embodiment uses Mosaic and Mixup operations to enrich the dataset background and achieve image fusion processing, thereby expanding the dataset.

[0037] In this embodiment, the Swin Transformer module mainly includes four layers for feature extraction. Before feature extraction, the image needs to be segmented. The input image is 448×448. After passing through the Patch Partition module, the patch size is set to 4×4 and the embed_dim is set to 96. That is, after passing through this layer, the convolutional feature map becomes 112×112 with 96 channels. Then it enters the four layers.

[0038] (1) Layer 1: First, the feature map passes through a linear embedding layer, which is implemented using a convolutional structure with LayerNorm(LN) operation. This layer flattens the feature map to 12544×96. Then, the feature sequence is processed through the SwinTransformer Block layer. The SwinTransformer Block layer includes W-MSA and SW-MSA structures. The window size is set to 14×14 to transform the original 12544-length sequence into a 196-length sequence, thus reducing computational complexity. The depth is set to 2, meaning it passes through two consecutive SwinTransformerBlock layers. The output matrix vector is [-1, 3136, 192]. At this point, a 1×1 convolution is used to transform the matrix vector, resulting in a feature map of size 56×56 with 192 channels, and the vector is [-1, 56, 56, 192]. To integrate global and local feature information, the AGFF module is introduced here. The first feature map output by the 1×1 convolution and the output of the linear embedding layer are used as inputs to the AGFF module. After global feature information fusion, the fourth feature map with a size of 56×56 and 192 channels is obtained and used as the prediction branch head of YOLOX, denoted as f1.

[0039] (2) Layer 2: Compared to layer 1, layer 2 first goes through a Patch Merging layer to reduce the image resolution, effectively downsampling. After this modification, the feature map becomes a 28×28 feature map with 384 channels. It then goes through two Swin Transformer block layers, resulting in a final feature map that is still 28×28. Instead of fusing with AGFF, it directly undergoes a 1×1 convolution to transform the dimensions, obtaining the second feature map, which serves as the prediction branch head for YOLOX, denoted as f2.

[0040] (3) Layer 3: First, the feature map is obtained through the Patch Merging layer, resulting in a 14×14 feature map. Then, the Swin Transformer block layer is passed with a depth of 6, resulting in a final feature map of 14×14 with 768 channels. This layer does not perform AGFF fusion or 1×1 convolution.

[0041] (4) Layer 4: First, the feature map passes through the Patch Merging layer, then two Swin Transformer Block layers, resulting in a 7×7 feature map. A 1×1 convolution is then introduced to output the third feature map. An AGFF module is introduced, using the third feature map output from the 1×1 convolution and the output of the Patch Merging layer as inputs to the AGFF module. After global feature information fusion, a fifth feature map of size 7×7 with 768 channels is obtained, which serves as the prediction branch head of YOLOX, denoted as f3.

[0042] Specifically, the Swing Transformer Block in the embodiment consists of LN, MLP, W-MSA structure, and SW-MSA structure, such as Figure 4 As shown, the input feature map first undergoes sample normalization through an LN layer, followed by a W-MSA structure. A multi-head attention module is used within the window to reduce computational complexity. The input feature map x0 of the Swin Transformer Block and the output feature map of the W-MSA structure are fused and added together through a residual structure to obtain the feature map output x1. Subsequently, an LN layer and an MLP structure are cascaded sequentially. The output feature map of the MLP and feature map x1 are fused and added together through a residual structure to obtain x2.

[0043] Compared to the ViT structure, which relies on internal feature map information exchange and communication, the W-MSA structure addresses this issue by first segmenting the feature map into multiple windows. Within each window, it performs MSA-based pixel matching to reduce computational cost. The MLP layer, for example... Figure 4 As shown in the MLPBlock structure, it contains a Linear layer, a GELU activation function, and a Dropout operation.

[0044] However, the W-MSA structure does not consider inter-window interaction, preventing information exchange between windows and affecting global view capture. Therefore, the SW-MSA structure is introduced. The x2 feature map is input to the LN layer, and the output of the LN layer is input to the SW-MSA structure. The SW-MSA structure performs pixel offset on the window (the offset value is...). This enables information exchange between multiple windows. The attention mechanism used in the Swing Transformer can then be expressed as:

[0045]

[0046] Where Q is the query vector, K is the key vector, V is the value vector, and d is the value vector. k Let k be the length and B be the bias. The x2 feature map is added to the output feature map of the SW-MSA structure to realize the residual features, and then passed through the LN layer and the MLP layer in sequence to output the final feature map.

[0047] like Figure 5 As shown, the attention fusion module (AGFF module) in this implementation first cascades information from multiple receptive fields and compresses global feature information using global pooling. It then fuses and adds the two input feature maps (y, z) to obtain the fused feature map U. To obtain the feature relationships between channels, it uses max pooling to represent the features. And average pooling (avg_pooling) represents the features as The two branches compress the spatial dimension of the feature map (U). The pixel positions of the two branches are added together by a SharedMLP with a bottleneck structure to obtain the feature fusion information M. c (U), this process can be expressed as formula (2), where σ represents the Sigmoid function, and W1 and W0 represent the weights:

[0048]

[0049] The feature map obtained after max pooling is denoted as m_out, and the feature map after average pooling is denoted as a_out. SharedMLP takes m_out and a_out as branch inputs, and each branch performs the same operation: including sequentially connected 1×1 convolutional blocks, ReLU, and another 1×1 convolutional block. Finally, the features from the two branches are summed, and the final feature map output M is obtained by passing the sigmoid function. c (U), denoted as F.

[0050] Subsequently, the Global_MLP structure is introduced to fuse the obtained feature map with the initial global branch that obtains different receptive fields, thereby achieving the fusion of global and local information.

[0051] Specifically, the Global_MLP structure has three branches. The first branch takes the input feature map F and performs global pooling to compress information in each channel dimension. This process can be represented as:

[0052]

[0053] Where H and W represent the feature map size (height and width).

[0054] To obtain global information for the current channel, the fc1, GELU, and fc2 structures are introduced sequentially. This structure is a fully connected layer with a bottleneck, which improves the model's generalization ability while reducing model complexity and parameter count. Then, to adaptively learn the importance of different channels, a sigmoid activation function is used to obtain the weight coefficients of different channels, enabling adaptive learning of important features. The output feature information M of the first branch is then processed. c (F), denoted as W c1 .

[0055] The second branch retains the feature map F of the current location information, and compares it with the channel information W obtained from the first branch. c1 Dot product enables information fusion and interaction, and the output feature map is denoted as W. c2 Meanwhile, the feature information obtained from the third branch is denoted as W. c3 The process of fusing and adding features, and finally outputting the feature map denoted as out, can be represented as follows:

[0056]

[0057] Among them, F scale This represents the dot product operation.

[0058] The third branch input feature map F also first undergoes a global pooling operation to obtain the current global information. Simultaneously, it passes through a bottleneck structure, which consists of a 1×1 convolution with BN fusion acceleration and ReLU. This structure includes a 1×1 convolution with BN layers, ReLU, and another 1×1 convolution with BN layers connected sequentially.

[0059] The feature map result after Global_MLP operation is denoted as G. To obtain global feature information, the initial feature information U and the current feature information G are fused and added together, and then the ReLU activation function is used to obtain the final feature output.

[0060] In this embodiment, the detection module employs the YOLOX detector, which utilizes an anchor-free mechanism for greater flexibility and adaptability. Furthermore, a branch-decoupled head is used, significantly improving convergence speed. The SimOTA method is introduced to automatically analyze the number of samples required for each ground truth (GT) and automatically adapt the GT-corresponding feature map to complete the detection task.

[0061] In this embodiment, the three prediction branches obtained after the backbone network output have feature maps f1, f2, and f3, respectively. Before entering the prediction layer, they pass through the Neck layer, which adopts a top-down approach using feature pyramid networks (FPN). The process is as follows: the feature map f3 passes through the CBL layer and upsampling operations to obtain a feature map that is aligned with the feature map of the f2 layer. The feature maps are then added together to output feature map F2. f2 passes through the CBL layer and upsampling operations and is then added to f1 to obtain feature map F1.

[0062] The Head layer adopts the improved coupling detection mechanism of YOLOX, which performs prediction through a branch structure. The decoupled Head layer has three prediction branch structures with consistent operations. Feature maps F2, F1, and f3 are input into the three branch structures of the decoupled Head layer, respectively.

[0063] Taking a prediction branch in the Head layer as an example, the input feature map F2, F1, or f3 is first processed through multiple sets of CBL operations to reduce the number of feature channels to 256. Then, a two-branch structure is adopted, each branch containing a CBL layer using 3×3 convolution operations, for classification and regression respectively. In the first classification branch, a sigmoid kernel is used to perform the classification task (Cls), determining the object type contained in each feature point. The second regression branch decouples two branches, Reg and Obj. Reg determines the regression parameters for each feature point to obtain the prediction bounding box, while Obj determines whether each feature point contains an object.

[0064] The predicted feature map is obtained by performing a concat operation and a sigmoid function on the three branches Cls, Reg, and Obj.

[0065] Finally, the results of the three prediction branches are concatenated to obtain the final output, `out`. The operations of the Neck and Head layers are as follows: Figure 3 As shown, the CBL structure consists of convolution, BN, and Leaky ReLU.

[0066] In the branch decoupling phase, the YOLO series typically combines the three Head layers (Cls, Reg, and Obj) together to perform classification and regression operations, which can be expressed as: [H, W, anchor × (C + 4 + 1)]. Here, cls is used to identify image categories, occupying C channels; Reg is used for coordinate labeling, occupying 4 channels; and the last one, obj, is used to distinguish between the target background and foreground, occupying 1 channel. Branch decoupling then separates the Head layers to achieve decoupling of [cls, reg, obj].

[0067] First, 1×1 convolution is used to reduce the dimensionality to 256 channels. Then, two parallel branches are used to perform recursion (the loss is represented by L). reg ) and cls (loss denoted as L) cls At the same time, add IoU (loss denoted as L) to the reg branch. IoU After branch decoupling, three branch structures can still be obtained, expressed as: [H,W,C], [H,W,4], [H,W,1]. L cls and L IoU Using the BCELoss (Binary CrossEntropy Loss) loss function, L reg The IoULoss loss is used. The decoupled branch prediction loss is given by, where N... pos The number of positive samples in the partition:

[0068]

[0069] The model training phase consisted of 100 iterations with a batch size of 8. A Swin Transformer combined with attention-based global feature fusion was employed, combining global features captured by the Transformer with local texture features from the CNN to achieve global + local visual feature extraction. The attention-based global feature fusion method further enhanced the model's feature representation capability by cascading receptive field information from different layers and fusing them. After iterative optimization, the optimal weights were selected to obtain the trained model, which was then used to predict test set samples, achieving sample type recognition and localization.

[0070] Figure 6 The image shows the prediction results of the algorithm proposed in this embodiment applied to the Huawei Cloud Cup municipal solid waste detection task.

[0071] Example 2

[0072] This embodiment proposes a target detection system based on Transformer and fusion attention mechanism, including:

[0073] Image acquisition module: Acquires the image to be detected and performs preprocessing;

[0074] Object detection module: Inputs the preprocessed image to be detected into the trained object detection model and outputs the detection results;

[0075] The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse global and local features in a cross-layer cascade manner. The detection module is used to output detection results based on the fused features.

[0076] In the image acquisition module, the dataset is divided into training and testing data sample sets. Data preprocessing employs image enhancement techniques such as shape transformation and color gamut transformation, including conventional geometric transformations (e.g., image flipping, scaling, rotation, shifting), color transformations (e.g., blurring, color gamut processing, noise reduction, filling), and mixed-class enhancement (e.g., the Mixup operation). Based on this, this experiment uses Mosaic and Mixup operations to enrich the dataset background and achieve image fusion processing, thereby expanding the dataset.

[0077] The object detection module includes the Transformer module, the attention fusion module, and the YOLOX detection module.

[0078] Transformer module: The preprocessed data is input into the model. The backbone network of this model adopts the Swing Transformer. First, the image is segmented and processed. It mainly includes four layers for feature extraction. By moving the window through a sliding window, semantic features are learned, which enhances the connection and interaction between upper and lower layers and improves the global modeling capability.

[0079] Attention Fusion Module: This module cascades receptive fields from different layers, fusing multi-layer perceptual information. It also incorporates a regular convolutional layer module, transforming dimensions while acquiring local feature information to further improve model accuracy. When using AGFF for feature fusion, a 1×1 convolutional module is introduced, which not only enables dimensionality transformation of the Transformer but also allows for feature fusion processing between the AGFF and Transformer structures.

[0080] The YOLOX detection module fuses the Swin Transformer and AGFF modules to obtain a three-layer branch structure. The Neck layer uses FPN to fuse high-order and low-order feature information from top to bottom. Simultaneously, three prediction branches are obtained, and model detection is achieved through YOLOX's decoupled branching method and the SimOTA method.

[0081] For the training and prediction of the object detection module: the model training phase iterated 100 times, with a batch size of 8. A Swin Transformer combined with attention-based global feature fusion was used, combining the global features captured by the Transformer with the local texture features of the CNN to achieve global + local visual feature extraction. Through attention-based global feature fusion, receptive field information from different layers was cascaded and fused to further improve the model's feature representation ability. After iterative optimization, the optimal weights were selected to obtain the trained model, which was then used to predict test set samples, achieving sample type recognition and localization.

[0082] Example 3

[0083] The purpose of this embodiment is to provide a computing device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the above-described method.

[0084] Example 4

[0085] The purpose of this embodiment is to provide a computer-readable storage medium.

[0086] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the above method.

[0087] The steps and methods involved in the apparatuses of Embodiments 2, 3, and 4 above correspond to those in Embodiment 1. For specific implementation details, please refer to the relevant description section of Embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood as including any medium capable of storing, encoding, or carrying an instruction set for execution by a processor and enabling the processor to perform any of the methods in this invention.

[0088] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computer device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. The present invention is not limited to any particular combination of hardware and software.

[0089] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.

Claims

1. A target detection method based on a Transformer and a fusion attention mechanism, characterized in that, include: Acquire the image to be detected and perform preprocessing; The preprocessed image to be detected is input into the trained target detection model, and the detection result is output. The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse the global and local features in a cross-layer cascade manner. The detection module is used to output the detection result based on the fused features. The Swing Transformer module includes layer 1, layer 2, layer 3, and layer 4 connected in sequence. A 1×1 convolutional layer performs dimensionality transformations on the output feature maps of layer 1, layer 2, and layer 4 to obtain the first feature map, the second feature map, and the third feature map, respectively. The output feature map of the linear embedding layer of layer 1, the first feature map, the output feature map of the patch merging layer of layer 4, and the third feature map of the output of layer 4 are respectively used as inputs to the attention fusion module to perform feature fusion and output the fourth and fifth feature maps. The attention fusion module includes a max pooling layer and an average pooling layer. The two inputs of the attention fusion module are fused and added together, and then fed into the max pooling layer and the average pooling layer respectively. The outputs of the two branches are fed into the SharedMLP layer, which adds the pixel position elements of the outputs of the two branches to obtain feature fusion information. The feature fusion information is then fed into the Global_MLP layer for fusion of different layers. The Global_MLP layer includes three branches. The first branch includes a sequentially connected global pooling layer, a fully connected layer, a GELU activation function, a fully connected layer, and a Sigmoid activation function. The second branch performs information fusion by multiplying the output of the first branch with the output of the SharedMLP layer, and then adds it to the output of the third branch. The third branch consists of a global pooling layer, a 1×1 convolutional and BN layer, a ReLU layer, and another 1×1 convolutional and BN layer connected in sequence.

2. The target detection method based on a Transformer and a fusion attention mechanism according to claim 1, characterized in that, Layer 1 consists of a linear embedding layer and two Swing Transformer Block layers connected in sequence; Layer 2 consists of a patch merging layer and two Swing Transformer Block layers connected in sequence; Layer 3 consists of a patch merging layer and six Swing Transformer Block layers connected in sequence; Layer 4 consists of a patch merging layer and two Swing Transformer Block layers connected in sequence. 3.The target detection method based on the Transformer and fusion attention mechanism of claim 1, wherein, The Swin Transformer Block layer includes a W-MSA structure and an SW-MSA structure. The W-MSA structure segments the feature map into multiple windows. The SW-MSA structure performs pixel offset on the segmented windows, enabling information exchange between the multiple windows.

4. The target detection method based on Transformer and fusion attention mechanism as described in claim 1, characterized in that, The fourth feature map, the feature map output from layer 2, and the fifth feature map serve as the three prediction branches of the prediction module, which employs a YOLOX detector. Alternatively, the head layer of the YOLOX detector may consist of three identical branches, one of which includes a CBL layer, parallel CBL layers, a Concat layer, and a sigmoid layer connected in sequence; one of the parallel CBL layers is followed by a convolutional layer and a sigmoid layer in sequence; and another parallel CBL layer is followed by parallel convolutional layers, one of which is followed by a sigmoid layer.

5. A target detection system based on Transformer and fusion attention mechanism, characterized in that, include: Image acquisition module: Acquires the image to be detected and performs preprocessing; Object detection module: Inputs the preprocessed image to be detected into the trained object detection model and outputs the detection results; The target detection model includes a Swing Transformer module, an attention fusion module, and a detection module. The Swing Transformer module is used to extract global features of the image to be detected. The attention fusion module is used to extract local features and fuse the global and local features in a cross-layer cascade manner. The detection module is used to output the detection result based on the fused features. The Swing Transformer module includes layer 1, layer 2, layer 3, and layer 4 connected in sequence. A 1×1 convolutional layer performs dimensionality transformations on the output feature maps of layer 1, layer 2, and layer 4 to obtain the first feature map, the second feature map, and the third feature map, respectively. The output feature map of the linear embedding layer of layer 1, the first feature map, the output feature map of the patch merging layer of layer 4, and the third feature map of the output of layer 4 are respectively used as inputs to the attention fusion module to perform feature fusion and output the fourth and fifth feature maps. The attention fusion module includes a max pooling layer and an average pooling layer. The two inputs of the attention fusion module are fused and added together, and then fed into the max pooling layer and the average pooling layer respectively. The outputs of the two branches are fed into the SharedMLP layer, which adds the pixel position elements of the outputs of the two branches to obtain feature fusion information. The feature fusion information is then fed into the Global_MLP layer for fusion of different layers. The Global_MLP layer includes three branches. The first branch includes a sequentially connected global pooling layer, a fully connected layer, a GELU activation function, a fully connected layer, and a Sigmoid activation function. The second branch performs information fusion by multiplying the output of the first branch with the output of the SharedMLP layer, and then adds it to the output of the third branch. The third branch consists of a global pooling layer, a 1×1 convolutional and BN layer, a ReLU layer, and another 1×1 convolutional and BN layer connected in sequence.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the object detection method based on Transformer and fusion attention mechanism as described in any one of claims 1-4.

7. A processing apparatus, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the target detection method based on Transformer and fusion attention mechanism as described in any one of claims 1-4.

Citation Information

Patent Citations

  • SAR target detection method and device based on context vision and storage medium

    CN114202696A