## 2 Materials and Methods
### Neural Network Training  
The second stage begins with the implementation and configuration of parameters in the YOLOv8 (You Only Look Once version 8) neural model, which was downloaded from the official Ultralytics website for inclusion in the neural network training. It offers essentially two types of image recognition techniques: image segmentation and object detection. The model introduces new features comparable to the previous models, like YOLOv5 (You Only Look Once version 5), which had good performance and improved hyperparameter optimization to set up the neural network, but instead, the YOLOv8 model introduced new features to the model, which also improves the performance, flexibility, and efficiency in computer vision AI (artificial intelligence) tasks. The purpose of using this model implies that individual objects can be precisely and accurately identified in an image and segmented from the rest of the image to outline or contour the image appropriately to its shape and then rigorously match the contour of the identified object. Run instance segmentation with the Ultralytics YOLOv8 model (software specialized in computer vision) requires training in Python (programming language) to be able to generate an artificial neuron which executes the predictions in the images of the manufacturing cell of PCBs, in order to be able to make inferences about the results that we obtain through the system of artificial vision that will be collecting the information about the manufacturing process of the printed circuit boards. We conducted multiple neural network training sessions with different YOLOv8 models and found that the YOLOv8n-seg [31; 32] model produced the best results (see Table 2). Compared to other pre-trained models used for instance segmentation, YOLOv8n-seg excelled in identifying the locations and exact shapes of objects in an image. The configuration of the model is implemented using a Python script made from the Google Colab platform (platform for developing Python code from the web browser) to which the OpenCV libraries were imported (Artificial Intelligence Library). For image processing and computer vision of the manufacturing cell, hyperparameters were configured (adjusting weights and network connections), with which the neural network will be trained in such a way that the training has a high rate of effectiveness. The parameters considered in the configuration of the YOLOv8n-seg model are listed below:  
1. Lr0: The initial learning rate for the optimizer. 2. Adj. Factor: Parameter used to adjust the model. 3. Total Img: The total number of images used in the dataset. 4. Imgsz: The size of the images used for training and testing. 5. Data: The file path to the YAML file that contains dataset information. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Model** & **Size (Pixels)** & **mAP\({}^{\text{box}}\)s\({}^{\text{SSSS}}\)** & **mAP\({}^{\text{mask}}\)s\({}^{\text{SSSS}}\)** & **Speed\({}^{\text{CPU}}\)ONNX** & **Speed\({}^{\text{A100}}\)TensorRT** & **Params (M)** & **FLOPs (B)** \\  & & & & **(ms)** & **(ms)** & **Params (M)** & **FLOPs (B)** \\ \hline YOLOv8n-seg * & 640 & 36.7 & 30.5 & 96.10 & 1.21 & 3.40 & 12.6 \\ YOLOv8n-seg & 640 & 44.6 & 36.8 & 155.7 & 1.47 & 11.8 & 42.60 \\ YOLOv8n-seg & 640 & 49.9 & 40.8 & 317.0 & 2.18 & 27.3 & 110.2 \\ YOLOv8l-seg & 640 & 52.3 & 42.6 & 572.4 & 2.79 & 46.0 & 220.5 \\ YOLOv8x-seg & 640 & 53.4 & 43.4 & 712.1 & 4.02 & 71.8 & 344.1 \\ \hline \hline \end{tabular}
* See: [[https://docs.ultralytics.com/tasks/segment](https://docs.ultralytics.com/tasks/segment)]([https://docs.ultralytics.com/tasks/segment](https://docs.ultralytics.com/tasks/segment)) (accessed on 10 June 2024).  
\end{table} 
Table 2: List of pre-trained models YOLOv8x-seg. Batch size: The number of images processed together in one iteration. * Epochs: The number of epochs and complete passes through the entire training dataset. * Optimizer: The optimization algorithm used to minimize the loss function and update the model parameters.