## 2 Materials and Methodology
### Network Architecture of CCS-YOLOv8  
#### 2.2.1 Model of YOLOv8 Network  
The same design team that created YOLOv5 is also working on YOLOv8. Owing to YOLOv5's popularity, YOLOv8 adds further enhancements and functionality [25]. Figure 2 depicts the YOLOv8 network's design.  
Figure 1: Some annotated samples for livestock detection.  
Figure 2: Architecture of YOLOv8 network.  
In the preprocessing stage of the image, the input side scales the image to the 640 \(\times\) 640 resolution required by YOLOv8. In addition, YOLOv8 uses data augmentation techniques such as mosaics to enhance training effectiveness during training.  
The CSP architectural concept is carried over into the YOLOv8 backbone network [26]. Five down-samplings of the input characteristics allow for the acquisition of visual features at five distinct scales. In contrast to the C3 module [27] used in YOLOv5, YOLOv8 employs the C2f module. The traditional C3 module Dodule is limited to processing neighboring Bottleneck structures, resulting in extracted features that lack cross-layer information transfer. The C2f module introduces cross-layer feature transfer, eliminates the branching convolution, and adds more splitting operations by combining the architecture of the C3 and ELAN modules from YOLOv7 [28]. These modifications allow YOLOv8 to capture richer gradient flow information. The use of the SPPF module enhances YOLOv8's ability to identify small, obstructed, and fuzzy objects compared to the SPP module [29].  
YOLOv8's neck network combines the FPN [30] and PAN [31] architectures to provide multi-scale picture feature fusion. In contrast to earlier iterations, YOLOv8 eliminates convolutional structures from PAN-FPN during the sampling phase, guaranteeing the model's lightweight and effective operation. Up-sampling is done from top to bottom via the FPN structure, combining low-level detail information with high-level semantic characteristics. However, target location data are lacking if FPN is used alone. The PAN structure down-samples from the top to the bottom and integrates feature maps of different levels through convolutional layers in order to precisely maintain the target's spatial position information. Through the generation of complementing semantic and positional information, the both-direction fusion of FPN and PAN improves the accuracy of target recognition in pictures of different sizes.  
YOLOv8 adopts a decoupled head structure, meaning that each scale has an independent detector, and each detector is responsible for separately predicting the bounding box for that scale. The detector consists of a set of convolutional and fully connected layers, which are used to predict the bounding box for the corresponding scale. The convolutional and fully connected layers are employed for bounding box regression and target classification tasks. For the target classification task, the BCE loss is utilized, incorporating the asymmetric weighting scheme of VFL [32]. For bounding box regression, the BBox loss function is employed, which combines the CIoU with the DFL [33]. YOLOv8 introduces an anchor-free detection head--no longer relying on anchor boxes--thus providing greater flexibility to better adapt to various target shapes and sizes.  
Five models with varied sizes are available in YOLOv8 to achieve a balance between accuracy and speed in different environments. YOLOv8n is particularly well-suited for field applications due to its portability and simplicity compared to the other variants. Consequently, we selected YOLOv8n as our baseline model.