# Research on Improved YOLO11 for Detecting Small Targets in Sonar Images Based on Data Enhancement
## 3 Methodology
### Improved Network
#### 3.2.2 EEA Attention Mechanism  
To guarantee detection range, sonar detection often reduces frequency, sacrificing precision and leading to low spatial resolution and blurry image details [25; 26]. For target detection in such complex, low-resolution sonar images, the target's edge contour info is crucial for identification and accurate positioning. Though the C2 PSA attention mechanism in YOLOv11 shows excellent performance across large datasets [27], it is too globally information-dependent, weakening its ability to capture local details. Therefore, in fine-grained tasks, such as edge detection and small-target recognition, C2 PSA's effectiveness declines, making it unsuitable for sonar image target recognition. Consequently, this paper introduces a novel Edge-Enhanced Attention (EEA) mechanism, which integrates multi-scale gradient perception, spatial attention, and channel attention. This mechanism enhances the model's sensitivity to edge features, particularly in small-object detection within sonar images where fine edge details are crucial. EEA consists of three main components: multi-scale gradient perception, spatial-channel co-attention, and feature fusion, with its specific structure shown in Figure 6.  
After feature maps enter the module, they undergo convolution and split into two branches. First, one branch performs multi-scale gradient perception and uses residual design (subtracting \(x_{1}\)) to highlight edge changes and suppress flat areas. The formula is as shown in Equation (6):  
\[\text{grad}_{d}=\text{Conv}_{3\times 3}^{\text{dilation}=d}(x_{1})-x_{1} \tag{6}\]  
The SC_attention module in EEA is a spatial-channel collaborative attention mechanism. This module concatenates multi-scale gradient features to generate spatial weights. Here, \(w_{s1}\) and \(w_{s2}\) stand for \(1\times 1\) convolution operations, and the output \(S\in\mathbb{R}^{B\times 3\times H\times W}\) corresponds to the weight coefficients of the three scales at each position. The formulas are as Equation (7), and the architecture of the SC_attention module is shown in Figure 7.  
\[S=\sigma\big{(}W_{s2}\cdot\text{ReLU}\big{(}W_{s1}\cdot[\text{grad}_{1}; \text{grad}_{2};\text{grad}_{3}]\big{)}\big{)} \tag{7}\]  
Figure 5: FASFF.  
Then, the weighted multi-scale gradient fusion operation is performed as per Formula (8). Here, \(S_{d}\) denotes the spatial attention map of the \(d\)-th scale, and \(\odot\) stands for element-wise multiplication.  
\[\text{weighted\_grad}=\sum_{d=1}^{3}S_{d}\odot\text{grad}_{d} \tag{8}\]  
The fused features then go through the C_attention (channel attention module) to adjust the importance weights of different channels, thereby enhancing the key channel feature responses via a channel attention mechanism. This is specifically represented as Equation (9), and in this equation, GPA is global average pooling \(w_{c1}\) and \(w_{c2}\) are \(1\times 1\) convolutions \(C\in\mathbb{R}^{B\times c\times 1\times 1}\). Its processing flow is shown in Figure 8:  
\[C=\sigma(W_{c2}\cdot\text{ReLU}(W_{c1}\cdot\text{GAP}(\text{weighted\_grad}))) \tag{9}\]  
Figure 8: C_attention module.  
Figure 6: Edge-Enhanced Attention (EEA) structure and process.  
Figure 7: SC_attention module.  
Finally, the enhanced edge features are fused with the original branch through element-wise addition, as in Equation (10).  
\[y=W_{3}\cdot(x_{2}+\text{weighted\_grad}\odot\text{C}) \tag{10}\]  
The EEA module considers both spatial and channel dimensions, capturing multi-scale edge information and performing feature decomposition and fusion. This module enhances edges while preserving original information. Unlike the original C2 PSA, EEA significantly strengthens edges and details in images, showing great potential in enhancing small targets and weak edge targets in sonar images. The overall implementation formula is as Equation (11):  
\[y=W_{3}\cdot\left(W_{2}\cdot x+\left(\sum_{d=1}^{3}S_{d}\odot(\text{Conv}_{d}(W _{1}\cdot x)-W_{1}\cdot x)\right)\odot\text{C}\right) \tag{11}\]