# A Defect Detection Method Based on YOLOv7 for Automated Remanufacturing
## 3 Training and Results
### Training Results
#### 3.5.3 KSDD2  
In this challenging dataset, where samples containing defects are only about 10% of the total samples, training results are shown in Figure 11. As the NRSD dataset, the base model variant was selected and trained with similar parameters as with NEU-DET mentioned in Table 3. In addition, images are resized to 640 \(\times\) 640 to reduce training time. Furthermore, the model was trained for 200 epochs since this dataset has fewer true positive samples, which is expected to slow the learning process, as shown in Figure 11. The training process results plotted in Figure 11 show a difficult learning curve due to serval reasons including a small number of defect samples, and a similar texture of defect with the background. Some of the testing results are shown in Figure 12. For the mAP with a 0.5 IoU threshold, the model performance with about 65% for both the bounding box and mask. However, the accuracy is reduced dramatically for the mAP over the range (0.5-0.95) IoU threshold with about 30% for the bounding box and 26% for detecting masks. This is due to smaller portions of the defective areas being detected that are ignored when the threshold is larger. For this dataset, [PERSON] et al. [49] introduce a weakly supervised model that achieved a 73.3% mAP_0.5 which is about 8.3% better than the YOLOv7 model in segmentation.  
Figure 11: YOLOv7-based variant model training processing performance on the KSDD2 dataset (B: box, M: mask). (**a**) mAP_0.5; (**b**) mAP_0.5:0.95.  
Table 6 provides a comparison of the YOLOv7 defect detection models used in this study across different datasets, along with some other studies, highlighting the accuracy metrics for each model. The results illustrate the strengths and limitations of each approach in identifying defects in industrial contexts. YOLOv7 variants show strong performance on the NRSD dataset but have lower performance with the KolektorSDD2 dataset, indicating variability in their effectiveness based on dataset characteristics. ResNet50 (Faster R-CNN) and Mask R-CNN demonstrate high accuracy on custom datasets, suggesting their suitability for specific applications. The Cas-V Swin Transformer balances high accuracy in both box and mask predictions, highlighting the importance of hybrid methods that combine YOLO with Swin Transformers, making it more suitable for real-time applications.  
There is potential for further improvements in the average prediction precision of this study through advanced data augmentation techniques. Techniques such as geometric transformations (rotations, translations, scaling, and flips) [58], photometric adjustments (altering brightness and contrast) [59], and the addition of synthetic noise can significantly enhance the model's robustness. Additionally, more sophisticated methods like generative adversarial networks (GANs) can be used to generate synthetic data that mimics real-world variations in defects [60]. Implementing these data augmentation methods is expected to improve the robustness of the YOLOv7 model and its precision in detecting subtle and complex defects.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Method** & **Dataset** & **Accuracy** \\ \hline YOLOv7 variants & NEU-DET & 65–73\% mAP\_0.5 \\ YOLOv7 (base) & NRSD & 88.5\% mAP\_0.5 \\ YOLOv7 (base) & KolektorSDD2 & 65\% mAP\_0.5 \\ ResNet50 (Faster R-CNN) [9] & Custom (fixed bends) & 88.7\% mAP \\ Cas-VSWin Transformer [26] & Private dataset & 82.3\% AP (Box)/80.2\% AP (Mask) \\ Mask R-CNN [56] & Custom insulator dataset & 87.5\% mAP \\ Faster R-CNN [57] & Aluminum defect dataset & 78.8\% mAP \\ \hline \hline \end{tabular}
\end{table}
Table 6: Comparative performances of defect detection models.  
Figure 12: Sample results of the model prediction for the KSDD2 dataset.