# ST-YOLOv8: Small-Target Ship Detection in SAR Images Targeting Specific Marine Environments
## 2 Method
### Loss Functions  
Object detection, as a core problem in computer vision, heavily relies on the design of its loss functions to achieve optimal performance. As a crucial component of object detection loss functions, a well-designed bounding box loss function can significantly enhance the performance of detection models. Recent studies often assume that the training data samples are of high quality and focus on enhancing the regression capabilities of bounding box loss functions. However, it is noteworthy that object detection training datasets often contain low-quality samples. Overly focusing on regressing bounding boxes for these low-quality samples can negatively impact model performance. Focal-EIoU v1 addresses this issue, but its static focusing mechanism does not fully exploit the potential of non-monotonic focusing mechanisms. Wise-IoU (W-IoU) is a bounding box regression loss function based on a dynamic focusing mechanism, significantly improving the performance of object detection models. Traditional IoU loss functions treat all samples equally during bounding box regression, ignoring the differences in difficulty among samples, while W-IoU dynamically adjusts sample weights, allowing the model to focus more on hard-to-learn samples (e.g., small or occluded targets), thereby enhancing detection accuracy. The core idea of W-IoU is to use a Dynamic Focusing Factor (DFF) to adjust the loss weight, formulated as  
\[\mathcal{L}_{WIoU}=\mathcal{R}_{WIoU}\mathcal{L}_{IoU} \tag{3}\]  
\[\mathcal{R}_{WIoU}=\exp\left(\frac{(x-x_{gt})^{2}+\left(y-y_{gt}\right)^{2}}{ \left(W_{g}^{2}+H_{g}^{2}\right)^{*}}\right) \tag{4}\]  
The meanings of each element are as follows:  
\(x\) and \(y\): The coordinates of the center point of the predicted bounding box.  
\(x_{gt}\) and \(y_{gt}\): The coordinates of the center point of the ground-truth bounding box.  
\(W_{g}\) and \(H_{g}\): The width and height of the minimum enclosing box, which is the smallest rectangle that contains both the predicted and ground-truth bounding boxes.  
\(\left(W_{g}^{2}+W_{g}^{2}\right)*\): The sum of the squares of the width and height of the minimum enclosing box. The symbol \(*\) may indicate a specific processing method, such as taking the average or maximum value, depending on the implementation details.  
This formula calculates the squared distance between the center points of the predicted and ground-truth bounding boxes, normalized by the sum of the squares of the width and height of the minimum enclosing box, and then takes the exponential of this value. This term is used to adjust the Wiou loss function, such that the greater the distance between the center points of the predicted and ground-truth bounding boxes, the larger the loss. This encourages the model to predict bounding boxes that are closer to the center of the ground-truth boxes.  
\[\mathcal{L}_{IoU}=1-\text{IoU}\left(B_{p},B_{g}\right) \tag{5}\]  
Figure 6: Structure diagram of Shuffle Attention.  
\[\text{IoU}=\frac{\text{Area of Overlap}}{\text{Area of Union}} \tag{6}\]  
\[\text{IoU}(B_{p},B_{g})=\frac{\text{Area}\big{(}B_{p}\cap B_{g}\big{)}}{\text{ Area}\big{(}B_{p}\big{)}+\text{Area}\big{(}B_{g}\big{)}-\text{Area}\big{(}B_{p}\cap B_{g} \big{)}} \tag{7}\]  
Among them, \(B_{p}\) is the hypothetical prediction box, and \(B_{g}\) is the real box  
Area (\(B_{p}\cap B_{g}\)) is the intersection area between the predicted box and the real box.  
Area (\(B_{p}\)) and Area (\(B_{g}\)) are the areas of the predicted box and the real box, respectively.