An underwater target detection method and system based on transformer and perception fusion attention
By introducing local-global Transformer and perceptual fusion attention network in underwater target detection, the problem that prior art is difficult to accurately identify targets in complex underwater contexts is solved, and more efficient and accurate underwater target detection is achieved.
Patent Information
- Application Number
- CN202410942211.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-07-15
AI Technical Summary
Existing underwater object detection technology is difficult to achieve accurate identification in complex underwater backgrounds, mainly due to the low contrast, uneven light, blur, light spot and high noise of underwater images, resulting in limited accuracy and efficiency of target detection.
Using the underwater object detection method based on Transformer and perceptual fusion attention, local to global information flow is established by introducing local-global Transformer (HLGCformer), generating accurate context representations, and using perceptual fusion attention network to get from multi-level features. Calculate attention weights, refine features and enhance the distinction between the target and the context.
Improves the confusion between background and target, improves detection rates, and enables more accurate and rapid target detection in complex underwater environments.
Smart Images

Figure CN118887520B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of underwater target detection, and in particular relates to an underwater target detection method and system based on transformer and perception fusion attention. Background Art
[0002] In recent years, underwater target detection technology has been widely used in many fields, including but not limited to underwater ecological monitoring, underwater pipeline maintenance, and shipwreck salvage. Underwater target detection is significantly different from detection in terrestrial environments. This brings new challenges to target detection: this is mainly attributed to the influence of water absorption and attenuation characteristics on light of different wavelengths, the distance between the target and the light source, and the spectral distribution. Due to the short propagation distance of blue wavelengths, images captured underwater often appear blue-green. Although artificial light sources can expand the visible range underwater, this also causes bright spots in the image and may aggravate the scattering of suspended matter in the water. Therefore, underwater images usually show low contrast, uneven illumination, blur, light spots, and high noise caused by multiple complex factors. In addition, due to the complexity of the underwater environment, it is relatively difficult to obtain high-quality underwater image data, and the corresponding data sets are relatively limited. Underwater biological targets are usually small in size, densely distributed, and may overlap and occlude. Considering the limited performance of existing target detection algorithms in underwater environments, how to achieve accurate and rapid target detection under such complex conditions has become an urgent research issue. Summary of the invention
[0003] In view of the shortcomings of the prior art, the present invention provides an underwater target detection method and system based on transformer and perceptual fusion attention, which introduces a local-global transformer (HLGCformer) to establish local-global information and generate accurate context representation, thereby more effectively distinguishing and identifying targets. At the same time, the perceptual fusion module is used to calculate the attention weight from multi-level features, the obtained attention weight is used to improve the features, and then the obtained features are integrated into fusion features to enhance the distinction between the target and the context.
[0004] To achieve the above object, the present invention provides the following solutions:
[0005] A method for underwater target detection based on transformer and perceptual fusion attention, comprising the following steps:
[0006] Obtain historical underwater target image datasets;
[0007] Based on the historical underwater image dataset, construct and train an underwater target detection model;
[0008] The trained underwater target detection model is used to perform target detection on the underwater target image to be detected, and a detection result including a target category label is obtained.
[0009] Preferably, the method for constructing an underwater target detection model is:
[0010] Building a backbone network based on a local-global transformer, inputting historical underwater target images of a preset size into the backbone network, and obtaining backbone feature maps of different scales;
[0011] Building a neck network based on the perception fusion attention network, inputting the backbone feature map into the neck network, and obtaining neck feature maps of different scales;
[0012] The detection head based on the yolov5 target detector performs target detection on the neck feature map to complete the construction of the underwater target detection model.
[0013] Preferably, the backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; wherein the underwater image data set is input into the backbone network, an initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer for feature extraction;
[0014] The standard features of the initial backbone feature map are extracted based on three 1×1 point-by-point convolutions, and the standard features are combined with the shallow features output by convolution compression and input into the spatial feature extraction block composed of 3×3 separable convolutions to obtain local features;
[0015] Based on three 3×3 point-by-point convolutions, extract important features of the initial backbone feature map;
[0016] Inputting the local features and the important features into an efficient additive attention module to obtain a local-to-global information flow of the initial backbone feature map;
[0017] The local-to-global information flow is input into a linear block to obtain a backbone nonlinear feature map.
[0018] Preferably, the neck network includes an upsampling layer, a splicing layer, a C3 layer, and a perceptual fusion attention network layer; wherein the method for extracting features in the perceptual fusion attention network layer is:
[0019] Based on the backbone network, a small-scale feature map and a large-scale feature map are obtained;
[0020] The perceptual fusion attention network layer upsamples the small-scale feature map, and adds the upsampled small-scale feature map to the large-scale feature map to obtain a feature map that preliminarily fuses multi-scale information;
[0021] Based on the channel prior convolutional attention module, the relationship between the feature maps of different channels that initially fuse multi-scale information is captured and retained to obtain a fine-grained attention map;
[0022] Performing weighted processing on the upsampled small-scale feature map, and fusing it with the fine-grained attention map to obtain a fused feature map;
[0023] The fused feature map is spliced with the large-scale feature map to obtain a comprehensive feature map of the neck.
[0024] The present invention also provides an underwater target detection system based on transformer and perceptual fusion attention, applying the method described above, including:
[0025] A data set acquisition module, used to acquire historical underwater target image data sets;
[0026] A model building module, used to build and train an underwater target detection model based on the historical underwater image dataset;
[0027] The target detection module is used to perform target detection on the underwater target image to be detected using the trained underwater target detection model to obtain a detection result containing a target category label.
[0028] Preferably, the model building module includes:
[0029] A backbone network construction submodule, used to construct a backbone network based on the local-global transformer, input historical underwater target images of preset sizes into the backbone network, and obtain backbone feature maps of different scales;
[0030] A neck network construction submodule, used to construct a neck network based on the perception fusion attention network, input the backbone feature map into the neck network, and obtain neck feature maps of different scales;
[0031] The detection head detection submodule is used to perform target detection on the neck feature map based on the detection head of the yolov5 target detector, so as to complete the construction of the underwater target detection model.
[0032] Preferably, the backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; wherein the underwater image data set is input into the backbone network, an initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer for feature extraction; the backbone network construction submodule includes a local-global transformer unit for extracting nonlinear features of the initial backbone feature map, including:
[0033] The local feature extraction subunit is used to extract the standard features of the initial backbone feature map based on three 1×1 point-by-point convolutions, and combine the standard features with the shallow features output by convolution compression and input them into the spatial feature extraction block composed of 3×3 separable convolutions to obtain local features;
[0034] An important feature extraction subunit, used for extracting important features of the initial backbone feature map based on three 3×3 point-by-point convolutions;
[0035] An information flow acquisition subunit, used for inputting the local features and the important features into an efficient additive attention module to obtain a local to global information flow of an initial backbone feature map;
[0036] The nonlinear feature extraction subunit is used to input the local-to-global information flow into a linear block to obtain a backbone nonlinear feature map.
[0037] Preferably, the neck network construction submodule includes a perception fusion attention network unit for comprehensive feature extraction, including:
[0038] The multi-scale information preliminary fusion subunit is used to obtain a small-scale feature map and a large-scale feature map based on the backbone network; the perception fusion attention network layer upsamples the small-scale feature map, and adds the small-scale feature map after the upsampling process to the large-scale feature map to obtain a feature map of preliminary fusion of multi-scale information;
[0039] The channel attention subunit is used to capture and retain the relationship between the feature maps of the preliminary fusion of multi-scale information in different channels based on the channel prior convolutional attention module to obtain a fine-grained attention map;
[0040] A feature fusion subunit, used for performing weighted processing on the upsampled small-scale feature map and fusing it with the fine-grained attention map to obtain a fused feature map;
[0041] The splicing subunit is used to splice the fused feature map with the large-scale feature map to obtain a comprehensive feature map of the neck.
[0042] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention provides an underwater target detection method and system based on transformer and perceptual fusion attention. At present, most of the existing underwater target detection methods are difficult to accurately identify targets in complex underwater backgrounds. The present invention introduces a local-global transformer (HLGCformer) to establish a connection between local and global information and generate an accurate context representation, thereby more effectively distinguishing and identifying targets. At the same time, the perceptual fusion attention network calculates attention weights from multi-level features, uses these weights to improve features, and then integrates these features into fusion features to enhance the distinction between targets and contexts. This method has the advantages of improving background and target confusion and improving detection rate. The proposed underwater target detection method can be widely used in the fields of marine resource exploration, underwater environment monitoring, underwater biodiversity research, etc., and provide support for scientific research and engineering practice in related fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0044] Figure 1 Schematic diagram of the composition of an underwater target detection system in an embodiment of the present invention;
[0045] Figure 2 Schematic diagram of the overall architecture of the underwater target detection model in an embodiment of the present invention;
[0046] Figure 3 Schematic diagram of the local-global transformer layer network architecture in an embodiment of the present invention;
[0047] Figure 4 A schematic diagram of the structure of a local feature extraction block, an important feature extraction block and a spatial feature extraction block in an embodiment of the present invention;
[0048] Figure 5 Schematic diagram of the perception fusion attention network architecture in an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] Embodiment 1
[0052] A method for underwater target detection based on transformer and perceptual fusion attention, comprising the following steps:
[0053] S1: Acquire a historical underwater target image dataset; in this embodiment, an underwater camera device takes an RGB image of an underwater target to construct an underwater image dataset I h =[I h1 , I h2 ,…I hK ], where data set I h The total number of elements in is K, and each element represents an underwater scene image. The image size is n ch ×h×w,n ch is the image channel, h is the image height, and w is the image width. The file format of the image is jpeg format. In this embodiment, underwater biological targets are detected, and the collected images include underwater biological targets and scenes.
[0054] S2: Based on the historical underwater image dataset, an underwater target detection model is constructed and trained; in this embodiment, the underwater image dataset is used as input, and an underwater target detection model is constructed based on the yolov5 target detector, the local-global transformer, and the perception fusion attention network; Figure 2 shown.
[0055] A further implementation method is that the method for constructing an underwater target detection model is:
[0056] S21: construct a backbone network based on the local-global transformer, input the historical underwater target image of the preset size into the backbone network, and obtain backbone feature maps of different scales; a further implementation method is that the backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; in this embodiment, a size of n is used ch The RGB image of size ×h×w is used as input to the backbone network of the network model, and passes through the convolution Conv, multi-scale sparse attention (MSDA) layer, local-global transformer (HLGCformer) layer and spatial pyramid SPPF layer, and outputs three feature maps of different scales I b1 , I b2 and I b3 , the scales are nc1 ×h / 8×w / 8,n c2 ×h / 16×w / 16 and n c3 ×h / 32×w / 32. The number of MSDA layers is set to 3,3, and the number of HLGCformer layers is set to 6,3. By stacking MSDA at the lower layer, local information is fully acquired, and stacking HLGCformer at the higher layer focuses on the global context information in the underwater environment.
[0057] The underwater image dataset is input into the backbone network, and the initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer (HLGCformer module) for feature extraction. In this embodiment, the HLGCformer module is as follows: Figure 3 As shown, given the input feature map M∈R C×H×W (Initial backbone feature map). In the initial stage of the module, local features are collected layer by layer through convolution operations, and local clues are retained as features. Figure 3-Figure 4 shown.
[0058] The first branch (local feature extraction block) extracts the standard features of the initial backbone feature map based on three 1×1 point-by-point convolutions, and combines the standard features with the shallow features output by convolution compression and inputs them into the spatial feature extraction block composed of 3×3 separable convolutions to obtain local features.
[0059] The second branch (important feature extraction block) extracts important features (important local features) of the initial backbone feature map based on three 3×3 point-by-point convolutions;
[0060] The local features and important features are input into the efficient additive attention module EAA to learn the contextual information of each scale of the input size and obtain the local to global information flow of the initial backbone feature map; specifically,
[0061] The local-to-global information flow is fed into the linear block to generate nonlinear features and obtain the backbone nonlinear feature map. The linear block consists of two 1×1 point-wise convolutional layers, batch normalization, and Silu activation function.
[0062] The feature extraction process of HLGCfomer can be expressed as:
[0063] O i =DwConv3(BN(3Conv1(BN(M))+M))+3Conv3(BN(M))
[0064] Z i =EAA(O i )
[0065] Ui =Linear(Z i )
[0066] Conv x () represents the three-point convolution function, and the kernel size of each convolution is x×x. BN(), DwConv x (), EAA(), and Linear() represent the depthwise separable convolution function with a kernel size of 3×3, the batch normalization function, the efficient additive attention function, and the linear function, respectively. i It is the output feature map of HLGCfomer (backbone nonlinear feature map). i represents the global information flow output by the efficient additive attention function, O i Represents the feature map obtained by combining local features with important features.
[0067] For the efficient additive attention part, the pairwise interactions between tokens are exploited through element-wise multiplication to capture the global context. It encodes the relevance score of the contextual information of the input sequence based on the interaction of the three attention components (Q, K, V). It has faster inference speed and more robust context representation. Specifically, two matrices w are used. q 、w k The input embedding matrix x is transformed into query (Q) and keyword (K). Then, the query matrix Q is multiplied by the learnable parameter vector w a ∈R d The attention weight of the learned query is used to generate a global attention query vector a.
[0068] The query matrices are then pooled together based on the learned attention, producing a single global query vector q∈R d Next, we use the element-wise product to multiply the global query vector q∈R d and keyword matrix K∈R d ×d to encode the interactions between them to form the global context (R n ×d). A linear transformation layer is used for query and key-value interaction to learn the hidden representation of the token. The effective additional attention U out The output can be expressed as:
[0069]
[0070] U out =Q+T(K*q)
[0071] In the above formula, d is the dimension of the embedding vector, a i Denotes the value assigned to the i-th query vector Q i The attention weight, Q represents the normalized query matrix, T() represents the linear transformation function, Uout The output variable representing the effective additional attention.
[0072] S22: Construct a neck network based on the perceptual fusion attention network, input the backbone feature map into the neck network, and obtain neck feature maps of different scales; in the neck of the network model, the three feature maps I obtained in the backbone network are input into the neck network. b1 , I b2 and I b3 After a series of processing such as upsampling, concatenation, C3 layer, and perceptual fusion module, the neck outputs three feature maps of different scales O I1 , O I2 and O I3 The scales are n c1 ×h / 8×w / 8,n c2 ×h / 16×w / 16 and n c3 ×h / 32×w / 32. Perceptual fusion is designed to fuse feature maps of different scales in pairs. Information interaction and fusion across feature maps are achieved, thereby improving target detection performance.
[0073] like Figure 5 As shown, a further implementation method is that the neck network includes an upsampling layer, a splicing layer, a C3 layer and a perception fusion attention network layer; wherein the method for feature extraction of the perception fusion attention network layer is:
[0074] Based on the backbone network, small-scale feature maps and large-scale feature maps are obtained;
[0075] The perceptual fusion attention network layer (perceptual fusion module) upsamples the small-scale feature map and adds the upsampled small-scale feature map to the large-scale feature map to obtain a feature map that initially fuses multi-scale information. In this embodiment, given the input large-scale feature map F1∈R C×h×W , F1∈R 2C×H / 2×W / 2 ,The perceptual fusion attention network layer upsamples the small-scale feature map F2 and adds it to the large-scale feature map to preliminarily fuse multi-scale information.
[0076] Based on the channel prior convolutional attention module, the relationship between feature maps of different channels that initially fuse multi-scale information is captured and retained, important semantic features are highlighted, and fine-grained attention maps are obtained;
[0077] The upsampled small-scale feature map is weighted and fused with the fine-grained attention map to enhance the target features, suppress background interference, and obtain a fused feature map.
[0078] The fused feature map is spliced with the large-scale feature map to obtain a comprehensive feature map of the neck, forming a more comprehensive feature representation. The operation process of the perception fusion module can be expressed as:
[0079] Y=Concat(Sigmoid(CPCA(F1+F2))×F1,F2)
[0080] In the above formula, CPCA(), Sigmoid(), and Concat() represent the channel prior convolution attention function, Sigmoid function, and concatenation function respectively. Y represents the output feature map of the perceptual fusion module.
[0081] Here, by combining the channel prior convolutional attention CPCA module, the model enhances key features and improves the ability to perceive and detect targets. Channel prior convolutional attention is based on the order of channel attention and spatial attention, and can dynamically allocate attention weights in the channel and spatial dimensions to pay attention to information channels and important areas. Channel prior convolutional attention can be expressed as
[0082] I C =CA(I)×I
[0083] I out =SA(I)×I C
[0084] The above formula CA() represents the channel attention function, SA() represents the spatial attention function, I, I out are the input and output of the channel prior convolution attention, respectively. C Represents the intermediate feature map of the weighted fusion output with the channel attention function.
[0085] S23: The detection head based on the yolov5 target detector performs target detection on the neck feature map to complete the construction of the underwater target detection model.
[0086] S3: Use the trained underwater target detection model to perform target detection on the underwater target image to be detected, and obtain a detection result including a target category label.
[0087] The training is performed in a way that the learning rate gradually decreases, and the final learning rate will be reduced to 1r, and the loss function is L. The following initializations are performed in each layer of the model: the weights of the convolutional layer are initialized using the Kaiming method, and the bias is also initialized. The linear layer uses a truncated normal distribution with a standard deviation of 0.02 to initialize the weights, and the bias is initialized to 0. In this embodiment, the linear layer uses a truncated normal distribution with a standard deviation of 0.02 to initialize the weights, and the bias is initialized to 0. The training parameters are set as follows: the learning rate lr is 0.01, the batchsize is 16, the training set validation set test set is divided into 8:1:1, the optimizer is SGD, and the total training cycle is 200.
[0088] The trained network is used for prediction, and the aquatic life images taken by underwater cameras are input to output the underwater life image detection results. First, the image containing multiple underwater life targets and scenes to be tested is input into the network. The image size is n×h×w. After network processing, the output prediction frames of the three detection heads are obtained. The output feature map scales are h / 4×w / 4, h / 8×w / 8, and h / 16×w / 16 respectively.
[0089] Each detection head further processes the feature map through a series of convolutional layers and outputs the object detection results. At the output stage of the detection head, multiple bounding box predictions are generated for each pixel of each feature map. Each bounding box contains the center point location (x, y), width and height (w, h), as well as the target category confidence and target existence confidence. Through the predefined box mechanism, these boxes have different sizes and aspect ratios to cover the various shapes and sizes of objects that may appear. In addition, the network also predicts two confidence scores: one is the target category confidence and the other is the target existence confidence. These prediction results can be represented as tensors. For example, for an 80×80 feature map with 3 anchor boxes, the output tensor has a size of (80, 80, 3, (4+1+number of categories)). This means that for each position on each feature map, the network predicts not only one bounding box, but multiple bounding boxes corresponding to each box. All bounding box prediction results are processed by non-maximum suppression (NMS). Starting from the prediction box with the highest confidence, the intersection over union (IoU) between the box and other prediction boxes is calculated. If the IoU is greater than the preset threshold, the prediction box is deleted (that is, it is considered a redundant box), and the prediction box with the highest confidence is retained. The above steps are repeated until all prediction boxes are processed.
[0090] Finally, the network will output a set of feature maps, which contain the center coordinates, width and height, confidence and category probability of the predicted box. The input image is divided into grids, and each grid cell predicts multiple bounding boxes. The predicted value of the center coordinate (x, y) is the offset relative to the upper left corner of the current grid cell, which is limited to between 0 and 1 using the sigmoid function. The width and height (w, h) are obtained by exponential transformation and multiplication by the size of the predefined anchor box (anchorboxes), and finally the actual center coordinates, width and height (x, y, w, h) are obtained. The confidence is normalized by the sigmoid function, indicating the probability of the predicted box containing an object. When the confidence of the predicted box is higher than the set threshold of 0.25, the model believes that the organism is detected, and then the category probability is calculated by the softmax function, and the category with the highest probability is selected as the category label of the box. Finally, the overlapping boxes are removed by non-maximum suppression to generate a predicted box containing the actual position, confidence and category label. On the contrary, if the confidence of the predicted box is below a threshold or is removed during non-maximum suppression, it is considered that no organism is detected.
[0091] Embodiment 2
[0092] like Figure 1 As shown, the present invention also provides an underwater target detection system based on transformer and perceptual fusion attention, and the application method includes:
[0093] A data set acquisition module, used to acquire historical underwater target image data sets;
[0094] A model building module, used to build and train an underwater target detection model based on the historical underwater image dataset;
[0095] The target detection module is used to perform target detection on the underwater target image to be detected using the trained underwater target detection model to obtain a detection result containing a target category label.
[0096] In this embodiment, the model building module and the target detection module are completed by a computer device, and the computer device is connected to the underwater imaging device via a wireless transceiver.
[0097] In a further embodiment, the model building module comprises:
[0098] The backbone network construction submodule is used to construct a backbone network based on the local-global transformer, input historical underwater target images of preset sizes into the backbone network, and obtain backbone feature maps of different scales;
[0099] The neck network construction submodule is used to construct a neck network based on the perception fusion attention network, input the backbone feature map into the neck network, and obtain neck feature maps of different scales;
[0100] The detection head detection submodule is used to perform target detection on the neck feature map based on the detection head of the yolov5 target detector, and complete the construction of the underwater target detection model.
[0101] A further implementation method is that the backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; wherein the underwater image data set is input into the backbone network, an initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer for feature extraction; the backbone network construction submodule includes a local-global transformer unit for extracting nonlinear features of the initial backbone feature map, including:
[0102] The local feature extraction subunit is used to extract the standard features of the initial backbone feature map based on three 1×1 point-by-point convolutions, and combine the standard features with the shallow features output by convolution compression and input them into a 3×3 separable convolution to obtain local features;
[0103] The important feature extraction subunit is used to extract the important features of the initial backbone feature map based on three 3×3 point-by-point convolutions;
[0104] The information flow acquisition subunit is used to input local features and important features into the efficient additive attention module to obtain the local to global information flow of the initial backbone feature map;
[0105] The nonlinear feature extraction subunit is used to input the local-to-global information flow into the linear block to obtain the backbone nonlinear feature map.
[0106] In a further embodiment, the neck network construction submodule includes a perception fusion attention network unit for comprehensive feature extraction, including:
[0107] The multi-scale information preliminary fusion subunit is used to obtain a small-scale feature map and a large-scale feature map based on the backbone network; the perception fusion attention network layer upsamples the small-scale feature map, and adds the upsampled small-scale feature map to the large-scale feature map to obtain a feature map that preliminarily fuses multi-scale information;
[0108] The channel attention subunit is used to capture and retain the relationship between feature maps of different channels that initially fuse multi-scale information based on the channel prior convolutional attention module to obtain a fine-grained attention map;
[0109] The feature fusion subunit is used to perform weighted processing on the upsampled small-scale feature map and fuse it with the fine-grained attention map to obtain a fused feature map;
[0110] The splicing subunit is used to splice the fused feature map with the large-scale feature map to obtain a comprehensive feature map of the neck.
[0111] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. An underwater target detection method based on transformer and perceptual fusion attention, characterized in that: The following steps are involved: Obtain historical underwater target image datasets; Based on the historical underwater target image dataset, an underwater target detection model is constructed and trained; the method for constructing the underwater target detection model is: Building a backbone network based on a local-global transformer, inputting historical underwater target images of a preset size into the backbone network, and obtaining backbone feature maps of different scales; Building a neck network based on the perception fusion attention network, inputting the backbone feature map into the neck network, and obtaining neck feature maps of different scales; The detection head based on the yolov5 target detector performs target detection on the neck feature map to complete the construction of the underwater target detection model; The backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; wherein the underwater image data set is input into the backbone network, an initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer for feature extraction; The standard features of the initial backbone feature map are extracted based on three 1×1 point-by-point convolutions, and the standard features are combined with the shallow features output by convolution compression and input into the spatial feature extraction block composed of 3×3 separable convolutions to obtain local features; Based on three 3×3 point-by-point convolutions, extract important features of the initial backbone feature map; Inputting the local features and the important features into an additive attention module to obtain a local-to-global information flow of the initial backbone feature map; Inputting the local-to-global information flow into a linear block to obtain a backbone nonlinear feature map; The trained underwater target detection model is used to perform target detection on the underwater target image to be detected, and a detection result including a target category label is obtained.
2. The underwater target detection method based on transformer and perceptual fusion attention according to claim 1 is characterized in that: The neck network includes an upsampling layer, a concatenation layer, a C3 layer, and a perception fusion attention network layer; wherein the method for feature extraction in the perception fusion attention network layer is: Based on the backbone network, a small-scale feature map and a large-scale feature map are obtained; The perceptual fusion attention network layer upsamples the small-scale feature map, and adds the upsampled small-scale feature map to the large-scale feature map to obtain a feature map that preliminarily fuses multi-scale information; Based on the channel prior convolutional attention module, the relationship between the feature maps of different channels that initially fuse multi-scale information is captured and retained to obtain a fine-grained attention map; Performing weighted processing on the upsampled small-scale feature map, and fusing it with the fine-grained attention map to obtain a fused feature map; The fused feature map is spliced with the large-scale feature map to obtain a comprehensive feature map of the neck.
3. An underwater target detection system based on transformer and perceptual fusion attention, applying the method described in any one of claims 1-2, characterized in that: include: A data set acquisition module, used to acquire historical underwater target image data sets; A model building module, used to build and train an underwater target detection model based on the historical underwater target image dataset; The model building module includes: A backbone network construction submodule is used to construct a backbone network based on a local-global transformer, input historical underwater target images of a preset size into the backbone network, and obtain backbone feature maps of different scales; A neck network construction submodule, used to construct a neck network based on the perception fusion attention network, input the backbone feature map into the neck network, and obtain neck feature maps of different scales; A detection head detection submodule is used to perform target detection on the neck feature map based on the detection head of the yolov5 target detector to complete the construction of the underwater target detection model; The backbone network includes a convolution Conv layer, a multi-scale sparse attention MSDA layer, a local-global transformer layer and a spatial pyramid SPPF layer; wherein the underwater image data set is input into the backbone network, an initial backbone feature map is obtained through the convolution Conv layer and the multi-scale sparse attention MSDA layer, and the initial backbone feature map is input into the local-global transformer layer for feature extraction; the backbone network construction submodule includes a local-global transformer unit, which is used to extract nonlinear features of the initial backbone feature map, including: The local feature extraction subunit is used to extract the standard features of the initial backbone feature map based on three 1×1 point-by-point convolutions, and combine the standard features with the shallow features output by convolution compression and input them into the spatial feature extraction block composed of 3×3 separable convolutions to obtain local features; An important feature extraction subunit, used for extracting important features of the initial backbone feature map based on three 3×3 point-by-point convolutions; An information flow acquisition subunit, used for inputting the local features and the important features into an additive attention module to obtain a local to global information flow of an initial backbone feature map; A nonlinear feature extraction subunit, used for inputting the local-to-global information flow into a linear block to obtain a backbone nonlinear feature map; The target detection module is used to perform target detection on the underwater target image to be detected using the trained underwater target detection model to obtain a detection result containing a target category label.
4. The underwater target detection system based on transformer and perceptual fusion attention according to claim 3 is characterized in that: The neck network construction submodule includes a perception fusion attention network unit for comprehensive feature extraction, including: The multi-scale information preliminary fusion subunit is used to obtain a small-scale feature map and a large-scale feature map based on the backbone network; the perception fusion attention network layer upsamples the small-scale feature map, and adds the small-scale feature map after the upsampling process to the large-scale feature map to obtain a feature map of preliminary fusion of multi-scale information; The channel attention subunit is used to capture and retain the relationship between the feature maps of the preliminary fusion of multi-scale information in different channels based on the channel prior convolutional attention module to obtain a fine-grained attention map; A feature fusion subunit, used for performing weighted processing on the upsampled small-scale feature map and fusing it with the fine-grained attention map to obtain a fused feature map; The splicing subunit is used to splice the fused feature map with the large-scale feature map to obtain a comprehensive feature map of the neck.
Citation Information
Patent Citations
Underwater target detection method based on visual Transform
CN117746224A
Small target detection method based on spatial context feature pyramid
CN118212403A