# Research on Automated Fiber Placement Surface Defect Detection Based on Improved YOLOv7
## 4 Experimental Setup and Result Analysis
### Ablation Study
#### 4.4.4 Test Results and Analysis  
To validate the detection performance of the model, we used the model to detect and recognize surface defects of composite material in the test set automatically. The models tested in addition to the improved models YOLOv7 + BiFormer, YOLOv7 + AFPN, YOLOv7 + WIoU, and Improved YOLOv7 include other classical and representative detection model algorithms such as Faster R-CNN [48], EfficientDet [49], YOLOv5 [50], YOLOv5-tiny [50], YOLOv7 [29], and YOLOv7-tiny [29]. Table 4 illustrates the average precision (AP) of the improved models and other models in each category. For gap defects, the AP of YOLOv7 is 79%, while YOLOv7 + BiFormer with the incorporation of the BiFormer attention mechanism significantly improves the AP to 91.5%, indicating the positive effect of the BiFormer attention mechanism in capturing subtle features of small object defects. In comparison, YOLOv7 + AFPN and YOLOv7 + WIoU show slightly smaller improvements in AP, reaching 88% and 89%, respectively. Regarding overlap defect detection, YOLOv7 achieves an AP of 83%, whereas YOLOv7 + BiFormer achieves an AP of 92.3%, demonstrating that the BiFormer attention mechanism outperforms the AFPN structure and WIoU loss function in performance. For wrinkle and twist defect detection, YOLOv7 achieves AP values of 84% and 88%, respectively, while YOLOv7 + BiFormer, YOLOv7 + AFPN, and YOLOv7 + WIoU all surpass the original algorithm's AP values. Improved YOLOv7, in particular, stands out in performance on these two defect types, reaching AP values of 95.7% and 97.3%, attributed to the fusion of the BiFormer attention mechanism, AFPN feature fusion, and WIoU loss function advantages, enhancing sensitivity to details, feature fusion, and the accuracy of bounding box regression. Lastly, for foreign object defect detection, YOLOv7 achieves an AP of 91%, while Improved YOLOv7 achieves a high AP of 98.5%, indicating its stronger detection capability for foreign object defects. Other algorithms such as YOLOv7 + BiFormer, YOLOv7 + AFPN, and YOLOv7 + WIoU also demonstrate better performance compared to the original algorithm. Overall, Improved YOLOv7 demonstrates superior detection performance across all defect types, with significantly higher average AP values compared to other algorithms. In particular, in wrinkle and twist defect detection, Improved YOLOv7 outperforms other algorithms, which can be attributed to its comprehensive integration of various improvement strategies. Firstly, the introduction of the BiFormer attention mechanism enables the model to better regress the size and position of targets by capturing subtle defect features, thereby enhancing the detection accuracy and recall. Secondly, the AFPN feature fusion strategy balances detailed information and semantic information, avoids significant semantic differences between different hierarchies, and strengthens feature fusion. Additionally, the WIoU loss function is more sensitive to small targets, aiding in optimizing the accuracy of bounding box regression. Improved YOLOv7 outperforms other algorithms in AFP defect detection in composite materials. This algorithm demonstrates higher accuracy and practicality in handling various defects due to the enhancement of detail sensitivity, feature \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Models** & **Gap** & **Overlap** & **Wrinkle** & **Twist** & **Foreign** \\ \hline Faster R-CNN & 68.3 & 63.4 & 71.3 & 77.4 & 81.7 \\ EfficientDet & 71.5 & 70.3 & 75.2 & 79.5 & 83.4 \\ YOLOv5-tiny & 75.3 & 76.5 & 77.4 & 80.1 & 85.7 \\ YOLOv5 & 77.4 & 79.7 & 79.5 & 82.4 & 87.6 \\ YOLOv7-tiny & 75.3 & 77.1 & 81.2 & 83.5 & 86.9 \\ YOLOv7 & 79.6 & 83.6 & 84.4 & 88.6 & 91.8 \\ \hline Our models & YOLOv7 + BiFormer & 91.5 & 92.3 & 92.5 & 94.4 & 96.6 \\ YOLOv7 + AFPN & 88.2 & 90.6 & 91.2 & 92.9 & 92.7 \\ YOLOv7 + WIoU & 89.3 & 90.4 & 92.9 & 93.7 & 92.1 \\ Improved YOLOv7 & 93.3 & 94.5 & 95.7 & 97.3 & 98.5 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of AP for various surface defects in test set.