## 2 Materials and Methods
### Cotton-YOLO Structure
#### 2.3.4 Improved Loss Function  
In real farmland environments, the proportion of small objects in cotton bolt detection tasks is considerably high. A well-designed loss function can significantly enhance the  
Figure 10: The gather-and-distribute structure. (**a**) Low-GD. (**b**) High-GD. (**c**) Information injection module. model's detection performance. YOLOv8 uses DFL and _CloU_ to calculate the regression loss of the bounding boxes; however, _CloU_ has the following drawbacks. First, _CloU_ does not account for the balance between hard and easy samples. Second, _CloU_ uses the aspect ratio as one of the penalties in the loss function. If the aspect ratios of the actual and predicted boxes are identical but the values of width and height differ, the penalty cannot accurately reflect the true difference between the two boxes. Third, the calculation of _CloU_ involves an arctangent function, increasing the computational burden on the model. The _CloU_ calculation formula is presented in Equation (19):  
\[L_{CloU}=1-IoU+\frac{\rho^{2}\big{(}b,b^{gt}\big{)}}{\left(c_{\omega}\right)^{ 2}+\left(c_{h}\right)^{2}}+\frac{4}{\pi^{2}}\left(tan^{-1}\frac{\omega^{gt}}{ h^{gt}}-tan^{-1}\frac{\omega}{h}\right) \tag{19}\]  
In Equation (19), the intersection over union (_IoU_) is defined as the ratio of intersection to union between the predicted box and the actual box. Parameters referenced in Equation (19) are depicted in Figure 11. Here, \(\rho\big{(}b,b^{gt}\big{)}\) denotes the Euclidean distance between the centroids of the true box and the predicted box; \(h\) and \(\omega\) denote the height and the predicted values, respectively; \(h^{gt}\) and \(\omega^{gt}\) represent the height and width of the true box; and \(c_{h}\) and \(c_{\omega}\), denote the height and width of the minimum enclosing box that includes both the predicted box and the actual box. _EloU_[25] advances beyond _CloU_ by incorporating the length and width as penalty terms, thus addressing the differences in width and height between the actual box and the predicted box, thereby offering a more rational penalty than those employed in _CloU_. The formula for calculating _EloU_ is presented in Equation (20):  
\[L_{EloU}=1-IoU+\frac{\rho^{2}\big{(}b,b^{gt}\big{)}}{\left(c_{\omega}\right)^{ 2}+\left(c_{h}\right)^{2}}+\frac{\rho^{2}\big{(}\omega,\omega^{gt}\big{)}}{ \left(c_{\omega}\right)^{2}}+\frac{\rho^{2}\big{(}h,h^{gt}\big{)}}{\left(c_{h} \right)^{2}} \tag{20}\]  
Parameters relevant to Equation (20) are illustrated in Figure 11; \(\rho\big{(}\omega,\omega^{gt}\big{)}\) and \(\rho\big{(}h,h^{gt}\big{)}\) denote the Euclidean distances in width and height, respectively, between the true box and the predicted box; and \(\left(b_{c_{x}},b_{c_{y}}\right)\) and \(\left(b_{c_{y}}^{gt},b_{c_{y}}^{gt}\right)\) indicate the coordinates of the center points of the actual box and the predicted box, respectively. _SloU_[26] incorporates the angle between the predicted box and the actual box as a penalty factor for the first time. Initially, the relationship between the angle size \(\theta\) and parameter \(\alpha\), as shown in Figure 11, causes the predicted box to rapidly align with the nearest axis before regressing towards the actual box. _SloU_ constrains the degrees of freedom in regression, thereby accelerating the model's convergence. The mainstream loss functions previously discussed utilize a static focusing mechanism. In contrast, _WloU_ not only takes into account area, centroid distance, and overlapping area  
Figure 11: Diagram of the _IoU_ principle. but also introduces a dynamic non-monotonic focusing mechanism. _WIoU_ employs a reasonable gradient gain distribution strategy to evaluate the quality of anchor boxes. [PERSON] et al. introduced three variants of _WIoU_. _WIoU_\(v1\) utilizes an attention-based prediction box damage design, while _WIoU_\(v2\) and _WIoU_\(v3\) incorporate focusing coefficients. _WIoU_\(v1\) employs distance as a metric for attention.