# RHS-YOLOv8: A Lightweight Underwater Small Object Detection Algorithm Based on Improved YOLOv8
## 2 Methodology
### Efficient Localization Attention  
To further enhance the detection capability of the model, this paper adopts the Efficient Local Attention (ELA) module [39], which is proposed based on an in-depth analysis of the Coordinate Attention (CA) method [40]. The structure of ELA is shown in Figure 5. Compared to CA, the ELA module is able to efficiently encode two 1D positional feature figures without the need to reduce the channel dimensions through 1D convolution and group normalized feature enhancement techniques. In addition, the design of the ELA module maintains its lightweight nature, enabling it to be easily integrated into existing convolutional neural networks. Thus, this modification effectively addresses the limitations of CA batch normalization in generalization, mitigates the negative impact of dimensionality reduction on channel attention, and reduces the complexity of the attention generation process.  
Figure 5: The structure of Efficient Local Attention (ELA).  
The parameters of the input x from the convolutional block are denoted as \(\mathbb{R}^{H\times W\times C}\), denoting the height, width, and channel dimension (i.e., the number of convolutional kernels), respectively. ELA extracts feature vectors in both the horizontal and vertical directions by applying banded pooling along the spatial dimension, preserving elongated kernel shapes to capture long-distance dependencies while minimizing interference from unrelated regions during label prediction. Specifically, for input x, each channel is encoded along horizontal and vertical coordinates using pooling kernels of dimensions \((H,1)\) and \((1,W)\), corresponding to the i and j directions, respectively. The output of the c.th channel with height h is shown in Equation (11).  
\[\mathrm{z}_{c}^{h}(h)=\frac{1}{W}\sum_{0\leq i<W}x_{c}(h,i) \tag{11}\]  
Similarly, the output of the c.th channel with width w is as in Equation (12).  
\[\mathrm{z}_{c}^{w}(w)=\frac{1}{H}\sum_{0\leq j<H}x_{c}(j,w) \tag{12}\]  
The above two transformations perform feature aggregation along the two spatial directions, returning a pair of direction-aware attention graphs, which in doing so can generate informative object location features in each direction. To efficiently utilize these features, 1D convolution is applied to augment the position information in the horizontal and vertical directions, denoted as \(F_{h}\) and \(F_{w}\), respectively, using a convolution kernel size of 5 or 7. Subsequently, we utilize Group Normalization (denoted as \(G_{n}\)) [41] to process the augmented position information and thus represent the positional attention in both the horizontal and vertical directions, as shown in Equations (13) and (14).  
\[\mathrm{g}^{h}=\sigma(G_{n}(F_{h}(z^{h}))) \tag{13}\]  
\[\mathrm{g}^{w}=\sigma(G_{n}(F_{w}(z^{w}))) \tag{14}\]  
where \(\sigma\) is the nonlinear activation function, and the results of positional attention in the horizontal and vertical directions are denoted as \(g^{h}\) and \(g^{w}\), respectively. The final output \(Y\) of the ELA module can be expressed as in Equation (15).  
\[Y=x_{c}\times g^{h}\times g^{w} \tag{15}\]  
In YOLOv8, this paper places the ELA module after the backbone part as a key component of the model. The main role of the backbone is to extract the features of the image, while the ELA module further enhances the spatial information of these features so that the model can better focus on the object region and ignore the background noise.