## 4 Experiment and Results
### Results  
#### 4.3.1 Stage 1: Defect Detection  
This study constructed a binary classification model for defect detection in stage 1, utilizing the transfer learning technique to classify defects in steel images. ResNet-50, ResNet-101, and ResNet-152, all pre-trained on the ImageNet database, served as base models for comparative experiments to ensure consistent defect distribution with the original dataset. Table 4 displays the hyperparameters for each model used in the experiments.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Model Number** & **Base Model** & **Description** \\ \hline
1 & ResNet-50 & batch\_size = 32, lr = 0.0001 \\
2 & ResNet-101 & batch\_size = 16, lr = 0.0001 \\
3 & ResNet-152 & batch\_size = 20, lr = 0.0001 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Hyperparameters of defect detection models.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Description** \\ \hline CPU & Intel core i7 \\ \hline Ram & 32 GB \\ \hline Graphics Card & NVIDIA L4 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Description of parameters.  
Figure 8 presents the training and validation loss curves over 30 epochs for model1, one of the three binary classification models referenced in Table 4. For the loss function, BCELoss was employed as the loss function in addressing the binary classification task, and the model weights were updated using the Adam optimizer with a learning rate of 0.0001. A StepLR scheduler reduced the learning rate by 0.2 every 10 epochs. The batch size varied between 16 and 32 during experiments, although this change did not significantly impact results. The training loss curve of model1 quickly declined in the initial 10 epochs, then stabilized and converged to nearly zero. The validation loss curve also showed a consistent decrease, indicating effective performance on both training and validation datasets.  
Figure 9 illustrates the training and validation loss curves for model2 over 30 epochs. The curves reveal a sharp decrease in both training and validation losses during the first 5 epochs, approaching zero. However, the curves exhibit a sudden spike in loss values afterward, indicating potential optimization issues due to overfitting or learning instability in specific data patterns.  
Figure 10 displays the training and validation loss curves for model3. Although the learning rate of model3 was slower in the initial epochs compared to the others, it stabilized and converged rapidly after a certain point. Examination of all three models' loss curves reveals that each model's training loss approaches near-zero values after specific epochs. However, except for ResNet-50, the remaining models exhibited unstable loss fluctuations during training, reflecting differences in their generalization abilities. Confusion matrices were used to provide a more intuitive visualization of each model's performance on defect and non-defect data.  
Figure 11 presents the confusion matrices for the three binary classification models described in Table 4. These matrices provide a clear visualization of the performance of each model on the test dataset, which includes 720 samples. Each matrix displays results for two classes: \"No Defect\" and \"Defect.\" The rows indicate the true labels, while the columns show the predicted labels. All three models effectively differentiated between defect and no defect samples. However, ResNet-101 and ResNet-152 each had one or two misclassified samples, whereas ResNet-50 achieved perfect predictions across all samples, demonstrating its superior performance and potential for defect detection in binary classification tasks.  
Figure 8: Training and validation loss curves of defect detection model1.  
Figure 9: Training and validation loss curves of defect detection model2.