## 3 YOLO v3 Algorithm Optimization
### Loss Function Optimization  
A regression bounding box is a key step in target detection and target tracking in computer vision. Traditional methods mainly improve network performance by deepening the number of layers in the backbone network and optimizing local feature extraction methods, but they often ignore the optimization of loss functions. Intersection Over Union (IOU) is a measure of overlap area, which indicates the degree of overlap between the target window generated by the model and the original labeled window [11]. It is not sensitive to the changes of scales and non-negative, and it is a common evaluation standard in target detection, also known as detection accuracy. The value of IOU is the ratio of the intersection between the detection result, the ground truth, and the union between them. The calculation diagram is shown in Figure 4.  
Evaluation indicators for bounding box regression:  
\[IOU=\frac{\left|B\cap B^{st}\right|}{\left|B\cup B^{st}\right|} \tag{1}\]  
Figure 4: Intersection Over Union (IOU) Calculation. where \(B^{gt}=(x^{gt},y^{gt},w^{gt},h^{gt})\) is the real box and \(B\)= (\(x,y,w,h\)) is the prediction box. Usually, the distance between the bounding boxes is measured by the coordinates of \(B\) and \(B^{gt}\) using the \(l_{n}\)-norm (n = 1 or 2) loss function. In recent years, IOU loss is usually used to improve the IOU index. The expression of IOU loss is listed as followed:  
\[L_{IOU}=1-\frac{\left|B\cap B^{gt}\right|}{\left|B\cup B^{gt}\right|} \tag{2}\]  
It can be seen that when the two frames do not intersect, that is, the IOU is equal to zero, which is equivalent to the loss function having no effect and cannot be learned and trained, for that, theIOU loss is only applicable to the case where the target frame overlaps. In the cases of different distances, different scales, and different aspect ratios, as IOU is used to optimize the loss function, the regression situation is often incomplete. For the case where the target boxes do not overlap, in order to optimize the IOU loss function and solve the positioning and other problems, the DIOU measurement parameters are introduced [20]. When the target box and the prediction box do not overlap, there will be a loss. The centering distance can make the prediction frame to move toward the target. The DIOU loss can directly minimize the distance between the two boxes, it means that by combining the standardized distance between the prediction box and the target box can directly minimize the normalized distance between the anchor box and the target box, for that, the loss convergence is more accurate and faster than that of the IOU. DIOU loss is mainly based on IOU loss plus a constraint term and DIOU loss is shown in Equation (3). Among this, \(b\) and \(b^{gt}\) represent the center points of the prediction frame and the real frame, respectively, \(\rho\) represents the calculation of the Euclidean distance between the two center points. The calculation result is the value of \(d\) in Figure 5, and \(c\) represents the diagonal distance between the smallest closed area that can contain both the prediction box and the real box. \[L_{DIOU}=1-\frac{\left|B\cap B^{gt}\right|}{\left|B\cup B^{gt}\right|}+\frac{ \rho^{2}(b,b^{gt})}{c^{2}} \tag{3}\]  
The DIOU loss can provide a moving direction for the bounding boxes when the target boxes do not overlap, which can directly minimize the distance between the two target boxes. At the same time, the regression convergence speed of DIOU loss is very fast, which solves the problem of IOU loss. In network training, DIOU loss is added to the network loss function. The value of the loss function gradually decreases with the number of iterations and the degree of overlap increases. It can effectively solve the problems of inaccurate positioning of YOLOv3. L2 regularization is used to enhance the generalization of the network to prevent the over-fitting problem, as Equation (4) shows. Where \(\beta\) is  
Figure 5: Boundary Box Regression Diagram.