# Implementing YOLO Convolutional Neural Network for Seed Size Detection
## 6 Results and Discussion  
To visualize the effects and assess the effectiveness of the created models, the results of segmentation and size detection of seeds in the images were presented (Figures 3-6). \begin{table}
\begin{tabular}{l l l l} \hline \hline
**Feature** & **YOLOv8\_n** & **YOLOv8\_s** & **YOLOv8\_m** \\ \hline Input size [pixels] & 640 \(\times\) 640 & 640 \(\times\) 640 & 640 \(\times\) 640 \\ \hline Number of training parameters [M] & 3.4 & 11.8 & 27.3 \\ \hline File size [MB] & 6.8 & 23.8 & 54.8 \\ \hline CPU inference time (ONNX) [ms] & 96.1 & 155.7 & 317.0 \\ \hline GPU A100 (TensorRT) inference time [ms] & \(1.21\) & 1.47 & 2.18 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The parameters of each trained model, such as their input size, number of parameters, and inference time. Figure 4: Segmentation results for coffee beans. Figure 3: Segmentation results for white bean seeds. Segmentation areas identified by the YOLO algorithm were overlaid on the images. Additionally, lines and points were used to mark the determined sizes of each seed. Textual information containing detailed data about the dimensions of each seed was placed next to them. This graphical presentation of results not only allowed for ongoing evaluation of the CNN models' performance but also served as an excellent way to visualize the outcomes. In the Supplementary Materials, the detection results are included, along with the calculated dimensions of the seeds, including width, height, and surface area for all test images. Measuring the accuracy of image segmentation is crucial for fully understanding the effectiveness of computer vision models. Metrics can be divided into two main categories: segment area metrics, which assess the overlap between the predicted and actual object areas, and classification metrics, which focus on the precision and completeness of the recognized areas. This approach allows for a comprehensive evaluation of segmentation quality, which is essential for further improving computer vision models. Since many practical applications of seed segmentation focus on determining individual dimensions and areas, metrics such as intersection over union (IoU), pixel accuracy, precision, recall, and F1-score were used. Intersection over union (IoU) is the ratio of the area of overlap between prediction A and the true object area B to the total area of both regions combined. The IoU value ranges from 0 to 1, with 1 indicating perfect overlap. It can be expressed using the Jaccard index [28]:  
Figure 5: Detection and segmentation of multiple coffee beans. \[\text{IOU}(A,B)=\text{JAC}(A,B)=\frac{|A\cap B|}{|A\cup B|} \tag{1}\]  
Pixel accuracy is the percentage of pixels that have been correctly classified by the model. While this metric is simple to implement and understand, it is not always the best measure, especially for imbalanced datasets where objects cover a small portion of the image. Pixel accuracy can be expressed as:  
\[\text{PA}=\frac{\sum_{j=1}^{k}n_{jj}}{\sum_{j=1}^{k}t_{j}} \tag{2}\]  
where \(n_{jj}\) represents the number of pixels correctly classified for class \(j\), and \(t_{j}\) is the total number of pixels belonging to class \(j\) in the ground truth. The summation is performed over all classes \(k\), from \(j=1\) to \(j=k\). Precision measures how many of the segments in an image have been correctly detected and classified (i.e., their IoU is above a certain threshold, typically IoU > 0.5). It is the ratio of true positive cases to the sum of true positive and false positive cases. Precision is expressed as:  
Figure 6: Detection and segmentation of multiple white bean seeds. \[\text{precision}=\frac{TP}{TP+FP} \tag{3}\]  
where _TP_ (true positives) denotes the number of correctly identified positive cases. _FP_ (false positives) represents the number of negative cases incorrectly identified as positive. Recall is the ratio of true positive cases to the sum of true positive and false negative cases. It measures the model's ability to detect all positive cases.