# Evaluating the FLUX.1 Synthetic Data on YOLOv9 for AI-Powered Poultry Farming
## 3 Materials and Methods
### Evaluation Metrics
CIoU loss is designed to address all three limitations of IoU by integrating the overlap, distance, and aspect ratio into a single loss function [61]:  
\[L_{CIoU}=1-IoU+\frac{\rho^{2}(b_{p},b_{g})}{c^{2}}+\alpha\upsilon \tag{6}\]  
where \(IoU\) represents the Intersection over Union between predicted and ground truth bounding boxes; \(\rho^{2}(b_{p},b_{g})\) is the squared Euclidean distance between the center points of the predicted box \(b_{p}\) and ground truth box \(b_{g}\); \(c\) denotes the diagonal length of the smallest enclosing box covering both \(b_{p}\) and \(b_{g}\); \(v\) is an aspect ratio consistency term that penalizes mismatches in the shape of the bounding boxes; and \(\alpha\) is a dynamic weighting factor that balances the contribution of the aspect ratio term. The aspect ratio penalty term \(v\) is defined as  
\[v=\frac{4}{\pi^{2}}\bigg{(}\arctan\frac{w_{g}}{h_{g}}-\arctan\frac{w_{p}}{h_{p} }\bigg{)}^{2} \tag{7}\]  
where \(w_{g},h_{g}\) and \(w_{p},h_{p}\) are the widths and heights of the ground truth and predicted boxes, respectively. By combining the IoU, distance, and shape constraints, CIoU improves gradient flow and stabilizes training. This allows YOLOv9 to handle objects of varying sizes and shapes more effectively, especially in cluttered scenes. YOLOv9 predicts an objectness score for each grid cell to determine whether it contains an object. Instead of using Softmax for multi-class classification, YOLOv9 applies BCE loss independently to each class [61]:  
\[L_{\text{BCE}}=-y\log(p)-(1-y)\log(1-p) \tag{8}\]  
where \(y\) is the ground truth label (1 for objects, 0 for background); and \(p\) is the predicted probability of an object. BCE enables multi-label classification, allowing objects to belong to multiple classes. It suits one-stage detectors, handling multiple objects per grid cell. Additionally, it ensures stable gradient flow, preventing vanishing gradients. Standard object detection models often suffer from class imbalance, where easily classified background regions dominate training, leading to poor performance on objects that are harder to classify. YOLOv9 addresses this issue by using focal loss, which modifies standard BCE loss by reducing the weight of well-classified examples and focusing on harder cases. The formula for general focal loss is [62]  
\[L_{\text{Focal}}=-\alpha(1-p_{t})^{\gamma}\log(p_{t}) \tag{9}\]  
where \(p_{t}\) is the predicted probability for the correct class; \(\alpha\) is a weighting factor to balance class distribution; and \(\gamma\) (typically set to 2) controls the down-weighting of well-classified examples. Several advanced loss functions, such as Alpha-IoU [65], EIoU [66], Deep-EIoU [67], SloU [68], etc., have been proposed to enhance object detection accuracy. Many deep learning object detectors, including YOLO models, are actively exploring hybrid IoU metrics that dynamically adapt during training. Additionally, recent approaches integrate transformer-based attention mechanisms to refine bounding box positioning beyond traditional IoU calculations [12]. Another important metric for evaluating model quality is accuracy. The accuracy of YOLOv9-e was assessed using the mean average precision (mAP) metric across 50 real images, evenly distributed by size and identical across all experimental setups, ensuring a consistent basis for comparison. The training was conducted for 100 epochs, after which mAP showed no significant improvement, indicating that it had plateaued with the given dataset and model. The mean average precision is a key metric for evaluating the performance of object detection models such as YOLO. It provides a comprehensive assessment by integrating several key performance indicators. To calculate mAP, it is important to define the following values: True Positives (TP)--correctly identified objects;False Positives (FP)--incorrectly identified objects; and False Negatives (FN)--missed objects that were not identified.