## 3 Methodology
### DCW-YOLO Algorithm
#### 3.2.3 Improved Loss Function  
The YOLOv8 algorithm has introduced significant improvements in its network architecture's head, adopting a decoupled head architecture along with an anchor-free strategy. For the computation of the loss function, it covers two main parts: classification and regression losses. For the classification loss, the algorithm utilizes binary cross-entropy loss to quantify the error between predicted classes and actual classes. In terms of regression loss, the algorithm combines distribution focal loss and bounding box regression loss to enhance the accuracy of the location prediction. Overall, the loss function of YOLOv8 can be expressed as Equation (7). \[L=L_{box}+L_{cls}+L_{DFL} \tag{7}\]  
The distribution focal loss (DFL) aims to optimize the probabilities of two discrete points adjacent to the target label y, namely the left and right points, in the form of cross-entropy. With this strategy, the network is encouraged to quickly concentrate on the dispersion of the area around the goal site, thereby enhancing the accuracy of localization. The loss function's particular form is as follows; see Equation (8). \[DFL(S_{i},S_{i+1})=-((y_{i+1}-y)\log(S_{i})+(y-y_{i})\log(S_{i+1})) \tag{8}\]  
Subsequently, YOLOv8 adopts CIoU as the loss function for the bounding box regression, as shown in Equation (9). \[L_{CIoU}=1-IoU\ +\frac{\rho^{2}\left(b\,b^{st}\right)}{c^{2}}+\alpha\
u \tag{9}\]  
where, \(b\) and \(b^{st}\) are the centroids of the predicted and actual bounding boxes, respectively, \(\rho\) represents the Euclidean distance between the two points, \(c\) is the diagonal length of the smallest box that contains both the predicted and actual boxes, and \(\alpha\) stands for the weight coefficient; its expression is shown as follows. \[\alpha=\frac{\
u}{(1-IoU)+\
u} \tag{10}\]  
where \(IoU\) is defined as the ratio of the overlap between the predicted bounding box and the actual box to their union. \(\
u\) is a measure of the aspect ratio similarity, and it can be defined in the form of Equation (11). In the equation,  
Despite the effectiveness of \(CIoU\) loss in object detection, it still harbors certain limitations. First and foremost, \(CIoU\) loss does not account for balancing sample difficulties, which may result in the model being biased towards detecting easier samples, especially in scenarios with an abundance of small targets, at the expense of performance on more challenging samples. Secondly, \(CIoU\) utilizes the aspect ratio as a penalty in its loss calculation; nonetheless, if the actual and predicted bounding boxes match in aspect ratio yet diverge in their width and height, this penalty fails to accurately capture the actual size disparities between the boxes. Moreover, the \(CIoU\) equation incorporates inverse trigonometric functions, significantly raising the computational demand and arithmetic processing expense of the model, which may limit its efficiency in environments with restricted resources. In the specific scenario of detecting WTB damages from UAV imagery, the presence of a relatively high proportion of small target damage data makes the judicious design of the loss function crucial for enhancing the performance of object detection models. Furthermore, since there will always be some low-quality examples in the training data, placing too much emphasis on box regression for these samples could deteriorate the model's ability to generalize. Ideally, the objective function should reduce the gradient penalty for geometric measures in cases of considerable congruence between the anchor boxes and the actual ground truth boxes, thus helping the model to enhance its generalization capabilities. Given these considerations, this research adopts the dynamic non-monotonic focus mechanism of gradient gain allocation from \(WIoUv3\)[45], which allows the flexible adjustment of gradient gain allocation strategies at different stages of training.