# Steel Surface Defect Detection Algorithm Based on Improved YOLOv8n
## 2 Related Works
### Based on the Improved YOLOv8 Algorithm (DDI-YOLO)
#### 2.2.4 Inner-IoU Loss Functions  
The loss function for the regression used in YOLOv8 is CIoU [30]. The CIoU loss function considers the entire intersection between target frames and adds a correction factor to more precisely quantify the similarity between target frames. The CIoU loss function has the following advantages: it is more robust relative to different shapes of target frames, it more easily captures the exact shape of the target, and it takes into account several factors such as position, shape, and direction, all of which can help enhance the model's performance in complex situations. However, with respect to practical applications in the context of steel surface defect detection, it cannot be adapted according to the different detection assignments and its capacity for generalization is weak; therefore, considering the aforementioned shortcomings, the model cannot be applied to the detection of steel surface defects. Based on the above shortcomings, the regression loss function, known as the Inner-IoU loss function, was introduced in this study. The Inner-IoU loss function was proposed by [PERSON] [31] et al. in 2023. This loss function calculates the IoU loss using an auxiliary bounding box, and a scale factor ratio is introduced to regulate the auxiliary bounding box scale size, which is utilized to determine the loss. To compensate for the shortcomings of the CIoU loss function, Inner-IoU entails the use of an auxiliary bounding box to compute the loss and quicken the process of bounding box regression. The scale factor ratio is introduced in the Inner-IoU and can be used to regulate the scale size of the  
Figure 4: Dilated reparam block module.  
auxiliary bounding box to overcome the limitation of the weak generalization ability of existing methods. The formula for the calculation of the Inner-IoU is as follows:  
\[b_{l}^{gt}=x_{c}^{gt}-\frac{w^{gt}*ratio}{2},b_{r}^{gt}=x_{c}^{gt}+\frac{w^{gt}* ratio}{2} \tag{1}\]  
\[b_{t}^{gt}=y_{c}^{gt}-\frac{h^{gt}*ratio}{2},b_{b}^{gt}=y_{c}^{gt}+\frac{h^{gt} *ratio}{2} \tag{2}\]  
where the ground truth (GT) frame and the anchor are identified as \(B^{gt}\) and \(B\) respectively, and the centers of the GT frame and the internal GT frame are denoted by the points (\(x_{c}^{gt}\),\(y_{c}^{gt}\)), which also denote the centers of the anchor and of the internal anchor.  
\[b_{l}=x_{c}-\frac{w*ratio}{2},b_{r}=x_{c}+\frac{w*ratio}{2} \tag{3}\]  
\[b_{t}=y_{c}-\frac{h*ratio}{2},b_{b}=y_{c}+\frac{h*ratio}{2} \tag{4}\]  
\[inter=(min(b_{r}^{gt},b_{r})-max(b_{l}^{gt},b_{l}))* \tag{5}\]  
\[union=(w^{gt}*h^{gt})*(ratio)^{2}+\]  
\[(w*h)*(ratio)^{2}-inter \tag{6}\]  
The width and height of the GT frame are denoted by \(w^{gt}\) and \(h^{gt}\), respectively, and \(w\) is the width and \(h\) is the height. The variable \"ration\" corresponds to the scale factor, which is usually in the value range of [0.5,1.5].  
\[IoU^{inner}=\frac{inter}{union} \tag{7}\]  
\[L_{Inner-IoU}=1-IoU^{inner} \tag{8}\]  
The _inter_ and _union_ are calculated using the above formula.