## 3 Method
### LIOU Loss Function  
The loss function for bounding box regression quantifies the difference between the predicted boxes and the ground truth, enabling the model to generate more accurate location predictions. As a result, a well-designed loss function can significantly enhance the model's detection performance. YOLOv8 employs CIOU [33] to compute the loss.  
The CIOU bounding box loss function is composed of three components: IOU loss, center distance loss, and aspect ratio loss. Upon investigating the aspect ratio loss, the following observations were made:  
1. When the predicted box has the same aspect ratio as the ground truth box, but with differing width and height values, the penalty term does not accurately reflect the true discrepancy between the two boxes.
2. The gradient of height and width are calculated as shown in Equations (13) and (14). \[\frac{\partial v}{\partial w}=\frac{8}{\pi^{2}}\bigg{(}\arctan\frac{w^{gt}}{ hs^{gt}}-\arctan\frac{w}{h}\bigg{)}*\frac{h}{w^{2}+h^{2}}\] (13)\[\frac{\partial\
u}{\partial t}=-\frac{8}{\pi^{2}}\bigg{(}\arctan\frac{w^{gt}}{hs^{ gt}}-\arctan\frac{w}{h}\bigg{)}*\frac{w}{w^{2}+h^{2}} \tag{14}\]  
It can be derived that \(\frac{\partial v}{\partial w}=-\frac{h}{w}\frac{\partial v}{\partial t}\), indicating that the gradients of \(w\) and \(h\) have opposite signs. Therefore, at any given time, if one of these two variables increases, the other will decrease. To tackle these issues, this paper designs a novel loss function, LIOU, which separates the aspect ratio factor between the predicted box and the ground truth box based on the penalty term in CIOU. It computes the width and length of both the predicted and ground truth boxes individually. Furthermore, to account for the orientation between the predicted boxes and ground truth boxes, an angle loss function is incorporated to prevent the predicted box from potentially \"wandering\" during the training phase. The calculation formula for LIOU is given by Equation (15).  
\[\begin{split} L_{LIOU}=1-IOU+L_{dis}+L_{asp}=1-IOU+\frac{\gamma}{ \gamma}+\frac{\big{(}w^{gt}-w\big{)}^{2}}{(c_{w})^{2}}+\frac{\big{(}h^{gt}-h \big{)}^{2}}{(c_{h})^{2}}\\ \gamma=2-e^{-\theta(\frac{y_{x}^{gt}-y_{y}}{c_{w}})^{2}}-e^{- \theta(\frac{y_{y}^{gt}-y_{y}}{c_{h}})^{2}}\\ \theta=2-sin2\alpha=2-\frac{2*\big{|}b_{x_{x}}^{gt}-b_{c_{x}}* \big{|}b_{xy}^{gt}-b_{cy}\big{|}}{\rho^{2}(b,bs^{gt})}\Big{(}0\leq\alpha\leq \frac{\pi}{4}\Big{)}\end{split} \tag{15}\]  
where IOU represents the overlap between the predicted and ground truth bounding boxes. The parameters \(h\), \(w\), \(c_{w}\), \(c_{h}\), \(w^{gt}\), and \(h^{gt}\) are illustrated in Figure 8. Here, \(h\) and \(w\) represent the height and width of the predicted box; \(\rho\big{(}b,bs^{gt}\big{)}\) represents the Euclidean distance between the centers of the predicted and ground truth boxes; \(c_{w}\) and \(c_{h}\) denote the dimensions of the smallest enclosing box formed by the predicted and ground truth boxes; and \(w^{gt}\) and \(h^{gt}\) represent the height and width of the ground truth box. \(\alpha\) represents the angle between the centerline connecting the predicted box and the ground truth box and the coordinate axes, \(\big{(}b_{c_{x}}^{gt},b_{cy}^{gt}\big{)}\) and \(\big{(}b_{c_{x}},b_{cy}\big{)}\) denote the center coordinates of the predicted boxes and ground truth box, respectively, and \(\theta\) represents the angle loss.  
As shown in Figure 9a, when the predicted box has the same aspect ratio as the ground truth box, LIOU can better reflect the difference between the two boxes. As the angle between the ground truth box center and the predicted box relative to the coordinate axis decreases, LIOU applies a greater penalty, as illustrated in Figure 9b. The LIOU loss function addresses the regression direction issue and simplifies the angle loss, thereby reducing the computational cost.  
Figure 8: Predicted box (yellow) and real box (blue).