# A Study on the Optimization of the Coil Defect Detection Model Based on Deep Learning
## 4 Case Study and Analysis
### Analysis of Case Application Results  
To find a suitable model for the defect detection system, three model improvement techniques were applied and their results were comparatively analyzed except for the initial model of the system.  
In the case of structure modification, when one or two Conv blocks were added to the backbone, mAP was approximately 95% and the inference time was 0.9 ms, which was found to be the most suitable model for the system. In the case of model scaling, when a  
Figure 16: Result graph (pruning).  
Figure 15: Result graph (model scaling).  
ratio of model depth and width (1.00 and 0.25) was applied, mAP was approximately 95.3% and the inference time was 1.1 ms, which was found to be the most suitable model. Finally, in the case of the lightweight technique, when 10% of the pruning value was applied, mAP was approximately 95% and the inference time was 1.6 ms, which was found to be the most suitable model for the system.  
Figure 17 shows a graph comparing the most suitable models obtained using the three techniques applied to improve the performance of the initial system model. As verified in Figure 16, when the initial model and the case of applying the lightweight technique were compared, the same inference time was revealed; however, the mAP value was relatively lower in the case of pruning. In the case of model scaling, the same mAP was exhibited, but the inference time was faster. Finally, in the case of structure modification, mAP was lower than that of the initial model, but the inference time was the fastest. In this study, the model that applied model scaling was selected as the most suitable model for the proposed system because it has the same mAP value as that of the initial model but a faster inference time based on the criteria that false defect detection should be low in practical  
calculation results obtained using 3 different grid sizes (8, 16, and 32), where the similarity is the highest when the grid size is 8 in all classes.  
Based on the results in Table 6, CLAHE-applied data with a grid size of 8 were added to the original dataset to perform learning. The added dataset contained 7600 images. Thus, a total of 20,541 images were used in model learning. Figure 18 shows the results of training by adding data applying CLAHE to the basic model and the model applying model scaling, respectively. The final result shows that mAP were approximately 95.3% and 96.9% and the inference times were 1.3 ms and 0.9 ms. When analyzing the mAP value through Table 7, it was observed that the mAP values of the 'T-OK' and 'T-NG' classes were maintained, and the mAP values of the 'OK' classes were improved. However, the value of 'NG' was relatively lowered by about 1.4%.  
For further model optimization, performance analysis was conducted according to changes in hyperparameters. Table 8 below summarizes the results of applying hyperparameter changes. The performance change according to the epoch shows the best performance when the epoch is 300. The learning rate shows the best performance in the cases of 0.01 and 0.001. Therefore, the optimal hyperparameter in this study is when the Epoch is 300 and the learning rate is 0.01 or 0.001. Based on this, it can be determined that the existing hyperparameters are appropriate for this study.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **8** & **16** & **32** \\ \hline Top & 0.855699131 & 0.850566568 & 0.839055953 \\ \hline L and R & 0.96406197 & 0.951937665 & 0.940069685 \\ \hline \hline \end{tabular}
\end{table}
Table 6: SSIM results (grid size).  
Figure 18: Final result analysis graph.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Precision** & **Recall** & **AP** \\ \hline \multirow{3}{*}{Our Model} & OK & 0.918 & 0.954 & 0.981 \\ \cline{2-4}  & NG & 0.879 & 0.786 & 0.915 \\ \cline{2-4}  & T-OK & 0.874 & 0.993 & 0.984 \\ \cline{2-4}  & T-NG & 1 & 0.976 & 0.995 \\ \hline \hline \end{tabular}
\end{table}
Table 7: mAP analysis (model scaling and pre-processing).