## 3 Materials and Methods
### You Only Look Once Version 8  
YOLOv8 is a state-of-the-art CNN model for object detection, segmentation, and classification. It is easily accessible online, making it a great option for those looking to develop machine learning algorithms without extensive programming expertise. Table 2 provides an overview of the available YOLOv8 variants for project development detailing input image sizes (in pixels), the number of used parameters (in millions), and floating-point operations per second (FLOPs), which indicates the computational requirements. YOLOv8 offers several model sizes: nano (n), small (s), medium (m), large (l), and extra-large (xl) [35]. The training time varies significantly across these variants, with the nano version taking as little as 10 min to train, while the extra-large version may take several hours. For our experiment, we selected the best-performing model variant based on the shortest time when two or more models showed similar performance.  
The YOLOv8 network architecture consists of three main components called backbone, neck, and head, as illustrated in Figure 2. The precision of the YOLOv8 model is significantly enhanced by its anchor-free design and decoupled head, which allows for independent processing of objectness, classification, and regression tasks. The softmax function is used to define the likelihood of an object belonging to each possible class [36]. YOLOv8 employs CIoU [37] and DFL [38] loss functions for bounding-box loss, along with binary cross-entropy for classification loss, which together improve detection performance. More detailed information about these components can be found in [39], and we also discussed them in our previous work on diabetic retinopathy [30]. To perform the classification task, YOLOv8 extracts rich features from the input image \(I\), as defined by Equation (2), by applying a series of convolutions described in Equation (3). The backbone adopts residual blocks to learn deeper image attributes, as specified in Equation (4) [39].  
\[\text{I}\varepsilon\Re^{\text{H}\times\text{W}\times 3}, \tag{2}\]  
where H and W are the height and width of the input image [39].  
\[\text{Conv}(I,\text{ K},\text{ s},\text{ p})=\text{ReLU}(\text{BatchNorm}(\text{I}* \text{K})), \tag{3}\]  
where K is the convolutional kernel, s is the stride, p is the padding, * indicates the convolution operation, and BatchNorm defines the batch normalization [39].  
\[\text{Res}(\text{X})=\text{X}+\text{Conv}(\text{Conv}(\text{X},\text{K}_{1}, \text{ s}_{1},\text{ p}_{1}),\text{K}_{2},\text{ s}_{2},\text{ p}_{2}), \tag{4}\]  
where X is the input of the residual block, and K\({}_{1}\) and K\({}_{2}\) are the kernels of the convolutional layers within the block [39].  
To accurately predict the class of an object, the head calculates the probabilities of that object to be part of a defined class according to Equation (5) [39] as follows:  
\[\text{B}=\left(\sigma(\text{t}_{\text{x}})+\text{c}_{\text{x}},\sigma(\text{ t}_{\text{y}})+\text{c}_{\text{y}},\text{e}^{\text{t}_{\text{w}}}\cdot\text{p}_{ \text{w}},\text{e}^{\text{t}_{\text{h}}}\cdot\text{p}_{\text{h}}\right)\,, \tag{5}\]  
where (c\({}_{\text{x}}\), c\({}_{\text{y}}\)) is the center of the anchor box; (p\({}_{\text{w}}\), p\({}_{\text{h}}\)) are the dimensions of the anchor box; and t\({}_{\text{x}}\), t\({}_{\text{y}}\), t\({}_{\text{w}}\), and t\({}_{\text{h}}\) are the predicted offsets.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Model** & **Size (Pixels)** & **Parameters (Million)** & **FLOPs (B)** \\ \hline YOLOv8-n & 640 & 3.4 & 12.6 \\ YOLOv8-s & 640 & 11.8 & 42.6 \\ YOLOv8-m & 640 & 27.3 & 110.2 \\ YOLOv8-l & 640 & 46.0 & 220.5 \\ YOLOv8-xl & 640 & 71.8 & 344.1 \\ \hline \hline \end{tabular}
\end{table}
Table 2: YOLO version 8 model variants parameters.