# Light-YOLO: A Study of a Lightweight YOLOv8n-Based Method for Underwater Fishing Net Detection
## 3 Model Improvement  
### An Improved Approach to Feature Fusion  
In underwater environment monitoring, fishing nets are broken due to the current impact of water, and their morphology is complex and variable, making them difficult to distinguish. The attention mechanism is introduced in traditional methods to improve the recognition accuracy [19]. However, the global attention mechanism requires computation-intensive interactions, which conflicts with the computational capacity limitations of edge devices. Therefore, this paper proposes a low-computation attention improvement module, DA2D, optimized for underwater scenes. This module can dynamically adapt and prioritize potential hotspot regions. It is a flexible and efficient self-attention mechanism that dynamically adapts the positions of key locations and values according to the input data, thus enabling the model to focus more on relevant regions and capture more informative features. The flowchart of the sub-network module of the DA2D module is shown in Figure 1.  
Based on the self-attention mechanism, DA2D firstly generates a set of uniformly distributed reference points on the feature map and learns the offsets of these reference points based on the query feature using an offset network. The offset network module diagram is shown in Figure 2.  
For each query q, the offset vectors of all reference points obtained from the query features are computed using the offset network O, as shown in Equation (1):  
\[\Delta\text{P}_{\text{offset}}=\text{O}(\text{q}) \tag{1}\]  
where O(q) denotes the new offset of each reference point relative to the original position. In the feature sampling and deformation phase, the offset network takes the query features  
Figure 1: Flowchart of the sub-network module of the DA2D module. Figure 2: Offset sub-network module diagram. as inputs and samples the feature map by bilinear interpolation based on the learned offsets to obtain the deformed keys and values, as shown in Equations (2) and (3):  
\[\mathrm{K_{deformed}^{(m)}}=\mathrm{F}\big{(}\mathrm{x}+\Delta\mathrm{p_{offset }}\big{)} \tag{2}\]  
\[\mathrm{V_{deformed}^{(m)}}=\mathrm{G}\big{(}\mathrm{x}+\Delta\mathrm{p_{offset }}\big{)} \tag{3}\]  
where (m) denotes the mth attention head in which F and G are the functions that map the deformed positions back to the feature map to extract the keys and values, respectively. In this way, the corresponding offsets are calculated for each reference point. The relative positional bias is also calculated from the deformed points to enhance the multi-head attention mechanism and to output the transformed feature representation. The multi-head attention computation follows the principle of multi-head attention computation in the standard transformer module, where the keys and values used have already undergone the deformation operations described above, and relative position offsets computed from the deformed points are introduced to enhance the attention mechanism. The formula is provided as follows:  
\[\mathrm{Z_{deformed}^{(m)}}= \sigma(\frac{\mathrm{q(m)K_{deformed}^{(m)}}}{\mathrm{d}})\mathrm{V _{deformed}^{(m)}} \tag{4}\]  
where \(\sigma\) is a softmax function to normalize the attention weights at each position, and \(\mathrm{d}\) is half of the feature dimensions in each attention head. By projecting queries, keys, and values into separate subspaces and performing independent attention computations, the model can capture different schema dependencies simultaneously. DA2D further introduces the ability to dynamically adjust the key points and value locations, thus making the attention more focused on essential regions. The DA2D module provides the model with the ability to adaptively adjust the location of attentional sampling points according to the input content by drawing on the deformable convolutional [20] concept to provide the model with an ability to adaptively adjust the location of attentional sampling points based on the input content.