# FFG-YOLO: Improved YOLOv8 for Target Detection of Lightweight Unmanned Aerial Vehicles
## 3 Ffg-Yolo
### WDLoss Function  
In small-target detection, traditional loss functions, such as intersection over union (IoU), suffer from insufficient localization accuracy, especially when the target boundary is blurred or confused with the background. To solve this problem, the WDLoss function was used to optimize the target frame regression. This distance loss function was used based on the optimal transmission theory to accurately measure the difference between the predicted and real bounding boxes. With the center coordinates of box 1 (\(cx_{1}\), \(cy_{1}\)) and box 2 (\(cx_{2}\), \(cy_{2}\)) and the width and height (\(w_{n}\), \(h_{n}\)), WDLoss is calculated using the following equation:  
\[Loss_{Wasserstein}=(cx_{1}-cx_{2})^{2}+(cy_{1}-cy_{2})^{2}+\left(\frac{w_{1}- w_{2}}{2}\right)^{2}+\ \left(\frac{h_{1}-h_{2}}{2}\right)^{2} \tag{12}\]Unlike traditional IoU-based losses that treat bounding boxes purely as geometric shapes, the WDLoss function is used to model bounding boxes as 2D Gaussian distributions. A bounding box defined by its center coordinates \((x,y)\), width \((w)\), and height \((h)\) is precisely converted into a Gaussian distribution characterized by its mean and covariance matrix. The mean corresponds to the box's center, and the covariance matrix captures its spatial extent and orientation [30]. This probabilistic representation allows the application of the optimal transport (OT) theory, specifically the Wasserstein distance, to quantify the dissimilarity between a predicted bounding box (as a Gaussian) and its ground-truth counterpart (also as a Gaussian). The Wasserstein distance, also known as the Earth Mover's Distance (EMD), intuitively measures the minimum cost required to transform one probability distribution into another [31]. This cost inherently considers the overlap between the boxes and their geometric disparities between their centers and differences in their widths, heights, and even orientations (for rotated bounding boxes). For bounding boxes modeled as Gaussians, the minimum cost is calculated to move the predicted Gaussian distribution to perfectly align with the ground-truth Gaussian distribution. WDLoss is used to address limitations inherent in IoU loss, particularly in cases where predicted and ground-truth bounding boxes do not overlap. In such scenarios, IoU values drop to zero, resulting in vanishing gradients and providing no meaningful signal for adjusting network predictions. Although variants, such as generalized IoU (GIoU), introduce penalty terms to mitigate this issue, they often exhibit slow convergence or ambiguity in certain non-overlapping configurations [32]. In contrast, WDLoss offers continuous and non-zero gradients, even when bounding boxes are distant or entirely disjoint [30]. This characteristic enables stable, accelerated, and robust convergence during training by ensuring persistent gradient feedback. In complex scenarios involving rotated bounding boxes, where direct computation of differentiable IoU is infeasible, WDLoss facilitates a differentiable approximation aligned with final evaluation metrics, supporting effective and consistent learning [30]. Figure 4: GCAB module architecture (GCBlock: global context block; SCP: spatial context processing; and SCAM: spatial context awareness module). WDLoss's sensitivity to subtle geometric variations stems from its treatment of bounding boxes as complete spatial distributions rather than discrete shapes. This makes it particularly advantageous in detecting small objects or those with ambiguous boundaries [33], and its alignment with human perception of localization errors can lead to more intuitively accurate bounding box predictions [31]. By integrating positional features such as center distance, dimensions, and orientation into a unified, continuous metric, WDLoss provides a holistic measure of regression quality--especially in instances where overlap-based metrics fail to capture misalignment due to high intersection values.