# Research on Automated Fiber Placement Surface Defect Detection Based on Improved YOLOv7
## 2 Overview and Detection Principle of YOLOv7  
The YOLO (You Only Look Once) neural network is a real-time object detection system that transforms the object detection problem into a single regression problem. The YOLO network divides the input image into a fixed number of grids, with each grid responsible for detecting objects that fall within it. Each grid predicts multiple bounding boxes and their corresponding class probabilities. Through a single forward pass, YOLO can simulaneously output multiple detection results, making it extremely fast. The network design includes convolutional layers and fully connected layers, with the convolutional layers used for feature extraction and the fully connected layers used for predicting bounding boxes and classes [25]. YOLOv1 was proposed in 2015, using the Darknet-19 network for end-to-end object detection, but it had shortcomings in small-object detection and localization accuracy. YOLOv2, introduced in 2016, addressed these issues by employing an improved Darknet-19 network and a multi-scale feature map design, enhancing detection accuracy. YOLOv3, launched in 2018, utilized the Darknet-53 network and feature pyramid network, further boosting performance. YOLOv4, released in 2020, adopted the CSPDarknet53 network, SAM attention mechanism, and other techniques, significantly improving detection performance. In the same year, YOLOv5 was introduced, optimizing the structure to enhance detection accuracy and speed. YOLOv7, released in 2021, achieved further improvements in both accuracy and speed, making it one of the most powerful detection algorithms available today [25; 26; 27; 28].  
The YOLOv7 algorithm has achieved new heights in speed and accuracy ranging from 5 FPS to 160 FPS, surpassing previous real-time object detection models with the highest accuracy of 56.8% AP on the GPU V100, achieving 30 FPS or higher [26]. YOLOv7 is an anchor-based object detection algorithm, building upon the previous versions with numerous improvements, including the integration of the Extended-ELAN (EELAN) aggregation network, convolution re-parameterization, and the proposal of concatenation-based models for model scaling [26]. The algorithm's model structure consists of the input layer, the backbone network for feature extraction, and the head network for feature fusion, loss calculation, and prediction.  
The backbone network comprises several BConv layers, E-ELAN modules, and MPConv modules [26; 29]. The BConv layer fuses convolution and Batch Normalization (BN) layers into a single convolution layer to reduce computational complexity. The E-ELAN module increases the base of features by using multiple sets of convolutions to add features and then combines these groups of features, enhancing the model's learning capability and parameter utilization without disrupting the gradient path or encountering issues like gradient explosion or vanishing gradients. The MPConv layer has two branches: one branch performs downsampling through max pooling to expand the receptive field, while the other branch achieves channel variation through convolution layers with different kernel sizes and adds the results together to enhance the network's generalization ability.  
In the head network, layers such as SPPCSPC (improved spatial pyramid pooling structure), several BConv layers, several MPConv layers, several concatenation layers, and RepConv layers (Repvgg_block) are used for final classification, regression prediction of the target image, and the generation of output results [26; 29].