# Glass Defect Detection with Improved Data Augmentation under Total Reflection Lighting
## 3 Principle and Improvement of Defect Detection Algorithm  
### YOLOv5 Algorithm  
At present, common target detection models are generally divided into single-stage and two-stage algorithms. The former algorithm is mainly dominated by YOLO and SSD, and the latter algorithm is represented by R-CNN [24] and Faster R-CNN [25]. YOLOv1 [26], as a classic single-stage target detection algorithm, was proposed by [PERSON] and other researchers in 2015, which ushered in the YOLO family. Through continuous optimiza  
Figure 5: Defect images under the main and the auxiliary imaging fields.  
tion and innovation, YOLOv2, YOLOv3, YOLOv4, and YOLOv5 came into being one after another [27; 28; 29], with constantly improving performance. YOLO sums up the target classification and target position regression in Faster R-CNN as a regression issue, which significantly reduces the computing power and improves the detection speed, thus enabling its wider application in real-time detection. YOLOv5 works as an end-to-end target detection algorithm that directly transforms image information into a target position and target type recognition through a deep convolution neural network, whose detection results take the form of a target box and confidence. The improved network structure, as shown in Figure 6, roughly falls into four parts. Input Section: The input module of YOLOv5 defines the specifications and format of the images received by the model. Typically, input images undergo preprocessing operations such as normalization and resizing for their effective processing within the model. During the training phase, the input section may also include information related to label data, such as the position and category information of target boxes. Backbone Section: YOLOv5 employs CSPDarknet53 as its backbone network, which is responsible for extracting feature information from the input images. CSPDarknet53 is a deep convolutional neural network with multiple convolutional layers and residual connections, gradually extracting semantic and spatial information from the images. These feature maps are then passed to subsequent layers for object detection. Neck Section: YOLOv5 utilizes PANet (Path Aggregation Network) as its neck section. The primary role of the neck section is to propagate and aggregate information between feature maps at different scales, enhancing the model's ability to detect objects of varying sizes. PANet achieves this by introducing path aggregation modules and feature fusion modules, facilitating the interaction and integration of information between feature maps of different resolutions, thereby improving the model's performance. Prediction Section: The prediction section of YOLOv5 comprises a series of convolutional layers and activation functions used to predict the position and category information of objects from feature maps. This network segment processes the feature maps to output the coordinates of object positions, category confidences, and other relevant information. The prediction section typically employs convolutions and activation functions to perform nonlinear transformations on the feature maps, extracting higher-level semantic information and ultimately generating object detection results. Through the collaborative effort of these modules, YOLOv5 accomplishes efficient and accurate object detection tasks. The input module handles the reception and preprocessing of input images, the backbone section extracts image features, the neck section enhances feature representation, and the prediction section is responsible for generating the final detection results.  
Figure 6: YOLOv5 network model structure diagram.