## 3 The Proposed Method
### Wise-IoI Loss  
In the YOLOv8 model, DFL loss and CIoU loss [30] are applied as the marginal regression loss functions. The DFL loss function helps focus the detection network faster on the defect target location as well as the neighboring regions, while the CIoU loss function evaluates the accuracy of the bounding box prediction in the defect detection model. The CIoU formula is as follows:  
\[L_{CIoU}=L_{IoU}+\frac{\left(x-x_{gt}\right)^{2}+\left(y-y_{gt}\right)^{2}}{ \left(W_{g}^{2}+H_{g}^{2}\right)}, \tag{9}\]  
\[\alpha=\frac{v}{L_{IoU}+v}, \tag{10}\]  
\[v=\frac{4}{\pi^{2}}\left(arctan\frac{w}{h}-arctan\frac{w_{gt}}{h_{gt}}\right) ^{2}, \tag{11}\]  
\[L_{IoU}=\frac{W_{i}H_{i}}{wh+w_{gt}h_{gt}-W_{i}H_{i}} \tag{12}\]  
The expression for \(L_{IoU}\) is illustrated in Figure 7. In this equation, \(\alpha\) represents the weight function, used for balancing parameters, \(v\) is the aspect ratio measure function, used to assess the aspect ratio consistency. \(w\), \(h\), and \((x,y)\) represent the width and height dimensions and the center coordinates of the prediction box, respectively, \(w_{gt}\), \(h_{gt}\), and \(\left(x_{gt},y_{gt}\right)\) represent the width and height dimensions and the center coordinates of the real box, respectively, \(W_{i}\) and \(H_{i}\) represent the intersection width and height, respectively, and \(W_{g}\) and \(H_{g}\) represent the minimum border width and height, respectively. In the prediction frame regression process, there are cases where the penalty term of the CIoU degrades to zero when the prediction frame is linear in the aspect ratio of the real frame, while either high- or low-quality anchor frames can be harmful to the regression losses.  
The accuracy of the model's bounding box prediction can be affected by the diversity of target sizes and shapes of various defect types in the strip surface defect dataset, as well as the distribution differences in the images. To solve this problem, the WioU [31] is introduced in this paper to replace the CIoU loss function, improving the precision of the  
Figure 7: The area of intersection and union of the real box and the prediction box.  
common mass anchor frame and enhance the fitting ability of the bounding box loss. The WIoU loss function is shown below:  
\[L_{WIoU}=rR_{WIoU}L_{IoU},R_{WIoU}\in[1,e),\ L_{IoU}\in[0,1]. \tag{13}\]  
The distance-focusing mechanism \(R_{WIoU}\) in the formula is used to amplify the \(L_{IoU}\) of ordinary appropriate anchor boxes, and the non-monotonic focusing factor \(r\) is used to focus on anchor boxes of normal quality. The expressions for \(R_{WIoU}\), \(r\), and the outlier factor \(\beta\) are as follows:  
\[R_{WIoU}=exp\left(\frac{\left(x-x_{gt}\right)^{2}+\left(y-y_{gt}\right)^{2}} {\left(W_{g}^{2}+H_{g}^{2}\right)^{*}}\right), \tag{14}\]  
\[r=\frac{\beta}{\delta a^{\beta-\delta}}, \tag{15}\]  
\[\beta=\frac{L_{IoU}^{*}}{L_{IoU}}\in[0,+\infty), \tag{16}\]  
where \(\overline{L_{IoU}}\) represents the dynamic moving average. Relatively small gradient gains are allocated for both large and small values, reducing the impact on bounding box regression. Meanwhile, \(\alpha\) and \(\delta\) represent hyperparameters. By lowering the contribution of high-quality samples to the loss value, \(r\) dynamically assigns gradient gains to bounding boxes, decreasing the harmful gradients produced by low-quality anchor boxes in the later stages of training. Moreover, it focuses on ordinary quality anchor frames to improve model localization.  
WIoU removes the aspect ratio penalty term from the CIoU while balancing the impact of both high-quality and ordinary-quality anchor boxes on model regression, which increases the model's generalization capability and overall performance. Therefore, this paper adopts WIoU to replace the original model's boundary loss function for optimizing the model's loss function.