# Implementing YOLO Convolutional Neural Network for Seed Size Detection
## 6 Results and Discussion
Recall is expressed as:  
\[\text{recall}=\frac{TP}{TP+FN} \tag{4}\]  
where _FN_ (false negatives) is the number of cases that are positive but have been incorrectly identified as negative by the model. The F1-Score is the harmonic mean of precision and recall. It offers a balance between these two metrics and is particularly useful in the case of imbalanced classes. \[\text{F1-Score}=2\times\frac{\text{precision}\times\text{recall}}{\text{ precision}+\text{recall}} \tag{5}\]  
In the context of detecting object sizes, there is a significant need to evaluate the effectiveness of models beyond traditional segmentation metrics. The actual sizes of objects allow for precise comparison of the results of a CNN-based model with the real parameters of the objects. These metrics demonstrate how well the detected sizes, based on model predictions, reflect the actual sizes. In practice, having information about the actual sizes of objects enables the construction of precise evaluation criteria, which in turn allows for model adaptation to the specifics of the analyzed task. Commonly used accuracy measures for detected sizes include the mean size error, mean relative size error, and mean area error, which measure the differences between the actual and predicted dimensions or surface areas of objects. Relative error is a metric that measures the average relative difference between the actual and predicted size of an object. Unlike absolute error, relative error is calculated proportionally to the actual size of the object. The lower the error value, the better the object sizes are detected. Area error is the average difference between the actual and predicted area of an object. This metric is useful for evaluating the effectiveness of a model, particularly in cases where determining the areas of detected elements in images is important. Table 2 presents detailed results of the model that achieved the highest precision in size detection--YOLOv8_n--for a test set consisting of 50 images. Segmentation metrics and size detection metrics are presented for each individual seed class, as well as aggregated for the entire test set. These results provide a comprehensive understanding of the model's effectiveness in identifying seed sizes of varying dimensions. The values 50 and 75 correspond to the threshold values of 0.5 and 0.75 for IoU, respectively. If the intersection of the actual and detected object is at least 0.75 or 0.5, it is considered detected; otherwise, it is considered undetected. This method was used to calculate values for precision, recall, and other related metrics. The analysis of the presented results shows that the YOLO method achieved excellent outcomes in identifying and segmenting coffee and white bean seeds. The pixel accuracy for each category exceeds 99.9%, which is an outstanding result. The mean intersection over union (IoU), a key indicator for assessing segmentation quality, ranges from 88.2% for coffee to 92.1% for white beans, indicating high precision in separating the background from the object. Precision and recall for thresholds of 50% and 75% remain very high, around 97% or higher, demonstrating the model's effectiveness in identifying and classifying seeds. The mean relative error, which is less than 5% in the worst case, and the mean dimensional errors in millimeters, which are below 1 mm, indicate the model's high accuracy in determining seed sizes. This level of accuracy is more than sufficient for practical applications, such as seed sorting. Considering these results, the outcomes are sufficiently robust to apply the YOLO method to seed segmentation in practice. Not only do they confirm the effectiveness of the YOLOv8 model in accurately detecting and locating seeds in images, but they also pave the way for using this technology in industrial applications, where fast and efficient image analysis is crucial. Such automation can significantly speed up and increase the efficiency of the seed sorting process.