Method and system for detecting elongated objects based on enhanced attention mechanism
By employing an enhanced attention mechanism for slender target detection, this method utilizes position encoding and axial attention to address the issues of long-range dependency capture and positional information loss in slender target detection, achieving high accuracy and stable detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF SOFTWARE - CHINESE ACAD OF SCI
- Filing Date
- 2026-04-20
- Publication Date
- 2026-07-14
AI Technical Summary
Existing general target detection models struggle to effectively capture long-range spatial dependencies when dealing with slender targets, resulting in low detection accuracy, inaccurate localization, and loss of deep feature location information, making it impossible to effectively model the geometric shape of slender targets.
A method based on enhanced attention mechanism is adopted to construct a slender target detection model through the synergistic effect of position encoding and directional attention mechanism. The model includes a backbone network, a neck network and a detection head. Multi-scale feature extraction, feature fusion and target prediction are performed. Two-dimensional position encoding technology and axial attention mechanism are used to capture the long-range dependencies and directional features of slender targets.
It significantly improves the detection accuracy and localization accuracy of slender targets, enhances the robustness and generalization ability of the model, and especially the detection stability in complex backgrounds.
Smart Images

Figure CN122391610A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and deep learning technology, and in particular relates to an image target detection method and system based on an enhanced attention mechanism. Background Technology
[0002] Currently, deep learning-based object detection technology has matured, with mainstream detection frameworks mainly divided into two-stage and one-stage detectors. Two-stage detectors (such as R-CNN and Faster R-CNN) first generate candidate regions, then classify and regress bounding boxes from these regions. One-stage detectors (such as SSD and YOLO) directly predict the target location and category on the feature maps, eliminating the need for candidate box generation and refinement, thus representing an end-to-end detection method. Regardless of the framework, its core components include the following: a feature extraction network (Backbone), a feature fusion network (Neck), and a detection head. The feature extraction network, such as ResNet and VGG convolutional neural networks, uses these networks to perform multi-layer convolution and downsampling operations on the input image to generate feature maps of different scales. These feature maps contain rich detailed and semantic information from shallow to deep layers. The feature fusion network, such as the Feature Pyramid Network (FPN), is used to fuse features at different scales, combining the semantic information of deep feature maps with the detailed information of shallow feature maps. This approach balances detailed and semantic information to improve the detection capability for targets of varying sizes. The detection head performs bounding box regression and target classification on the fused feature map, outputting the class probability and position offset of each bounding box. Redundant predicted boxes are removed through post-processing techniques such as Non-Maximum Suppression (NMS) to obtain the final detection result. This general object detection framework achieves good results in detecting targets of conventional shapes (such as approximately square targets) using operations like convolution and pooling.
[0003] Slender targets refer to specific types of targets that exhibit an extreme aspect ratio in images, such as roads, rivers, power lines, ships, surfboards, and skis. These targets typically appear in images with a scale in one main direction that is much larger than the scale in another vertical direction. These objects are very common in practical applications, but are easily overlooked in traditional object detection algorithms. These methods usually use standard convolutional kernels and pooling operations to capture local features and integrate multi-scale features through methods such as feature pyramids. In existing technologies, the closest approach to this invention is to use a general object detection model for slender target detection. However, this approach is a direct application of known technologies and does not involve specific optimization design for the unique geometric characteristics of slender targets.
[0004] While general object detection frameworks have demonstrated excellent performance on public datasets such as COCO, they exhibit significant inherent limitations when handling elongated objects: First, elongated objects typically have extreme aspect ratios, but standard convolutional kernels and pooling windows are usually square (e.g., 3x3), with isotropic receptive fields. They excel at capturing features in local, approximately square regions, but struggle to effectively capture long-range spatial structural relationships. Models are prone to misidentifying elongated objects as multiple discontinuous short objects or only detecting fragments of the object. Second, the recognition of elongated objects relies on contextual understanding of their overall contour and long axis direction. Existing solutions, while increasing the receptive field through stacked convolutional layers or feature pyramids, are less effective and struggle to accurately model long-distance dependencies between pixels. This easily leads to missed detections. Some methods introduce global attention mechanisms, but their high computational complexity makes them difficult to apply to high-resolution feature maps. Third, in deep convolutional networks, continuous downsampling operations reduce the resolution of feature maps, blurring the positional and directional information of elongated objects. Traditional positional encoding methods may not be efficient enough in target detection tasks. They are computationally complex and fail to be effectively aligned with the main axis of slender targets, thus failing to provide the model with the most favorable directional positional prior for slender target localization. Summary of the Invention
[0005] The purpose of this invention is to address the technical problems of general target detection models, such as insufficient ability to model the geometric shape of slender targets, difficulty in capturing long-range spatial dependencies, and inaccurate localization due to the loss of deep feature position information. This invention proposes a slender target detection method and system based on an enhanced attention mechanism. Through the synergistic effect of position encoding and directional attention mechanism, this method can accurately extract the principal axis features and long-range context information of slender targets without significantly increasing the computational burden, thereby significantly improving the detection accuracy, localization accuracy, and model robustness of slender targets.
[0006] To achieve the above objectives, the present invention adopts the following technical solution.
[0007] A method for detecting slender targets based on an enhanced attention mechanism includes the following steps: Multi-scale feature maps are obtained by performing multi-scale feature extraction and attention enhancement on the image to be processed through the backbone network. The multi-scale feature maps are fused using a neck network to obtain multi-path enhanced feature maps; The detection head is used to predict the target category and bounding box position of the multi-path enhanced feature map; A slender target detection model is constructed based on the backbone network, neck network, and detection head, and the slender target detection model is trained to detect slender targets in images.
[0008] Furthermore, multi-scale feature extraction and attention enhancement are performed on the image to be processed through the backbone network to obtain multi-scale feature maps, including: The image to be processed is subjected to backbone initial convolution to obtain an initial feature map; The initial feature map is downsampled step by step through a multi-level cascaded residual feature extraction unit, and high-resolution feature maps and medium-resolution feature maps are extracted from different downsampling levels of the backbone network respectively. Spatial pyramid pooling is applied to the features extracted from the downsampling layers at the end of the backbone network to aggregate multi-receptive field features and output a low-resolution semantic feature map. An enhanced low-resolution semantic feature map is obtained by applying attention enhancement to the low-resolution semantic feature map using an enhanced attention module.
[0009] Furthermore, by enhancing the attention of the low-resolution semantic feature map using an enhanced attention module, an enhanced low-resolution semantic feature map is obtained, including: By projecting features onto the low-resolution semantic feature map, the query, key, and value are obtained. The query and key are independently encoded in one-dimensional positions in the horizontal and vertical directions to obtain query components and key components with spatial position information. The query component and key component are used to aggregate the values along the axial features, and the horizontal and vertical axial features are output. The horizontal axis features are fused with the vertical axis features and then residually connected to the low-resolution initial semantic feature map to output an enhanced low-resolution semantic feature map.
[0010] Furthermore, the query features and key features are encoded using independent one-dimensional positional encoding in the horizontal and vertical directions, including: The two-dimensional spatial location information of the feature map is masked in a directional manner, that is, the vertical location component is masked when calculating the horizontal feature, and the horizontal location component is masked when calculating the vertical feature. The unidirectional location information after directional masking is encoded and injected into the feature to generate query components and key components with spatial location information.
[0011] Furthermore, axial feature aggregation is performed on the values using the aforementioned query components and key components, including: By calculating the correlation matrix between the query component and the corresponding directional key component, axial attention weights in the horizontal and vertical directions are generated. By using axial attention weights to perform weighted projection on the values, we obtain the aggregated results of the values in the axial features.
[0012] Furthermore, the horizontal axis features are fused with the vertical axis features and residually connected to the low-resolution semantic feature map to output an enhanced low-resolution semantic feature map, including: The horizontal axis features and vertical axis features are summed and mapped, and learnable parameters are introduced to adjust the weights of the mapped features. The adjusted features are added to the low-resolution semantic feature map, and at least one loop of enhancement processing is performed to obtain the enhanced low-resolution semantic feature map.
[0013] Furthermore, feature fusion is performed on the multi-scale feature maps through the neck network to obtain multi-path enhanced feature maps, including: The enhanced low-resolution semantic feature map is upsampled at multiple levels and then concatenated across scales with medium-resolution and high-resolution feature maps and residual feature extraction is performed to output the first enhanced feature map and intermediate layer features. The first enhanced feature map is downsampled and horizontally concatenated with the intermediate layer features, and residual features are extracted to output the second enhanced feature map. The second enhanced feature map is then downsampled and combined with the enhanced low-resolution semantic feature map for path aggregation and residual feature extraction to output the third enhanced feature map.
[0014] Furthermore, the target category and bounding box location are predicted on the multi-path enhanced feature map using a detection head, including: The multi-path enhanced feature maps are input to the corresponding decoupled detection heads, and feature mapping is performed through parallel classification branches at each level. The predicted class probability of the slender target is output using the activation function. By using a regression branch that runs parallel to the classification branch, a distributed focus learning mechanism is employed to perform boundary anchoring and offset prediction on the multi-path enhanced feature map, outputting the predicted bounding box coordinates of the slender target.
[0015] Further, the slender target detection model is trained, including: Calculate the classification loss between the predicted target category and the true target label; Calculate the geometric localization loss between the predicted bounding box and the ground truth bounding box label; Calculate the confidence loss between the predicted target existence probability and the true label. The total loss is obtained by weighting the classification loss, geometric localization loss, and confidence loss. Backpropagation is performed based on the total loss, and the parameters of the slender target detection model are updated through iterative optimization.
[0016] A system for detecting slender targets based on an enhanced attention mechanism, comprising: The backbone network module is used to perform multi-scale feature extraction and attention enhancement on the image to be processed, resulting in multi-scale feature maps. The neck network module is used to perform feature fusion on the multi-scale feature maps to obtain multi-path enhanced feature maps; The detection head module is used to predict the target category and bounding box position of the multi-path enhanced feature map; The training module is used to train the elongated target detection model constructed from the backbone network, neck network, and detection head for detecting elongated targets in images.
[0017] The present invention has achieved the following beneficial effects.
[0018] 1. This invention introduces a decoupled two-dimensional position encoding technique to decompose spatial position information into one-dimensional encodings injected into feature maps in the horizontal and vertical directions. This provides the model with clear spatial position priors and effectively compensates for the loss of position information in deep features without increasing the amount of computation, thus greatly enhancing the model's positioning accuracy for the endpoints of slender targets.
[0019] 2. This invention employs an attention mechanism that calculates weights for row and column pixels. By aggregating contextual information along a specific axis, it efficiently captures the long-range dependencies of slender targets along the main axis with extremely low computational cost, solving the problem that traditional convolutional structures cannot effectively integrate the features of discrete segments of slender targets.
[0020] 3. This invention constructs a directional context modeling framework guided by position priors. By utilizing a complementary enhancement system of position encoding and axial attention mechanism, it achieves deep fusion of structured position information and directional feature aggregation, enabling the model to extract more discriminative directional features and significantly enhancing the modeling ability for the unique geometric shape of slender targets.
[0021] 4. This invention focuses on the main axis of the target through structure-aware spatial attention and combines dynamic multi-scale feature fusion to optimize the representation, effectively solving the inherent problems of slender targets being prone to breakage and missed detection in complex backgrounds, and greatly improving the model's generalization ability and detection stability in practical application scenarios such as remote sensing and industrial inspection. Attached Figure Description
[0022] Figure 1 This is an overall flowchart of a method for detecting slender targets based on an enhanced attention mechanism, as shown in the embodiment. Figure 2 This is a structural diagram of the slender target detection network model in the embodiment; Figure 3 This is a structural diagram of the enhanced attention module in the embodiment; Figure 4 This is a schematic diagram of the axial rotation position encoding in the embodiment; Figure 5 This is a schematic diagram illustrating the attention weight calculation in the embodiment; Figure 6 This is an example diagram of the categories and their labels in the data set in the embodiment; Figures 7A to 7C The graph shows the changes in recall, precision, and F1 score with confidence during model training in the example. Figure 8 This is a diagram illustrating the detection effect on slender targets in the embodiment. Figure 9 This is a block diagram of a slender target detection system based on an enhanced attention mechanism, as shown in the embodiment. Detailed Implementation
[0023] To make the various technical features, advantages, or effects of the present invention more apparent and understandable, detailed descriptions are provided below through embodiments.
[0024] This invention provides a method for detecting slender targets based on an enhanced attention mechanism, the overall process of which is as follows: Figure 1 As shown. This embodiment selects to improve the attention enhancement based on the baseline model YOLO11, constructing as follows. Figure 2 The slender target detection network shown comprises three parts: a backbone, a neck, and a head. This network enables the detection of slender targets. The method specifically includes the following steps.
[0025] Step S1: Multi-scale feature extraction and attention enhancement are performed on the image to be processed through the backbone network to obtain a multi-scale feature map.
[0026] Specifically, the backbone, as the core component of the model, is used to extract multi-level feature representations of the input image. It consists of a series of convolutional layers, normalization layers, and activation function layers stacked together, accompanied by downsampling operations. As the number of network layers increases, the spatial size of the feature maps gradually decreases, while the number of channels continuously increases, and the semantic information is continuously enhanced, thus outputting multi-scale feature maps. Among them, the shallow feature maps have a larger spatial size and contain rich details and location information; the deep feature maps have a smaller spatial size and contain more semantic information.
[0027] Specifically, the Backbone structure is as follows: Figure 2 As shown on the left, the module consists of, in sequence, the starting unit Stem, four consecutive residual convolutional modules (Conv+C3k2), the spatial pyramid pooling module (SPPF), and the enhanced attention module (AR-CCA).
[0028] In an optional embodiment of the present invention, step S1 may include: Step S11: Perform backbone initial convolution on the image to be processed to obtain the initial feature map.
[0029] Specifically, after the image to be detected is input into the network model, it first passes through the Stem unit for initial feature representation, which forms the basis for feature extraction.
[0030] Step S12: The initial feature map is downsampled step by step through a multi-level cascaded residual feature extraction unit, and high-resolution feature maps and medium-resolution feature maps are extracted from different downsampling levels of the Backbone respectively.
[0031] Specifically, a continuously cascaded Conv and C3k2 structure is used as a residual feature extraction unit to increase channel depth while reducing feature map resolution. In this embodiment, the feature map output by the second C3k2 module in the Backbone is extracted as the first-scale feature, and the feature map output by the third C3k2 module is extracted as the second-scale feature, and then input into the subsequent feature fusion network.
[0032] Step S13: Perform spatial pyramid pooling on the features extracted from the downsampling layer at the end of the backbone network, aggregate the features from multiple receptive fields, and output a low-resolution semantic feature map.
[0033] Specifically, the output of the fourth C3k2 module is input to the SPPF module. Through spatial pyramid pooling, the model can effectively aggregate feature information from different receptive fields, enhancing its adaptability to targets of different sizes. The output of the SPPF module is further used as input to the enhanced attention module for subsequent directional attention enhancement processing.
[0034] Step S14: The low-resolution semantic feature map is enhanced by an enhanced attention module to obtain an enhanced low-resolution semantic feature map.
[0035] Specifically, to overcome the limitations of baseline models in detecting slender targets, this invention integrates an Enhanced Attention Module (AR-CCA Block) in the last layer of the Backbone, as shown in the following structure. Figure 3 As shown, spatial location priors are injected into features through positional encoding, and long-range dependencies are captured through an attention mechanism. This module makes the calculation of attention weights dependent on the relative positional relationships of pixels and their rows and columns, thus providing accurate spatial structure priors.
[0036] In an optional embodiment of the present invention, step S14 may include: Step S141: Perform feature projection on the low-resolution semantic feature map to obtain the query, key, and value.
[0037] Specifically, input a low-resolution semantic feature map Where C is the number of input channels, H is the feature map height, and W is the feature map width, the projection is performed through three different convolutional layers. The first convolutional layer outputs the query... The output key of the second convolutional layer The output value of the third convolutional layer The number of channels for querying Q and key K here is reduced to [number missing]. ,and , The number of channels is the number after projection, and the number of channels remains unchanged for the value V.
[0038] Step S142: Perform independent one-dimensional position encoding on the query and key in the horizontal and vertical directions to obtain query components and key components with spatial position information.
[0039] Specifically, position encoding can employ rotational axis position encoding, sine / cosine encoding, or learnable parameter encoding. This embodiment takes rotational axis position encoding as an example. Before calculating the attention weights, the two-dimensional spatial position information is decomposed into two orthogonal directions, horizontal and vertical, for encoding and embedding respectively.
[0040] In an optional embodiment of the present invention, step S142 may include: Step S1421: Orient the two-dimensional spatial position information of the feature map by masking it, that is, masking the position component of the vertical direction when calculating the horizontal direction feature, and masking the position component of the horizontal direction when calculating the vertical direction feature.
[0041] Step S1422: The unidirectional location information after directional masking is injected into the feature through encoding to generate query component and key component with spatial location information.
[0042] Specifically, in the horizontal direction, the query component carries spatial location information. and bond components The calculation method is as follows: in, and These represent the horizontal rotation positions of query Q and key K, respectively (see...). Figure 3 and Figure 4 The component after H_RoPE, These are the horizontal position coordinates. These are the position coordinates in the vertical direction. Since only the horizontal direction is considered, the vertical component is... Set to 0.
[0043] Similarly, in the vertical direction, query components and bond components The calculation method is as follows: in, and These represent the position codes of query Q and key K after vertical rotation (see...). Figure 3 and Figure 4 The component after V_RoPE, at this time the horizontal component Set to 0.
[0044] Step S143: Use the query component and key component to perform axial feature aggregation on the values, and output the horizontal axial feature and the vertical axial feature.
[0045] Specifically, the attention mechanism can be implemented through a cross-attention mechanism or depthwise separable convolution. This embodiment takes the cross-attention mechanism as an example, which projects the value V in both horizontal and vertical directions through asymmetric convolution and other methods to enhance row and column information.
[0046] In an optional embodiment of the present invention, step S143 may include: Step S1431: By calculating the correlation matrix between the query component and the corresponding directional key component, axial attention weights in the horizontal and vertical directions are generated.
[0047] Step S1432: The values are weighted and projected using axial attention weights to obtain the aggregated results of the values in the axial features.
[0048] Specifically, the calculation process is divided into two branches, through aggregation (see...). Figure 5 (Aggregation) outputs horizontal attention respectively (See Figure 3 and Figure 5 (H_Attn) and vertical attention (See Figure 3 and Figure 5 (V_Attn), the formula is as follows: in, It is a horizontal axial feature. It is a feature of the vertical axis. is the scaling factor, and softmax is the normalization function.
[0049] Step S144: Fuse the horizontal axis features and the vertical axis features, and perform residual connection with the low-resolution semantic feature map to output an enhanced low-resolution semantic feature map.
[0050] In an optional embodiment of the present invention, step S144 may include: Step S1441: The horizontal axis features and the vertical axis features are summed and mapped, and learnable parameters are introduced to adjust the weights of the mapped features.
[0051] Step S1442: Add the adjusted features to the low-resolution semantic feature map and perform at least one loop enhancement process to obtain the enhanced low-resolution semantic feature map.
[0052] Specifically, the output features of the enhanced attention module The calculation formula is as follows: in, The input is a low-resolution semantic feature map. The output is an enhanced low-resolution semantic feature map. For learnable parameters, This involves a convolution operation with a 1×1 kernel. The fused features then undergo the same projection, encoding, and aggregation processes described above to achieve iterative enhancement, ultimately resulting in an enhanced low-resolution semantic feature map.
[0053] Step S2: The multi-scale feature maps are fused through the neck network to obtain multi-path enhanced feature maps.
[0054] Specifically, the Neck is responsible for fusing the multi-scale features output by the Backbone. Its function is to combine the strong semantics of high-level features with the fine spatial details of low-level features. In this embodiment, the structure of the Neck is as follows: Figure 2 The middle section shows four sequentially connected Concat+C3k2 modules. Through a top-down upsampling path and horizontal connections, it fuses high-resolution, low-semantic shallow features with low-resolution, high-semantic deep features, ultimately outputting the enhanced features required for the Head.
[0055] In an optional embodiment of the present invention, step S2 may include: Step S21: The enhanced low-resolution semantic feature map is upsampled at multiple levels and then cross-scale concatenated with the medium-resolution feature map and the high-resolution feature map, respectively, and residual feature extraction is performed to output the first enhanced feature map and the intermediate layer features.
[0056] Specifically, the enhanced low-resolution semantic feature map output by the Backbone's AR-CCA module is input to the first upsampling module (Up) of the Neck. The first concatenation unit (Concat) receives this upsampling output and the medium-resolution feature map output by the second C3k2 module in the Backbone, and processes it through the first C3k2 residual convolution module to obtain intermediate layer features. Subsequently, this intermediate layer feature is received by the second concatenation unit (Concat) through the second upsampling module and fused with the high-resolution feature map output by the first C3k2 module in the Backbone, and then processed by the second C3k2 module to output the first enhanced feature map.
[0057] Step S22: The first enhanced feature map is downsampled and horizontally concatenated with the intermediate layer features, and residual features are extracted to output the second enhanced feature map.
[0058] Specifically, the second enhancement process uses a convolutional layer (Conv) between the second and third C3k2 modules for downsampling. The first enhanced feature map (i.e., the output of the second C3k2 module) is downsampled by this convolutional layer and then received by the third concatenation unit (Concat). Simultaneously, this concatenation unit also receives intermediate layer features from the output of the first C3k2 module, achieving feature fusion through lateral connections. The fused features are then processed by the third C3k2 module to output the second enhanced feature map.
[0059] Step S23: The second enhanced feature map is downsampled and combined with the enhanced low-resolution semantic feature map to perform path aggregation and residual feature extraction, and the third enhanced feature map is output.
[0060] Specifically, the third enhancement process also incorporates a convolutional layer (Conv) for downsampling between the third and fourth C3k2 modules. The second-path enhanced feature map (i.e., the output of the third C3k2 module) is downsampled by this convolutional layer and then received by the fourth concatenation unit (Concat). This concatenation unit simultaneously receives the enhanced low-resolution semantic feature map output from the AR-CCA module at the backbone end, achieving bottom-up path aggregation. The aggregated features are then processed by the fourth C3k2 module to output the third-path enhanced feature map.
[0061] Finally, the second, third, and fourth C3k2 modules in the neck feature fusion process each output a result, resulting in a total of three multi-path enhanced feature maps being output to the Head.
[0062] Step S3: Predict the target category and bounding box position of the multi-path enhanced feature map using the detection head.
[0063] Specifically, the Head's function is to generate the final detection result based on the fused feature map. In this embodiment, the Head adopts a decoupled design and includes three Detect heads, such as... Figure 2 As shown on the right side, this decoupled design avoids conflicts between classification and regression tasks, resulting in better detection performance. Specifically, the first Detect receives the output from the second C3k2 module in the Neck module, the second Detect receives the output from the third C3k2 module in the Neck module, and the third Detect receives the output from the fourth and final C3k2 module in the Neck module.
[0064] In an optional embodiment of the present invention, step S3 may include: Step S31: Input the multi-path enhanced feature maps into the corresponding decoupled detection heads, perform feature mapping through the parallel classification branches at each level, and output the predicted class probability of the slender target using the activation function.
[0065] Specifically, each Detect head contains a classification branch for predicting the target category. The classification branch processes the input features using methods such as sigmoid to obtain a probability score indicating whether the target belongs to each elongated target category.
[0066] Step S32: Through the regression branch running in parallel with the classification branch, the distributed focus learning mechanism is used to perform boundary anchoring and offset prediction on the multi-path enhanced feature maps, and output the predicted bounding box coordinates of the slender target.
[0067] Specifically, each Detect head also includes a bounding box regression branch running parallel to the classification branch. The regression branch uses methods such as Distributed Focus Learning (DFL) to obtain the geometric parameters of the predicted bounding box, ultimately achieving efficient location prediction for slender targets. The model eventually predicts the target bounding box parameters, including the coordinates of the bounding box center point. The bounding box width w and height h, as well as the target confidence. Mathematically, the confidence is the product of the target's existence probability and the bounding box localization accuracy.
[0068] Step S4: Construct a slender target detection model based on the backbone network, neck network, and detection head, and train the slender target detection model to detect slender targets in the image.
[0069] Specifically, by constructing a dedicated dataset of slender targets and using a loss function to guide the iterative optimization of model parameters, the model learns the inherent patterns and feature mappings of slender targets, ultimately achieving efficient detection of typical slender targets.
[0070] In an optional embodiment of the present invention, step S4 may include: Step S41: Construct a dataset specifically for detecting slender targets.
[0071] Specifically, target categories that conform to the geometric characteristics of slender targets are selected from the training and validation sets of existing general datasets to form a dedicated dataset for slender targets. This embodiment selects categories with typical slender structures, such as ships, skis, and surfboards, from two large datasets, COCO and Objects365. During the construction process, systematic considerations were made regarding target category, target size, background diversity, annotation consistency, data balance, and noise control to ensure that the dataset covers different scale variations, complex backgrounds, occlusion conditions, and multiple lighting conditions. Example images of some categories and their labels in the dataset can be found in [link to example images]. Figure 6 .
[0072] Step S42: Train the slender target detection model.
[0073] Specifically, using labeled training data, the model parameters of Backbone, Neck, and Head are updated iteratively to minimize a predefined loss function.
[0074] In an optional embodiment of the present invention, step S42 may include: Step S421: Calculate the classification loss between the predicted target category and the true target label.
[0075] Specifically, the prediction error of the classification branch is calculated using cross-entropy loss (CE) or binary cross-entropy loss (BCE).
[0076] Step S422: Calculate the geometric localization loss between the predicted bounding box and the actual bounding box label.
[0077] Specifically, GIoU loss, DIoU loss, or a combination thereof are used to measure the geometric overlap, center point distance, and aspect ratio difference between the predicted bounding box and the ground truth box.
[0078] Step S423: Calculate the confidence loss between the predicted target existence probability and the true label.
[0079] Specifically, based on the confidence calculation rules defined in Head, the product error of the target existence probability and the positioning accuracy is evaluated.
[0080] Step S424: The classification loss, geometric location loss, and confidence loss are weighted and calculated to obtain the total loss.
[0081] Step S425: Perform backpropagation based on the total loss, and update the parameters of the slender target detection model through iterative optimization.
[0082] Specifically, the weights are continuously adjusted using the backpropagation algorithm until the model converges. During training, the changes in metrics such as recall, precision, and F1 score with confidence are monitored. Figures 7A to 7C The graphs show the changes in recall, precision, and F1 score with confidence level during model training. It can be seen that different categories, such as train, boat, skis, and snowboard, have different curves. In Figures A to C, the smooth, thick blue curves represent the changes in average recall, average precision, and average F1 score for all categories at different confidence thresholds. For example, "all classes 0.80 at 0.000" means that when the confidence level is 0, the average recall for all categories is 0.80.
[0083] In an optional embodiment of the present invention, the generalization ability can be evaluated based on an independent validation set, strategies such as early stopping can be used to prevent overfitting, and hyperparameters can be adjusted according to performance indicators.
[0084] Step S43: Use the trained elongated target detection model to predict the image to be processed and output the elongated target detection result.
[0085] Specifically, the image to be processed is input into the trained model, which outputs the predicted bounding box and its confidence score. The prediction result includes the coordinates of the center point of the target bounding box. The bounding box width *w*, height *h*, and target confidence score are all considered. This model can output accurate detection boxes for typical slender targets such as surfboards, boats, and tripods. Figure 8 The test results are shown.
[0086] This invention also provides a slender target detection system based on an enhanced attention mechanism, such as... Figure 9 As shown, it includes: The backbone network module is used to perform multi-scale feature extraction and attention enhancement on the image to be processed, resulting in multi-scale feature maps. The neck network module is used to perform feature fusion on the multi-scale feature maps to obtain multi-path enhanced feature maps; The detection head module is used to predict the target category and bounding box position of the multi-path enhanced feature map; The training module is used to train the elongated target detection model constructed from the backbone network, neck network, and detection head for detecting elongated targets in images.
[0087] Method performance testing: To fully verify the beneficial effects of the proposed solution, experiments were conducted on the recognized authoritative benchmark datasets COCO and Objects365. Since the original datasets are designed for general object detection, this experiment selected and constructed evaluation subsets specifically for slender targets. These subsets cover multiple different sources and scenarios, used to comprehensively evaluate the model's detection performance and generalization ability for slender targets.
[0088] The following methods were used for performance comparison in the experiment: Baseline: refers to the original YOLO11s model, which serves as the baseline for comparison; ACCNets: refers to models built based on the YOLO11s backbone network and combined with the improvement strategy proposed in this invention; ACCNetm: refers to a model built on a larger YOLO11m backbone network, combined with the improved strategy proposed in this invention.
[0089] The experiment uses common evaluation metrics in the field of target detection: AP50: Average accuracy at an Intersection over Union (IoU) threshold of 0.50; AP: The overall average accuracy across multiple IoU thresholds (0.50 to 0.95) is a core indicator for measuring the overall detection capability of a model.
[0090] The performance metrics of each method on the elongated target subset of the COCO dataset are shown in Table 1: Table 1. Performance Comparison of Slender Target Subset Detection on COCO Dataset The performance metrics for each method on a thin subset of the Objects365 dataset are shown in Table 2: Table 2. Performance Comparison of Elongated Object Subset Detection on the Objects365 Dataset Based on the analysis of the above experimental data, the following conclusions can be drawn: Significantly Improved Detection Accuracy: The improved scheme proposed in this invention achieves a significant improvement in AP compared to the baseline model on both datasets. ACCNetm achieves an AP of 46.5% on the COCO subset and 43.9% on the Objects365 subset. Even the lightweight ACCNets outperforms the baseline across the board, effectively addressing the inherent shortcomings of slender targets such as fragility, missed detections, and inaccurate localization.
[0091] Strong generalization and robustness: The proposed solution consistently and stably improves detection performance on both COCO and Objects365 subsets, which have different data sources and scene complexities. This strongly demonstrates that the algorithm has strong generalization ability and environmental adaptability, rather than being overfitted to specific data.
[0092] Although the present invention has been disclosed above with reference to embodiments, it is not intended to limit the present invention. Appropriate modifications or equivalent substitutions made by those skilled in the art to the technical solutions of the present invention should be covered within the protection scope of the present invention, which is defined by the claims.
Claims
1. A method for detecting slender targets based on an enhanced attention mechanism, characterized in that, Includes the following steps: Multi-scale feature maps are obtained by performing multi-scale feature extraction and attention enhancement on the image to be processed through the backbone network. The multi-scale feature maps are fused using a neck network to obtain multi-path enhanced feature maps; The detection head is used to predict the target category and bounding box position of the multi-path enhanced feature map; A slender target detection model is constructed based on the backbone network, neck network, and detection head, and the slender target detection model is trained to detect slender targets in images.
2. The method as described in claim 1, characterized in that, The backbone network performs multi-scale feature extraction and attention enhancement on the image to be processed, resulting in multi-scale feature maps, including: The image to be processed is subjected to backbone initial convolution to obtain an initial feature map; The initial feature map is downsampled step by step through a multi-level cascaded residual feature extraction unit, and high-resolution feature maps and medium-resolution feature maps are extracted from different downsampling levels of the backbone network respectively. Spatial pyramid pooling is applied to the features extracted from the downsampling layers at the end of the backbone network to aggregate multi-receptive field features and output a low-resolution semantic feature map. An enhanced low-resolution semantic feature map is obtained by applying attention enhancement to the low-resolution semantic feature map using an enhanced attention module.
3. The method as described in claim 2, characterized in that, An enhanced low-resolution semantic feature map is obtained by applying attention enhancement to the low-resolution semantic feature map using an enhanced attention module, including: By projecting features onto the low-resolution semantic feature map, the query, key, and value are obtained. The query and key are independently encoded in one-dimensional positions in the horizontal and vertical directions to obtain query components and key components with spatial position information. The query component and key component are used to aggregate the values along the axial features, and the horizontal and vertical axial features are output. The horizontal axis features are fused with the vertical axis features and then residually connected to the low-resolution initial semantic feature map to output an enhanced low-resolution semantic feature map.
4. The method as described in claim 3, characterized in that, Perform independent one-dimensional positional encoding on the query features and key features in the horizontal and vertical directions, including: The two-dimensional spatial location information of the feature map is masked in a directional manner, that is, the vertical location component is masked when calculating the horizontal feature, and the horizontal location component is masked when calculating the vertical feature. The unidirectional location information after directional masking is encoded and injected into the feature to generate query components and key components with spatial location information.
5. The method as described in claim 3, characterized in that, Axial feature aggregation is performed on the values using the query components and key components described above, including: By calculating the correlation matrix between the query component and the corresponding directional key component, axial attention weights in the horizontal and vertical directions are generated. By using axial attention weights to perform weighted projection on the values, we obtain the aggregated results of the values in the axial features.
6. The method as described in claim 3, characterized in that, The horizontal and vertical axis features are fused and residually connected to the low-resolution semantic feature map to output an enhanced low-resolution semantic feature map, including: The horizontal axis features and vertical axis features are summed and mapped, and learnable parameters are introduced to adjust the weights of the mapped features. The adjusted features are added to the low-resolution semantic feature map, and at least one loop of enhancement processing is performed to obtain the enhanced low-resolution semantic feature map.
7. The method as described in claim 2, characterized in that, The multi-scale feature maps are fused using a neck network to obtain multi-path enhanced feature maps, including: The enhanced low-resolution semantic feature map is upsampled at multiple levels and then concatenated across scales with medium-resolution and high-resolution feature maps and residual feature extraction is performed to output the first enhanced feature map and intermediate layer features. The first enhanced feature map is downsampled and horizontally concatenated with the intermediate layer features, and residual features are extracted to output the second enhanced feature map. The second enhanced feature map is then downsampled and combined with the enhanced low-resolution semantic feature map for path aggregation and residual feature extraction to output the third enhanced feature map.
8. The method as described in claim 1 or 7, characterized in that, The multi-path enhanced feature map is analyzed using a detection head to predict the target category and bounding box location, including: The multi-path enhanced feature maps are input to the corresponding decoupled detection heads, and feature mapping is performed through parallel classification branches at each level. The predicted class probability of the slender target is output using the activation function. By using a regression branch that runs parallel to the classification branch, a distributed focus learning mechanism is employed to perform boundary anchoring and offset prediction on the multi-path enhanced feature map, outputting the predicted bounding box coordinates of the slender target.
9. The method as described in claim 1, characterized in that, Training the slender target detection model includes: Calculate the classification loss between the predicted target category and the true target label; Calculate the geometric localization loss between the predicted bounding box and the ground truth bounding box label; Calculate the confidence loss between the predicted target existence probability and the true label. The total loss is obtained by weighting the classification loss, geometric localization loss, and confidence loss. Backpropagation is performed based on the total loss, and the parameters of the slender target detection model are updated through iterative optimization.
10. A system for detecting slender targets based on an enhanced attention mechanism, characterized in that, include: The backbone network module is used to perform multi-scale feature extraction and attention enhancement on the image to be processed, resulting in multi-scale feature maps. The neck network module is used to perform feature fusion on the multi-scale feature maps to obtain multi-path enhanced feature maps; The detection head module is used to predict the target category and bounding box position of the multi-path enhanced feature map; The training module is used to train the elongated target detection model constructed from the backbone network, neck network, and detection head for detecting elongated targets in images.