## 3 Methods
### YOLOv11 Working Principle  
YOLO (You Only Look Once) is a single-stage object detection model that eliminates the need for separate steps for feature extraction, region proposal, and classification by combining them into one compact convolutional neural network (CNN). This makes YOLO highly efficient for many applications. YOLOv11 is an advanced version that integrates detection and segmentation in one framework. This project used YOLOv11n-seg (nano version), which is optimized for edge devices and lightweight hardware. Despite having fewer parameters, it provides an excellent balance between accuracy and speed [73; 74; 75]. The detection process includes the following steps:  
* The input image passes through convolutional layers to extract features. * The image is divided into a grid, where each cell predicts bounding boxes and class labels. * The model outputs the location (x, y, w, and h), class label (e.g., \"sharp\" or \"smooth\"), and confidence score. * The model also produces a pixel-wise mask for each detected object in the segmentation version. Each output prediction includes the following:  
* Bounding box coordinates. * Class label (e.g., sharp or smooth). * Segmentation mask. * Confidence score (e.g., 0.93). The model is trained using a composite loss function [76]:  
\[\text{TotalLoss}=\text{BoxLoss}+\text{ClassLoss}+\text{DFLLoss}+\text{SegmentationLoss},\]  
where:  
Figure 8: Roboflow-labeled samples: sharp (**top**) and smooth (**bottom**) materials. * BoxLoss: Bounding box regression loss. * ClassLoss: Classification loss (cross-entropy). * DFLLoss: Distribution focal loss for localization precision. * SegmentationLoss: Pixel-wise segmentation mask loss. All these loss components decreased steadily during training, as shown in Figures 9 and 10. The consistent downward trend of the box, class, segmentation, and DFL losses over 100 epochs indicates stable and practical learning. The model's inference time was approximately 4.9 ms per image, with preprocessing and postprocessing times of 0.5 ms and 1.3 ms, respectively. These figures make the model suitable for deployment in industrial settings. Model Analysis and Label Distribution  
A set of analytical visualizations was generated to thoroughly assess the YOLOv11n-seg model's classification performance and to understand the distribution of labeled objects within the dataset. These include confusion matrices (both raw and normalized), label distribution histograms, spatial density heatmaps, and a bounding box attribute correlogram. Figure 11 presents the raw confusion matrix that illustrates the model's classification performance across three categories: sharp, smooth, and background. Among 557 ground-truth sharp samples, 425 were correctly predicted as sharp, 127 background instances were misclassified as sharp, and five smooth objects were incorrectly labeled as sharp. The model achieved strong performance for the smooth class: it correctly identified most  
Figure 10: The evaluation metrics over 100 epochs for the bounding box (B) and mask (M) outputs in a multi-task detection and segmentation model. smooth samples with a dark diagonal cell, indicating high confidence. However, a small portion was misclassified. The background class appeared to be the most challenging as a significant portion of background instances (approximately 127) were incorrectly classified as sharp. This may be due to the visual similarity in texture or brightness between background noise and fine, sharp materials. Overall, the matrix reveals that, while the model performs strongly in distinguishing between sharp and smooth objects, it struggles more when dealing with background filtering, highlighting a potential direction for future model improvement. Figure 12 shows the normalized confusion matrix, providing a clearer understanding of class-wise accuracy and error proportions. The normalized values reveal that 92% of sharp samples and 89% of smooth samples were accurately classified.