# Multi-Target Detection Algorithm for Fusion Images Based on an Attention Mechanism
## 4 Architecture Improvements for Multi-Target Detection
### Loss Function Improvement
At the same time, \(L_{IoU}\to 1\) indicates that the predicted box and the true box are basically overlapped, and a good effect has been achieved at this time. Therefore, this penalty term can reduce the impact of loss when the predicted box effect is already very good. At the same time, in order to prevent \(R_{WIoU}\) from hindering  
Figure 15: CIOU schematic. convergence, \(W_{g}\) and \(H_{g}\) are separated from the calculation graph. The asterisk (*) in the denominator denotes a separation operation, and this interpretation remains consistent throughout the subsequent formulas. 2. Wise-IoU v2 WloUv2 uses a monotonic focusing mechanism, which can reduce the impact of simple data on the loss value. WloUv2 introduces a gradient gain \(L_{IoU}^{\gamma^{*}}\). The larger the IoU, the smaller the \(L_{IoU}\), and the smaller the gradient gain \(L_{IoU}^{\gamma^{*}}\), which will reduce the impact of loss when the effect is good. \[L_{WloUv2}=L_{IoU}^{\gamma^{*}}L_{WloUv1},\gamma>0\] (11) Equation (12) adds a normalization factor \(\overline{L_{IoU}}\) to Equation (11), which can keep the gradient gain \((\frac{L_{IoU}^{\gamma^{*}}}{L_{IoU}})^{\gamma}\) at a high level and prevent the gradient gain from being too small to affect training. \[L_{WloUv2}=(\frac{L_{IoU}^{\gamma^{*}}}{\overline{L_{IoU}}})^{\gamma}L_{WloUv1},\] (12)
3. Wise-IoU v3 WloU v3 introduces the outlier to indicate the quality of the anchor box. The calculation equation of the outlier is \[\beta=\frac{L_{IoU}^{*}}{\overline{L_{IoU}}}\in[0,+\infty)\] (13) A small outlier indicates a high-quality prediction box. In model training, more attention should be paid to the bounding boxes that have a positive impact on the prediction accuracy. WloUv3 focuses on the prediction boxes with better quality by controlling the gradient gain. For the prediction boxes with large outliers, WloUv3 will reduce the gradient gain, which can reduce the adverse effect of the gradient generated by this set of low-quality data on the model. In this way, the model can pay more attention to the prediction boxes of general quality, improve the performance in actual scenarios, and effectively control the impact of low-quality data. The calculation equation of IoUv3 is \[L_{WloUv3}=rL_{WloUv1},\quad r=\frac{\beta}{\delta\alpha^{\beta-\delta}}\] (14) where \(r\) is a non-monotonic focusing coefficient constructed using \(\beta\), and \(\alpha\) and \(\delta\) are hyperparameters. It should be noted that in Equation (14), the denominator \(\alpha^{\beta-\delta}\) may approach zero when \(\alpha\) is small and \(\beta\) is close to \(\delta\), potentially leading to numerical instability. To mitigate this, we ensure that \(\alpha\) remains a small but non-zero positive constant, and we constrain the range of \(\beta\) during training to maintain numerical stability. Moreover, the coefficient \(r(\beta)\) exhibits non-monotonic behavior with respect to \(\beta\), meaning that increasing \(\beta\) does not always lead to a linear increase or decrease in \(r\). This design enables the loss function to dynamically adjust its focus on bounding boxes of different qualities, making it more adaptive to varying object detection scenarios. In this paper, the original CIoU loss function in YOLOv8 is replaced with WloU. Specifically, the bounding box regression branch of the detection head is modified to compute WloU-based loss values during training. This allows YOLOv8 to benefit from WIoU's adaptive penalty mechanism, thereby improving its robustness to noisy labels and enhancing detection accuracy, particularly in complex or low-quality data scenarios.