# Yolo Based Defects Detection Algorithm for EL in PV Modules with Focal and Efficient IoU Loss
## 3 Results  
The experiments were conducted using the Windows 10 operating system and the PyTorch framework. The specific configuration is listed in Table 1.  
The dataset employed in this research comprises EL images of photovoltaic components obtained during real production operations. The initial data images exhibit a resolution of 5328 \(\times\) 3134 pixels. Specifically, we isolated EL images featuring solely S-type defects and applied image segmentation techniques to generate samples sized at 248 \(\times\) 504 pixels and 756 \(\times\) 1010 pixels. These segmented EL images were then merged \begin{table}
\begin{tabular}{c c} \hline \hline
**Environment** & **Configuration** \\ \hline CPU & Intel(R) Core(TM) i7-10700 CPU @ 2.90 GHz \\  & 2.90 GHz \\ GPU & NVIDIA GeForce GTX 3060 \\ System & Windows 10 \\ Language & Python 3.8 \\ Architecture & Pytorch \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Experimental environment and configuration. with the original EL images containing L-type defects and annotated utilizing LabelImg, an image annotation tool. As a result, a dataset comprising 2044 sample images is obtained and divided into a train set and test set by 4:1. As shown in Figure 8, the number of different samples is uneven. In this study, ablation experiments were conducted based on YOLOv5 and three loss functions: DIoU, CIoU, and Focal-EIoU. We focused on learning the features of 12 types of EL defects in photovoltaic components. The decrease of box_loss means that the model can accurately predict the location of the target; the decrease of obj_loss means that the model can correctly identify the target in the image; the decrease of cls_loss means that the model has higher accuracy in different categories. As shown in Figure 9, after adding focal_eiou_loss to the loss function, lower box_loss, box_loss, and cls_loss were obtained, thus obtaining lower loss in total, which proved that the proposed Focal-EIoU achieves significant performance advantages in terms of convergence speed and final convergence results. Figure 8: Histogram of the defect sample distribution, where (**a**) to (**l**) have been listed in Table 3.  
Figure 9: Convergence curves of the model under the three loss functions. Precision (P) and Recall (R) are important metrics for evaluating object detection algorithms, and their definitions are shown in Equations (14) and (15). \[P=\frac{TP}{TP+FP} \tag{14}\]  
\[R=\frac{TP}{TP+FN} \tag{15}\]  
where TP represents the number of correctly detected objects, FP represents the number of false positives, and FN represents the number of false negatives. F1 is a comprehensive metric that measures the precision and recall of a system. The relationship between F1 and P, as well as R, can be expressed as in Equation (16). \[F1=\frac{P\times R}{P+R} \tag{16}\]  
The higher the P and R, the better the performance of the model. After completing the model training, the trained model is evaluated by detecting EL images to validate its effectiveness. This paper compares the detection performance of the model based on four metrics: P, R, F1 score, and mean average precision (mAP). The experimental results are presented in Table 2.  
Comparing the four detection performance metrics of YOLOv5s under the three loss functions, the proposed Focal-EIoU loss function in this paper achieves the best detection capability for the model, with mAP of 0.865 for the detection of 12 EL defects. This paper uses mAP as the primary metric to evaluate the detection performance of the model and compares the detection capabilities of the three models for the 12 defects. The experimental results are shown in Table 3.  
From Table 3, it can be seen that the YOLOv5s model with the introduced Focal-EIoU loss function shows significant improvement in detecting defects with scarce samples, such