# Implementing YOLO Convolutional Neural Network for Seed Size Detection
## 5 Methods
The greater the number of layers, the more complex and capable the model is of representing intricate objects, but it also demands more computational resources. The choice of a specific variant depends on the application specifics, available hardware resources, and object detection performance requirements. The training process for the three YOLOv8 models was conducted using the prepared training dataset. The images were resized to 640 \(\times\) 640 pixels using linear interpolation. To achieve better results, pre-trained YOLOv8 segmentation models, available from the common objects in context (COCO) dataset, were utilized. In the YOLOv8 network, the training parameters were set as follows: The batch size was 16, and the number of epochs was set to 100. The patience parameter was 10, indicating the number of epochs to wait without improvement before early stopping. The optimizer was set to auto, which defaulted to AdamW. The image size was specified as 640 \(\times\) 640, which was the target dimension for resizing training images. The initial learning rate was 0.01. Momentum, used with certain optimizers to influence updates, was set at 0.937. Weight decay (L2 regularization) was set at 0.0005 to avoid overfitting. Mosaic data augmentation was disabled in the last 10 epochs. Warmup epochs were set at 3.0, meaning the learning rate gradually increased from a lower base. Warmup momentum was set at 0.8, adjusting the momentum during the warmup phase. The warmup bias learning rate was 0.1, indicating a special learning rate for bias parameters during the warmup phase. The training utilized the BCE (binary cross-entropy) loss function. The training was stopped when the loss function value reached 0.41. Each of the pre-trained models, varying in size from n to m, was appropriately loaded and then fine-tuned through transfer learning on the dataset tailored to the research project needs. Upon completion of the training process, the weights of all models were saved, and the training progress was documented. The saved model weights are available for future use in ongoing research on seed size detection. Table 1 details each of the trained models, including their input size, number of parameters, and inference time. To determine the physical dimensions of the seeds, image analysis techniques were employed. Using the YOLO algorithm to identify the seeds, the central point of each designated seed area was determined. Then, the longest axis passing through this central point, lying within the seed area, was identified. Once this axis was found, the points where it intersected the edges of the area were determined. The distance between these points defines the height of the seed. Next, a perpendicular axis to this longest axis was drawn through the center of the seed. The points where this perpendicular axis intersected the edges of the seed area were also identified, allowing the calculation of its width. Using the YOLO algorithm for seed identification, the area of each designated seed region was calculated in pixels. To convert these values into actual physical dimensions, a reference element, a 1 PLN coin, was used, which appeared in each image. The diameter of the coin, d = 23 mm, and its area were measured. Knowing the actual dimensions of the coin and the number of pixels it occupied in the image, it was possible to convert the seed area into square millimeters and determine the height and width of the seed in millimeters. In this way, the actual surface area, width, and length dimensions of the seeds were determined.