## 4 Results
### Defect Detection Experiment
#### 4.1.2 Experimental Data and Analysis  
Take 1300 images from the collected images and feed them into the YOLOv6 network for training using a training set to validation set ratio of 8:2. The training parameters are shown in Table 4. Where, the learning rate refers to the step size of gradient descent for the loss function at each parameter update. Batch-size represents the number of images trained in one training session. The epoch represents the number of training sessions. The img-size indicates the training image size. Workers represents the number of CPU cores in the computer. Figures 10 and 11 depict the change in the loss function value and the change in the \(mAP\) verification after 1000 training times.  
Figure 10 illustrates that around the 700 th iteration, the loss function value of YOLOv6 starts to decline progressively and approaches convergence. In terms of validation mean Average Precision (\(mAP\)), when considering a confidence level larger than 0.5, the \(mAP\) is consistently maintained at approximately 0.9 during the initial 300 iterations. Similarly, when considering a confidence level of 0.5 to 0.95, the \(mAP\) remains at around 0.6 until approximately 600 iterations, as depicted in Figure 11. Figure 12 showcases the test results of the YOLOv6 algorithm after 440 additional images were captured following 1000 training iterations.  
Based on the results displayed in Figure 12, it is evident that the YOLOv6 algorithm effectively detects various surface defects, meeting the requirements for industrial detection. The experiment's mean Average Precision (\(mAP\)) is measured to be 0.911, which indicates compliance with industrial testing requirements.  
Table 5 provides a comparison of the results obtained from the most recent iterations of the YOLO algorithm series, namely YOLOv5, YOLOv6, and YOLOv7, in terms of their ability to identify surface defects on lock bodies. According to the table, the YOLOv6 algorithm demonstrates a significantly better average precision compared to the YOLOv5 algorithm. Furthermore, the average precision of YOLOv6 is nearly on par with that of the YOLOv7 algorithm. It is important to note that YOLOv6 achieves this higher precision while weighing substantially less than YOLOv7 in terms of model weight. High precision in defect detection is crucial as it reduces the chances of false detection and missed detections. By reducing the weight size of the inspection algorithm, YOLOv6 enables lightweight inspection in industrial production. This reduction in weight requirements translates to improved productivity, reduced equipment needs, and lower production costs. Therefore, YOLOv6 offers a favorable solution by combining accurate detection with reduced weight size. In addition, according to Table 5, the reasoning time of Yolov6 is better than that of the other two networks. Therefore, even if the training time is longer, it does not affect the superiority of Yolov6.  
Figure 11: \(mAP\) verification curve.  
Figure 12: Detection results of various surface defects: (**a**) bump damage, scratches and freckles; (**b**) freckles, scratches and bump damage; (**c**) bad stuff; (**d**) bad cover; (**e**) freckles and poor contraction; (**f**) poor cut.