# A Study on the Optimization of the Coil Defect Detection Model Based on Deep Learning
## 3 Methodology
### YOLOv5 Model and Performance Improvement Techniques
#### 3.2.1 Yolo  
YOLO is a universal object detection algorithm focusing on fast inference speed, as the localization and classification of the object in the image or video are conducted simultaneously in the object detection process. To date, various versions of YOLO models have been released through continuous performance improvements. Figure 5 shows the structure of YOLOv5 [15], which is used in the present study.  
The backbone of YOLOv5 is mainly composed of a single block called Conv, which includes three components (convolution, batch normalization, and leaky ReLu), a C3 block that employs CSPNet [16], and the spatial pyramid pooling (SPP) algorithm. Conv blocks consist of convolution, batch normalization, and activation functions, and in this study, Conv blocks are added for performance analysis through structural modifications. This structural modification is intended to analyze the effect of more feature map extraction on the performance of the model. The purpose of CSPNet is to reduce the computation increase due to the duplication of the weight information created during the learning process. In a partial dense block, the feature maps are split into two parts: one part goes through a dense block and the other part is directly linked to the end of the stage as shown in Figure 6. In a partial transition layer, the concatenation of the output through the dense block and the output that is directly linked to the end of the stage is used as the input value. This process can be effective in reducing duplicate weights as well as computation.  
Figure 5: YOLOv5 network structure.  
Existing CNN models have input size limitations due to fully connected layers. However, SPPNet [17] tried to solve the problems that could arise by removing the input size limit. The feature map extracted through the convolution layer is divided into a predetermined bin. After that, max pooling is applied to the bin, and then the results are connected. Through this, it is possible to extract an output value of a certain size regardless of the image size.  
In the Neck, a block used in the backbone is applied to a path aggregation network (PAN) [18] to improve the performance. PAN allows improved performance by further adding a bottom-up path to the feature pyramid network [19]. It aims to transfer a feature in the bottom hierarchy to the top hierarchy because the feature from the bottom hierarchy is less influential up to the last hierarchy.  
Finally, the Head extracts the results for three different sizes, the same as in YOLOv3 [20], and aims to detect objects with various sizes in an image or video.  
To improve the model performance, model scaling that generally adjusts the model's depth and width as well as the input image size can be performed. Further, five different YOLOv5 models are proposed through model scaling as shown in Figure 7. Table 1 presents the model scale ratio in five different versions, which are categorized as \"XLarge,\" \"Large,\" \"Medium,\" \"Small,\" and \"Nano.\"The model scaling value becomes large from Nano to XLarge. As verified in Figure 8, mAP values improve as the model scaling value becomes larger; however, the inference time is slower and the capacity of the final model also increases. The present study aims to improve the model performance by changing the model scaling value to find the optimum model.