## 2 Materials and Methods
### Standard YOLOv8 Model  
In January 2023, YOLOv8 was launched by Ultralytics, the company responsible for developing YOLOv5. YOLOv8 provides five scaled versions, including YOLOv8n,  
Figure 3: Cotton bell size distribution of the dataset.  
Figure 2: Dataset amplification methods: (**a**) Raw image, (**b**) Brightness adjustment, (**c**) Noise increase, (**d**) CutOut enhancement, (**e**) Rotation by 30 degrees, (**f**) Rotation by 60 degrees, (**g**) Cropping, (**h**) Translation, (**i**) Mirroring.  
YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x, which support a variety of visual tasks such as object detection, segmentation, pose estimation, tracking, and classification.  
Figure 4 illustrates the detailed architecture of YOLOv8. It employs a backbone similar to YOLOv5 but with modifications on the CSPLayer, now referred to as the C2\(f\) module. The C2\(f\) module (Cross Stage Partial Bottleneck with two convolutions) integrates high-level features with contextual information to enhance detection precision. YOLOv8 utilizes an anchor-free model and a decoupled head to independently handle object detection, classification, and regression tasks. This design enables each branch to focus on its specific function, thus enhancing overall model accuracy. In YOLOv8's output layer, a sigmoid function serves as the activation for object scores, indicating the likelihood that a bounding box contains an object, while a softmax function represents the likelihoods of belonging to each possible class.  
YOLOv8 employs CioU and DFL for bounding box loss and binary cross-entropy for classification loss. These loss functions enhance target detection performance, particularly when addressing smaller objects. YOLOv8 also introduces a semantic segmentation model, named YOLOv8-Seg. Its backbone is the CSPDarknet53 feature extractor, followed by the C2\(f\) module in place of the traditional YOLO neck architecture. Following the C2\(f\) module, two segmentation heads are configured to learn to predict semantic segmentation masks of the input images. The model includes a detection head similar to YOLOv8, comprising five detection modules and a prediction layer. The YOLOv8-Seg model delivers state-of-the-art results on various object detection and semantic segmentation benchmarks, all while maintaining high speed and efficiency.  
YOLOv8 can be operated from a command-line interface (CLI) or installed as a PIP package. Additionally, it incorporates multiple integrated features for labeling, training, and deployment. When evaluated on the MS COCO dataset test-dev 2017, YOLOv8x recorded an _AP_ of 53.9% at an image size of 640 pixels (compared to YOLOv5's _AP_ of 50.7% at the same input size), achieving a speed of 280 FPS on NVIDIA A100 and TensorRT.  
When applying the YOLO algorithm for cotton bolt detection in complex environments, the limited hardware capabilities of mobile devices must be taken into account. The YOLOv8x algorithm, although it offers the best detection performance, is not feasible due to its high demands on real-time processing in complex settings. Consequently, this paper adopts the minimal weight model of YOLOv8n. However, several issues emerge with YOLOv8n in practical detection processes. First, YOLOv8n employs a large number  
Figure 4: Standard YOLOv8 model structure.  
of standard convolutions and _C2f_ modules, which enhance the model's accuracy but simultaneously reduce its operational speed and increase the model's parameters. Second, the scene in cotton boll detection changes rapidly, necessitating sufficient detection accuracy. However, YOLOv8n is not ideal for processing cotton boll detection, as it is prone to false positives and missed detections. The algorithm particularly struggles with objects that undergo significant scale changes. Since YOLOv8 divides the input image into smaller grids, with each grid predicting only one object, this configuration makes it challenging to handle objects that vary greatly in size.