## 4 Results and Discussion
### Transfer Learning Process from a Pre-Trained YOLOv5s to a Fine-Tuned YOLOv5s  
The pre-training result empowered the YOLOv5s model to extract and distinguish image-based features, resulting in the ability to identify specific objects. The network weights obtained from pre-training were also general for the processing of data not involved in training, but did not necessarily achieve acceptable performance, especially in cases like arc magnet images that differ significantly from the object images used for pre-training. Although retraining the pre-trained model with a large number of arc magnet images was highly beneficial for improving the surface defect identification performance, our dataset was limited and relatively small. Therefore, in our study, transfer learning was exploited to retain those parts of the network in the pre-trained model that were suitable for processing arc magnet images and to adapt the others to be more conducive to perceiving \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **TNNP (M)** & **FLOPS (G)** & **MS (MB)** & **[EMAIL_ADDRESS] (\%)** \\ \hline YOLOv3-tiny & 8.849 & 13.201 & 33.873 & 16.000 \\ YOLOv4-tiny & 6.057 & 6.945 & 23.150 & 21.500 \\ YOLOv5s & 7.277 & 7.208 & 27.899 & 35.600 \\ YOLOx-nano & 0.912 & 1.079 & 3.666 & 27.400 \\ YOLOv6-nano & 4.300 & 4.700 & 17.684 & 30.800 \\ YOLOv7-tiny & 6.227 & 5.800 & 23.879 & 36.800 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Performance comparison of different pre-trained models for the same dataset. and distinguishing the image-based features of the surface defects through the training of small samples. Our strategy for transfer learning was model-based and contained two aspects. The first was to freeze the partial layers from the backbone network in the already trained YOLOv5s; they were available for extracting the image-based features of arc magnets. The second was to fine-tune the remaining layers of YOLOv5s under small-sample training to improve the accuracy of the model in extracting and discriminating image-based features of the surface defects. Since the three CSP1-Xs in the backbone network of YOLOv5s are the most crucial feature extraction modules, we used them as references to divide the backbone network into three frozen regions, each of which referred to the corresponding CSP1-X and all layers before it. In parallel, we treated the maximum [EMAIL_ADDRESS] and the minimum training loss as the basis for judging the optimal effect of fine-tuning all network layers outside the frozen region. As a result, comparing the effects of fine-tuning in different freezing cases enabled us to determine the most suitable transfer from a pre-trained model for the COCO2017 dataset to a highly accurate identification model for our dataset. The effects of the [EMAIL_ADDRESS] and training loss formed by different combinations of freezing and fine-tuning are depicted in Figure 5a,b. As can be seen, freezing with fewer layers gave better results after fine-tuning. The maximum [EMAIL_ADDRESS] (0.999 at the 72 nd epoch) and the minimum training loss (0.018 at the 268 th epoch) always appeared in the fine-tuning result when freezing the network layers up to the first CSP1-X (namely, CSP1-1). In contrast, the worst [EMAIL_ADDRESS] and training loss occurred in the fine-tuning result without any frozen layer. Thus, freezing the first CSP1-X module and its preceding layers, which is the approach that we adopted in our proposed framework, proved to be the most reasonable way to freeze layers. To further illustrate the fine-tuning effect, we used the visualization for the output of the second CSP1-X (namely, the CSP1-3 closest to the CSP1-1) in the backbone network as an example to observe the improvement in the feature extraction. As seen in Figure 5c, for the same image, the outputs of extracted features from the layer in the frozen and fine-tuned model, which was also regarded as the transferred model, were superior to those of the un-frozen and un-tuned ones.