Improved YOLOv5s Algorithm for Solar Cell Defect Detection

Introduction

Solar energy, as a renewable energy source, has characteristics such as abundant reserves, permanence, cleanliness, pollution-free, and local sourcing, making it a consensus among countries to promote the development of new energy, especially in the photovoltaic industry. Therefore, quickly and accurately detecting solar cell defects has become an important issue for ensuring the production quality of solar cells and improving energy utilization efficiency. Recently, Professor Lin Zhixian‘s team from Fuzhou University and the Mindu Innovation Laboratory published a research article titled “Improved YOLOv5s Algorithm for Solar Cell Defect Detection” in Liquid Crystal and Display (ESCI, Scopus indexed, Chinese core journal) in the 2024 second issue, which was selected as the cover article of that issue. This article extracts and trains small target defect information of solar cells based on the YOLOv5s network, achieving detection of small target defects in solar cells.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 1: Cover image of Liquid Crystal and Display 2024, Issue 2

Improvement of Backbone Network

The YOLOv5s model suffers from inefficiencies in small target detection, primarily due to its excessive down-sampling factors and some pooling operations that lead to a low resolution of high-level feature maps. This results in very few pixels on high-level feature maps to represent small defects such as scratches and damages, affecting the model’s detection capability. To address this issue, a Contextual Transformer block (CoT) has been introduced (as shown in Figure 2). The CoT module, which incorporates contextual encoding and dynamic multi-head attention mechanisms, effectively collects rich contextual information between adjacent pixels, thereby enhancing the detection accuracy of small defects. Compared to the traditional C3 module, the CoT module can more finely perceive and utilize static contextual information between local neighborhood keys, enabling the model to more accurately locate and classify small defects such as scratches and damages.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 2: Contextual Transformer ModuleFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.1

CBAM Attention Mechanism

When detecting defects in solar cells, factors such as lighting, contaminants, and temperature changes often affect the recognition rate and result in a high false positive rate. To improve detection accuracy and reduce interference, this paper introduces the Convolutional Block Attention Module (CBAM) into the Head section to enhance the model’s feature expression capability. CBAM (as shown in Figure 3) is a technique that organically combines channel attention (as shown in Figure 4) with spatial attention (as shown in Figure 5), effectively improving the efficiency of attention and achieving more efficient learning.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 3: Convolutional Attention ModuleFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.3Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 4: Channel Attention ModuleFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.4Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 5: Spatial Attention ModuleFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.5

Improvement of Upsampling Method

YOLOv5s uses nearest neighbor interpolation for upsampling in its feature fusion network. However, this simple method determines the upsampling kernel only based on the pixel positions and does not fully utilize the rich semantic information in the feature maps. By introducing CARAFE, a lightweight universal upsampling operator, as illustrated in Figure 6. The CARAFE operator mainly consists of two parts: the upsampling kernel prediction module and the feature reorganization module. The upsampling kernel prediction module analyzes the encoded input feature map to infer the upsampling kernels needed for feature points at different positions. The feature reorganization module fully utilizes the upsampling kernels generated by the upsampling kernel prediction module to achieve efficient upsampling operations. Compared to nearest neighbor interpolation upsampling, the CARAFE operator shows better performance in object detection tasks and has significant advantages in solar cell defect detection. By leveraging semantic information and the influence of surrounding feature points, the CARAFE operator can achieve more precise feature reconstruction during the upsampling process, thereby improving the quality and expressiveness of the feature map after upsampling.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 6: CARAFE Module StructureFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.6

Improvement of Loss Function

In the task of detecting defects in solar cells, the loss function of YOLOv5s consists of three parts: classification loss, confidence loss, and regression loss. The traditional Complete Intersection over Union (CIoU) loss function only considers the size of the overlapping area and does not fully consider the position and shape information of the bounding box. However, the position and shape information of the bounding box is critical for solar cell defect detection. They can accurately describe the location and shape of defects and assess the severity of defects. To address this issue, an improved loss function, the Weighted Intersection over Union (WIoU) loss function, is adopted. The WIoU loss function considers the size and position information of the bounding boxes when calculating the overlap between them, focusing not only on the size of the overlapping area but also on the relative position and shape of the bounding boxes. This makes WIoU more sensitive to the integrity of the bounding boxes and allows for a more accurate measurement of the matching degree between predicted and true boxes.

Improved Network Model

Based on the above description, the improved YOLOv5s network structure is shown in Figure 7.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 7: Improved YOLOv5s Network StructureFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.7

Analysis of Experimental Results

In conclusion, the improved YOLOv5s algorithm proposed in this study demonstrates the best detection accuracy and significant overall performance, thereby demonstrating the advantages of this algorithm. To intuitively assess the improvement effect, the detection results before and after the improvement are compared in Figure 8. In the second image of Figure 8(a), the original YOLOv5s algorithm mistakenly identified the area originally labeled as “scratch” as “broken,” leading to false detection. In the fourth image of Figure 8(a), the original YOLOv5s algorithm only detected two out of three areas originally labeled as “scratch.” By observing Figure 8(c), it is clear that the improved YOLOv5s algorithm no longer has issues of missed detection and false detection. In the PV-Multi-Defect dataset detection task, this study improved the YOLOv5s algorithm, effectively resolving the issues of missed and false detections of the original algorithm while significantly improving the average recognition accuracy of surface defects in solar cells. These results indicate that the improved YOLOv5s algorithm has great potential and practical application value in the field of solar cell defect detection.Improved YOLOv5s Algorithm for Solar Cell Defect DetectionFigure 8: Comparison of detection effects before and after improvement. (a) Original image; (b) YOLOv5s detection effect image; (c) Improved YOLOv5s detection effect imageFigure Source: Liquid Crystal and Display, 2024, 39(2): 237-247. Fig.10

Conclusion and Outlook

Defects in solar cells are inevitable during the production process, and these defects affect the lifespan and luminous efficiency of solar cells to varying degrees. Therefore, defect detection is necessary during the production process of solar cells. This paper takes this as a starting point and, based on the YOLOv5s algorithm, introduces the CoT module in the backbone part to enhance the feature expression capability and receptive field range, thereby capturing the details and contextual information of solar cell defects more accurately. Secondly, by adding the CBAM attention to the C3 module in the Head section, it can better capture the important channels and spatial positions of the input feature map, improving the model’s performance and robustness. Next, using the lightweight universal upsampling operator CARAFE reduces the loss of feature information during the upsampling process, ensuring the integrity of feature information. Finally, using WIoU as the bounding box loss function can significantly enhance regression accuracy and help achieve rapid model convergence. Experimental results show that the improved model exhibits high performance improvements in the task of detecting defects in solar cells, providing a reliable and efficient solution for solar cell defect detection.

Paper Information

Xueling Peng, Shanling Lin, Zhixian Lin, Tailiang Guo. Improved YOLOv5s Algorithm for Solar Cell Defect Detection [J]. Liquid Crystal and Display, 2024, 39(2): 237-247.https://cjlcd.lightpublishing.cn/thesisDetails#10.37188/CJLCD.2023-0249

Corresponding Author Profile

Improved YOLOv5s Algorithm for Solar Cell Defect DetectionShanling Lin, PhD, Master’s supervisor, obtained a PhD degree from Fuzhou University in 2020, mainly engaged in research on display driving, image processing, and other fields.E-mail: [email protected]Supervised by: Zhang Ying, Zhao YangEdited by: Zhao WeiImproved YOLOv5s Algorithm for Solar Cell Defect DetectionBannerClick Here 👇 Follow MeLight Up “Like” and “View”, So You Don’t Miss Article Updates

Leave a Comment