# Research on Automated Fiber Placement Surface Defect Detection Based on Improved YOLOv7
## 1 Introduction
(2017) [PERSON] et al. (2017) have also realized online defect identification using this approach. Although the defect detection scheme based on infrared thermal imaging has shown certain effectiveness, it still has some limitations. Firstly, temperature data can be easily affected by environ  
Figure 1: Automatic fiber placement machine (column type). mental factors such as temperature gradients, humidity, and airflow, which may lead to misjudgment or missed defects. Secondly, the detection speed of the infrared thermal imager is relatively slow, especially in cases of large-area laying or high-speed laying, which may not meet the real-time monitoring requirements. The third approach is based on visible-light image defect detection technology. [PERSON] et al. [12] installed cameras on the laying head to monitor laying defects online. However, ambient light may cause changes in the brightness of the laying area, thereby interfering with image capture and analysis. In recent years, the development of deep learning and computer vision technologies has provided new solutions for surface defect detection in AFP. Through learning from large amounts of data, deep learning models can automatically extract features and classify and detect defects. There are two common types of object detection algorithms in deep learning: two-stage detection algorithms such as Faster R-CNN, and single-stage detection algorithms such as the YOLO series. Two-stage detection algorithms have high detection accuracy but are slow in speed, while single-stage detection algorithms have relatively high detection accuracy and fast detection speed, meeting the requirements for online detection. [PERSON] et al. (2022) [13] proposed a multi-scale AFP defect detection algorithm, SPFFY-CA, enhancing automatic defect recognition efficiency and accuracy in automated fiber placement processes. [PERSON] et al. (2023) [14] presented a novel approach utilizing Convolutional and Recurrent Neural Networks for real-time defect detection in automated fiber placement processes, offering a significant advancement for automated inspection systems in composite engineering. Deep learning-based detection methods have been widely applied in various industries [15; 16; 17; 18; 19; 20; 21; 22; 23; 24] but have not been extensively used in the field of AFP. This can be attributed to two main reasons: firstly, the lack of high-quality datasets for surface defect inspection in composite material automated laying processes; and secondly, the relatively low detection rate and accuracy of small-target defects generated in AFP, which do not suffice for stable industrial applications. Building upon the aforementioned background, this paper proposes an improved YOLOv7-based automated surface defect detection algorithm for AFP to achieve detection of surface defects in automated laying. The main contributions of this paper are as follows:  
1. Utilizing the self-developed AFP equipment from Nanjing University of Aeronautics and Astronautics (NUAA) to establish a detection platform, a composite material automated laying surface defect dataset comprising over 5000 images was constructed. The defect categories include gaps, overlaps, foreign objects, twists, and wrinkles. 2. We introduce the BiFormer attention mechanism to enhance the backbone network, capturing fine information in the feature map, and strengthening the relevance of contextual information in the image to improve the extraction capability of small target features such as gaps and overlaps. 3. Replacing the PAFPN structure with the AFPN in the neck layer, AFPN fuses adjacent low-level features and gradually integrates high-level features into the fusion process, effectively avoiding significant semantic differences between non-adjacent levels, ensuring a balanced retention of detailed and semantic information in the AFP defect detection task. 4. We adopt the WIoU loss function to replace the original CIoU loss function as the bounding box regression loss function.