A solar cell defect segmentation method based on an improved UNet algorithm

CN122906376APending Publication Date: 2026-10-13GUANGDONG POLYTECHNIC NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611097366.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0006]为了克服现有技术的不足,本发明的目的在于提供一种基于改进UNet算法的太阳能电池缺陷分割方法,其通过引入VGG16骨干网络与混合注意力机制对UNet模型进行改进,能够在复杂电致发光图像背景下实现高精度、低计算复杂度的太阳能电池多类型缺陷分割

Benefits of technology

1.本发明显著提升了缺陷分割精度与边界完整性。本发明对UNet模型进行针对性改进,一方面将编码器中的骨干网络替换为VGG16,利用VGG16的深度卷积结构和ImageNet预训练权重,系统提取从低层纹理到高层语义的多尺度缺陷特征,有效解决了现有模型在复杂光照和小样本条件下特征提取能力不足、难以捕捉多尺度缺陷特征的问题;另一方面,在解码器引入混合注意力机制(HybridAttention),该机制并行采用全局平均池化和全局最大池化进行双路径通道注意力校准,并引入Gumbel-Softmax实现硬空间注意力选择,能够自适应地强化缺陷相关通道和空间区域、抑制复杂EL图像背景干扰,从而显著提升缺陷边界分割精度和微小缺陷的检出率。经实验验证,以原始UNet为基准模型,其MIoU、mPA、Precision和Recall分别为39.78%、44.75%、59.42%和44.75%;本发明完整模型在相同数据集上的MIoU、mPA、Precision和Recall分别达到76.14%、82.31%、88.95%和82.31%,相比原始UNet分别提高了36.36%、37.56%、29.53%和37.56%,证明了本发明在分割精度上的显著优势。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122906376A_ABST
    Figure CN122906376A_ABST
Patent Text Reader

Abstract

The application discloses a solar cell defect segmentation method based on an improved UNet algorithm, and comprises the following steps: S1, acquiring solar cell defect image data to be detected as initial image data set; S2, performing geometric data enhancement processing on the initial image data set to obtain a pretreated image data set; S3, dividing the pretreated image data set into a training set, a verification set and a test set according to a preset proportion; S4, constructing an improved UNet model based on a UNet algorithm; S5, iteratively training the improved UNet model by using the training set and the verification set, saving optimal training weights after the training is completed, and obtaining a trained improved UNet model; and S6, testing and evaluating the trained improved UNet model by using the test set and the optimal training weights. The application can realize high-precision and low-computational-complexity solar cell multi-type defect segmentation under a complex electroluminescence image background.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and more specifically to a method for segmenting defects in solar cells based on an improved UNet algorithm. Background Technology

[0002] Against the backdrop of global efforts to address climate change and advance energy transition, solar energy technology forms a core support for sustainable development, reducing greenhouse gas emissions, decreasing dependence on fossil fuels, and enhancing energy self-sufficiency. As the core component of photovoltaic (PV) systems, solar cells are driving the large-scale development of the PV industry through improved efficiency and reduced costs. However, surface defects such as cracks and stains formed during the production and operation of solar cells can reduce photoelectric conversion efficiency and shorten their lifespan. Therefore, before being put into practical use, solar cells must undergo rigorous defect detection and segmentation to ensure their performance and long-term reliability.

[0003] Currently, solar cell defect segmentation methods are mainly divided into two categories: traditional image processing methods and deep learning methods. Traditional methods mainly adopt techniques based on threshold segmentation, edge detection, and region growing. However, electroluminescent (EL) images generally suffer from problems such as uneven backgrounds, blurred defect boundaries, and diverse defect morphologies and scales. When faced with these complex situations, traditional methods have inherent limitations such as low automation, poor adaptability, and sensitivity to seed points or similarity criteria, making it difficult to achieve accurate and robust defect segmentation.

[0004] With the development of deep learning technology, semantic segmentation model-based methods have been gradually applied to the field of solar cell defect detection. The encoder-decoder structure represented by UNet can automatically learn the hierarchical features of images, which improves the detection accuracy to a certain extent. However, existing semantic segmentation models still face the following problems under complex lighting and small sample conditions: (1) insufficient feature extraction capability, making it difficult to effectively capture multi-scale defect features from low-level texture to high-level semantics; (2) insufficient understanding of semantic information in complex backgrounds, making them susceptible to background interference and resulting in false detections; (3) insufficient defect boundary segmentation accuracy, which easily leads to problems such as blurred boundaries and missed detection of small defects. In addition, existing models have a large number of parameters and high computational complexity, making it difficult to balance high accuracy and real-time performance, which limits their deployment and application on resource-constrained edge devices.

[0005] Therefore, there is an urgent need to design a lightweight deep learning model that can efficiently extract multi-scale defect features in complex backgrounds, enhance boundary segmentation accuracy, and reduce computational complexity, so as to meet the dual requirements of segmentation accuracy and computational efficiency in the field of solar cell defect detection. Summary of the Invention

[0006] To overcome the shortcomings of existing technologies, the present invention aims to provide a solar cell defect segmentation method based on an improved UNet algorithm. By introducing a VGG16 backbone network and a hybrid attention mechanism to improve the UNet model, it can achieve high-precision, low-computational-complexity segmentation of multiple types of solar cell defects in complex electroluminescent image backgrounds.

[0007] To achieve the objectives of this invention, the following solution is adopted: A method for defect segmentation in solar cells based on an improved UNet algorithm includes the following steps: S1: Acquire image data of solar cell defects to be detected as the initial image dataset; S2: Perform geometric data augmentation on the initial image dataset to obtain a preprocessed image dataset; S3: Divide the preprocessed image dataset into a training set, a validation set, and a test set according to a preset ratio; S4: An improved UNet model is constructed based on the UNet algorithm. The improved UNet model includes: replacing the backbone network in the encoder with VGG16, using the deep convolutional structure and pre-trained weights of VGG16 to extract multi-scale features from low-level texture to high-level semantics, and fusing shallow positional information with deep semantic information through skip connections; and introducing a hybrid attention mechanism in the decoder. The hybrid attention mechanism uses global average pooling and global max pooling in parallel for dual-path channel attention calibration, and introduces Gumbel-Softmax to achieve hard-space attention selection to suppress background interference and enhance the accuracy of defect boundary segmentation, thus obtaining the improved UNet model. S5: Iteratively train the improved UNet model using the training set and the validation set, and save the optimal training weights after training to obtain the trained improved UNet model; S6: Test and evaluate the trained improved UNet model using the test set and the optimal training weights to obtain defect segmentation results and evaluation metrics.

[0008] Further, in step S1, the initial image dataset contains 206 images selected from publicly available datasets, and the 206 images are labeled at the pixel level according to defect type. The labeled defect types include black core, corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

[0009] Further, in S2, the geometric data enhancement processing includes flipping, rotating, scaling, and random cropping; after the geometric data enhancement processing, a preprocessed image dataset with 758 samples is obtained, and the defect types covered by the 758 samples include black core, edge and corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

[0010] Further, in step S3, the preprocessed image dataset is divided into a training set, a validation set, and a test set according to a preset ratio of 8:1:1.

[0011] Further, in step S4, the VGG16 consists of 13 convolutional layers, 5 pooling layers, and 3 fully connected layers. Cascaded 3×3 convolutional kernels are used to replace large receptive field convolutions in order to reduce the number of parameters while maintaining feature extraction capabilities. The kernels pass through convolutional blocks composed of 3×3 convolutional layers in sequence, with each convolutional block followed by a 2×2 max pooling layer, which is used to halve the feature map size and expand the receptive field.

[0012] Furthermore, in step S4, the hybrid attention mechanism is applied to the feature fusion stage of the decoder, which adaptively adjusts the importance of different channels and spatial locations, enabling the network to focus on key features and suppress irrelevant information.

[0013] Furthermore, in step S4, the hybrid attention mechanism specifically refers to: The input feature map is calibrated through a channel attention branch. The channel attention branch uses parallel global average pooling and global max pooling to capture the spatial context and generate two complementary channel descriptors. The two descriptors are respectively passed through a bottleneck structure consisting of two 1×1 convolution layers. Then, the outputs of the two branches are added element by element and channel attention weights are generated by the Sigmoid function. The channel attention weights are multiplied element by element with the original input features to obtain the channel-enhanced features. Spatial attention processing is performed on the channel-enhanced features. The spatial attention branch calculates the mean and maximum values ​​along the channel dimension to generate two complementary spatial description maps. These maps are then stitched together by the channels to form a feature map. Subsequently, spatial context modeling is performed using a 7×7 convolutional kernel to generate initial spatial attention weights. The initial spatial attention weights are discretized using the Gumbel-Softmax function to generate a hard spatial attention mask. The hard spatial attention mask is then multiplied pixel-by-pixel with the enhanced features of the channel to highlight key regions and suppress irrelevant background.

[0014] Furthermore, in step S4, the improved UNet model fuses the shallow positional information extracted by VGG16 in the encoder with the deep semantic information in the decoder through skip connections, so as to preserve spatial details and improve the accuracy of segmentation boundaries.

[0015] Further, in step S5, Adam is selected as the optimizer, the number of training iterations is 200, the batch size is 16, the momentum value is set to 0.9, the initial learning rate is set to 0.0001, and the input image size of the model is set to 512×512.

[0016] Furthermore, in step S6, the optimal training weights are used to test the model performance on the test set. The average intersection-union ratio, precision, number of floating-point operations, mean precision, and recall are used to measure the merits of the improved UNet model. The defect segmentation results obtained from the test are used as the final output.

[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention significantly improves defect segmentation accuracy and boundary integrity. The invention makes targeted improvements to the UNet model. On one hand, it replaces the backbone network in the encoder with VGG16, utilizing VGG16's deep convolutional structure and ImageNet pre-trained weights to systematically extract multi-scale defect features from low-level texture to high-level semantics. This effectively solves the problems of insufficient feature extraction capabilities and difficulty in capturing multi-scale defect features under complex lighting and small sample conditions in existing models. On the other hand, it introduces a hybrid attention mechanism in the decoder. This mechanism uses global average pooling and global max pooling in parallel for dual-path channel attention calibration and introduces Gumbel-Softmax to achieve hard-space attention selection. This adaptively strengthens defect-related channels and spatial regions and suppresses background interference from complex EL images, thereby significantly improving defect boundary segmentation accuracy and the detection rate of small defects. Experiments have verified that, based on the original UNet model, its MIoU, mPA, Precision, and Recall are 39.78%, 44.75%, 59.42%, and 44.75%, respectively. The complete model of this invention achieves MIoU, mPA, Precision, and Recall of 76.14%, 82.31%, 88.95%, and 82.31%, respectively, on the same dataset, representing improvements of 36.36%, 37.56%, 29.53%, and 37.56% compared to the original UNet, demonstrating the significant advantage of this invention in segmentation accuracy.

[0018] 2. This invention significantly reduces model computational complexity and enables edge deployment. It replaces the backbone network in the encoder with VGG16 and uses cascaded 3×3 small convolutional kernels instead of large receptive field convolutions, effectively reducing the number of model parameters and floating-point operations while maintaining or even enhancing feature extraction capabilities. Experiments show that the original UNet has a computational cost of 3.712T FLOPs, while the complete model of this invention has a computational cost of only 452.441G FLOPs, a reduction of approximately 88%. This significantly improves inference speed and resource utilization, enabling real-time deployment on edge devices with limited computing power, meeting the dual requirements of detection efficiency and cost control in industrial scenarios.

[0019] 3. This invention effectively mitigates the risk of overfitting under small sample conditions and enhances the model's generalization ability. This invention introduces a VGG16 backbone network and uses its pre-trained weights on the ImageNet large-scale dataset for initialization, enabling the model to possess good general visual feature representation capabilities from the initial training stage. Combined with geometric data augmentation strategies (flipping, rotation, scaling, and random cropping), it effectively alleviates the problem of overfitting in deep learning models under limited solar cell defect annotation samples, enhances the model's generalization robustness to different defect morphologies and imaging conditions, and further improves the reliability of this invention in practical industrial applications. Attached Figure Description

[0020] Figure 1 This is a flowchart of a solar cell defect segmentation method based on an improved UNet algorithm in an embodiment of the present invention; Figure 2 This is a network structure diagram of the improved UNet model in an embodiment of the present invention; Figure 3 This is an example diagram of solar cell defect segmentation in an embodiment of the present invention; Figure 4 This is a schematic diagram of the VGG16 backbone network in an embodiment of the present invention; Figure 5 This is a schematic diagram of the hybrid attention mechanism in an embodiment of the present invention. Detailed Implementation

[0021] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the various embodiments or technical features described below can be arbitrarily combined to form new embodiments.

[0022] like Figure 1-5 As shown, this embodiment of the invention provides a solar cell defect segmentation method based on an improved UNet algorithm, comprising the following steps: S1: Obtain image data of the solar cell defects to be detected, as the initial image dataset.

[0023] S2: Perform geometric data augmentation on the initial image dataset to obtain a preprocessed image dataset.

[0024] S3: Divide the preprocessed image dataset into a training set, a validation set, and a test set according to a preset ratio.

[0025] S4: An improved UNet model (solar cell defect segmentation model) is constructed based on the UNet algorithm. The improved UNet model includes: replacing the backbone network in the encoder with VGG16, using the deep convolutional structure and pre-trained weights of VGG16 to extract multi-scale features from low-level texture to high-level semantics, and fusing shallow positional information with deep semantic information through skip connections; and introducing a hybrid attention mechanism in the decoder. The hybrid attention mechanism uses global average pooling and global max pooling in parallel for dual-path channel attention calibration, and introduces Gumbel-Softmax to achieve hard-space attention selection to suppress background interference and enhance the accuracy of defect boundary segmentation, thus obtaining the improved UNet model.

[0026] S5: Iteratively train the improved UNet model using the training set and the validation set, and save the optimal training weights after training to obtain the trained improved UNet model.

[0027] S6: Test and evaluate the trained improved UNet model using the test set and the optimal training weights to obtain defect segmentation results and evaluation metrics.

[0028] Further, in step S1, the initial image dataset contains 206 images selected from publicly available datasets, and the 206 images are labeled at the pixel level according to defect type. The labeled defect types include black core, corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

[0029] Further, in S2, the geometric data enhancement processing includes flipping, rotating, scaling, and random cropping; after the geometric data enhancement processing, a preprocessed image dataset with 758 samples is obtained, and the defect types covered by the 758 samples include black core, edge and corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

[0030] Further, in step S3, the preprocessed image dataset is divided into a training set, a validation set, and a test set according to a preset ratio of 8:1:1.

[0031] Further, in step S4, the VGG16 consists of 13 convolutional layers, 5 pooling layers, and 3 fully connected layers. Cascaded 3×3 convolutional kernels are used to replace large receptive field convolutions in order to reduce the number of parameters while maintaining feature extraction capabilities. The kernels pass through convolutional blocks composed of 3×3 convolutional layers in sequence, with each convolutional block followed by a 2×2 max pooling layer, which is used to halve the feature map size and expand the receptive field.

[0032] Furthermore, in step S4, the hybrid attention mechanism is applied to the feature fusion stage of the decoder, which adaptively adjusts the importance of different channels and spatial locations, enabling the network to focus on key features and suppress irrelevant information.

[0033] Furthermore, in step S4, the hybrid attention mechanism specifically refers to: The input feature map is calibrated through a channel attention branch. The channel attention branch uses parallel global average pooling and global max pooling to capture the spatial context and generate two complementary channel descriptors. The two descriptors are respectively passed through a bottleneck structure consisting of two 1×1 convolution layers. Then, the outputs of the two branches are added element by element and channel attention weights are generated by the Sigmoid function. The channel attention weights are multiplied element by element with the original input features to obtain the channel-enhanced features. Spatial attention processing is performed on the channel-enhanced features. The spatial attention branch calculates the mean and maximum values ​​along the channel dimension to generate two complementary spatial description maps. These maps are then stitched together by the channels to form a feature map. Subsequently, spatial context modeling is performed using a 7×7 convolutional kernel to generate initial spatial attention weights. The initial spatial attention weights are discretized using the Gumbel-Softmax function to generate a hard spatial attention mask. The hard spatial attention mask is then multiplied pixel-by-pixel with the enhanced features of the channel to highlight key regions and suppress irrelevant background.

[0034] Furthermore, in step S4, the improved UNet model fuses the shallow positional information extracted by VGG16 in the encoder with the deep semantic information in the decoder through skip connections, so as to preserve spatial details and improve the accuracy of segmentation boundaries.

[0035] Further, in step S5, Adam is selected as the optimizer, the number of training iterations is 200, the batch size is 16, the momentum value is set to 0.9, the initial learning rate is set to 0.0001, and the input image size of the model is set to 512×512.

[0036] Furthermore, in step S6, the optimal training weights are used to test the model performance on the test set. The average intersection-union ratio, precision, number of floating-point operations, mean precision, and recall are used to measure the merits of the improved UNet model. The defect segmentation results obtained from the test are used as the final output.

[0037] This invention presents a solar cell defect segmentation method based on an improved UNet algorithm. The method first organizes electroluminescent (EL) images of solar cells to obtain a research dataset. Then, it preprocesses the dataset using various geometric enhancement methods, including flipping, rotating, scaling, and random cropping, to obtain preprocessed images. The UNet model is improved by introducing VGG16 as the feature extraction backbone network in the encoder, leveraging its deep convolutional structure and pre-trained weights to enhance multi-scale feature representation capabilities. Next, a hybrid attention mechanism is designed, combining dual-path channel attention with Gumbel-Softmax hard-space attention to suppress background interference and improve boundary segmentation accuracy for solar cell surface defect segmentation. The improved UNet model is then optimized and trained, and the optimal training weights are saved and incorporated into the improved model. Finally, the EL images of the solar cells to be segmented are input into the trained model for testing, and metrics such as mAP, Precision, and Recall are calculated. This invention achieves high-precision and real-time segmentation of various defects in solar cells even in complex backgrounds.

[0038] The solar cell defect segmentation method based on the improved UNet algorithm in this invention has the following advantages: The solar cell defect segmentation method based on the improved UNet algorithm in this invention introduces VGG16 as the backbone network of the UNet encoder. Utilizing its deep convolutional structure, it extracts multi-scale features from low-level texture to high-level semantics, enhancing the model's ability to extract defect morphology while accelerating convergence and improving small-sample generalization performance. This method also employs a novel hybrid attention mechanism, HybridAttention, combining dual-path channel attention with Gumbel-Softmax-based hard-space attention. Dual-path pooling is used for channel calibration, and Gumbel-Softmax is used to generate a hard-space attention mask, effectively suppressing background interference and sharpening boundary responses, thus improving segmentation accuracy while maintaining computational efficiency. Therefore, this solar cell defect segmentation method based on the improved UNet algorithm can solve the problems of complex backgrounds, blurred defect boundaries, easy omission of small defects, and high model computational complexity in existing solar cell defect detection methods using electroluminescent (EL) images, demonstrating strong practical engineering value.

[0039] The following is a more detailed description of the solar cell defect segmentation method based on the improved UNet algorithm according to embodiments of the present invention.

[0040] like Figure 1-5 As shown, the solar cell defect segmentation method based on the improved UNet algorithm in this embodiment of the invention can achieve surface defect segmentation of solar cells. This design significantly improves the segmentation accuracy while effectively reducing the computational complexity of the model, greatly improving the computational efficiency and resource utilization, and enhancing the ability to extract multi-scale defect features and locate boundaries. Therefore, it has good adaptability to edge deployment scenarios with limited computing power.

[0041] In this embodiment, the specific content of step S1 is as follows: We collected publicly available datasets on solar cells to construct a research dataset; and conducted experimental verification using the publicly available large-scale industrial dataset PVEL-AD for photovoltaic cell defect detection. This dataset consists of near-infrared imaging images, which generally suffer from background inhomogeneity. Targeting low-cost, high-efficiency polycrystalline silicon photovoltaic cells, we utilized electroluminescence (EL) imaging technology to visualize and collect internal defects within the cells. The dataset contains a total of 36,543 high-resolution images (1024×1024), from which 206 images were selected and pixel-level finely annotated.

[0042] In this embodiment, the specific content of step S2 is as follows: Geometric data augmentation was performed on the obtained solar cell defect dataset to obtain an expanded image dataset, covering six typical defect types: black core, corner, printing error, short circuit, vertical dislocation, and finger. Figure 3 As shown, six typical examples are listed from left to right: Black Core, Corner, Printing Error, Short Circuit, Vertical Dislocation, and Finger.

[0043] In this embodiment, the specific content of step S3 is as follows: The augmented defect image dataset from step S2 is divided into training, validation, and test sets in an 8:1:1 ratio. Each defect category contains a certain number of samples.

[0044] In this embodiment, the specific content of step S4 is as follows: An improved UNet model is used for surface defect segmentation in solar cells. The improved model structure is as follows: Figure 2 As shown. Step S4 is performed as follows: Specifically, VGG16 is introduced to replace the backbone network in the original UNet encoder. This is to improve the ability to extract features of solar cell defects. VGG16 is introduced as the backbone network in the original UNet encoder for feature enhancement. For example... Figure 4 As shown, the VGG16 model consists of 13 convolutional layers, 5 pooling layers, and 3 fully connected layers. Its core design feature is the adoption of a "small convolutional kernel, deep network" paradigm. First, it uses cascaded 3×3 convolutional kernels to replace large receptive field convolutions. For the input feature map... After two cascaded 3×3 convolutions, a ReLU activation function is introduced after each convolution. By stacking multiple small convolutional kernels instead of large convolutional kernels, the number of parameters is reduced while maintaining the same feature extraction capability, and more non-linear transformations are introduced, enhancing the network's expressive power. This is followed by five consecutive 3×3 convolutional blocks, each connected to a 2×2 max-pooling layer.

[0045] Specifically, to further improve segmentation accuracy, a HybridAttention mechanism is introduced between the encoder and decoder. This mechanism combines dual-path channel attention with hard-space attention based on Gumbel-Softmax. For example... Figure 5 As shown, the overall processing flow is as follows: First, for the input feature map... HybridAttention performs feature calibration through a channel attention branch. This branch uses parallel Global Average Pooling (GAP) and Global Max Pooling (GMP) to capture spatial context, generating two complementary channel descriptors: (1) in, These represent performing global average pooling and global max pooling on the feature map, respectively. These two descriptors are each passed through a bottleneck structure consisting of two 1×1 convolutions. Then, the outputs of the two branches are summed element-wise and channel attention weights are generated using the Sigmoid function. (2) in, Represents the Sigmoid function. This represents two fully connected layers.

[0046] Secondly, channel attention weights The original input features are multiplied element-wise to obtain the channel-enhanced features. Next, spatial attention processing is applied to the channel-enhanced features. This branch first calculates the mean and maximum along the channel dimension, generating two complementary spatial description maps, which are then concatenated through channel stitching. The feature maps are then used for spatial context modeling via 7×7 convolutional kernels to generate initial spatial attention weights. Finally, the Gumbel-Softmax function is introduced to discretize the weights. During the training phase, Gumbel noise, adjusted by a temperature parameter, is injected to enable the network to learn the discretized attention distribution. The sampling process is as follows: in, This represents the first element in the approximate discrete probability distribution after continuous relaxation. Output probability values ​​for each category The model predicts the first The original probabilities of each category, It is random noise independently sampled from the Gumbel distribution, used to simulate the randomness of discrete sampling. The temperature parameter controls the smoothness of the output distribution. The resulting hard-space attention mask is multiplied pixel-by-pixel with the channel enhancement features, effectively suppressing irrelevant background while highlighting key areas.

[0047] In this embodiment, the specific content of step S5 is as follows: The improved UNet model is iteratively trained using the training and validation sets, and the optimal training weights are saved. Specifically, the environment setup involved downloading the official source code of the UNet model from GitHub and creating a virtual environment using Anaconda based on the dependency library files of the UNet source code. The experiments in this invention were conducted on an NVIDIA RTX 4060 Ti GPU with 16GB of VRAM using the PyTorch 2.1.0 + CUDA 12.6 framework. The code was implemented in Python 3.9, using pre-trained VGG16 initial weights.

[0048] Specifically, the hyperparameter configuration is as follows: input image size is 512×512, batch size is set to 16, training iterations are 200, Adam is selected as the optimizer, momentum value is set to 0.9, and initial learning rate is 0.0001.

[0049] Specifically, the pre-trained model and VGG16 pre-trained weights are loaded, and iterative training begins. After a specified number of 200 epochs, the trained model is saved.

[0050] In this embodiment, the specific content of step S6 is as follows: The trained defect segmentation model is used to perform performance testing on the test set in the dataset. After the training process is complete, a defect segmentation model weight file is generated, which is then used to test the model's performance.

[0051] To verify the effectiveness of the method of the present invention, a series of ablation experiments were designed using UNet as the benchmark model. Key modules such as VGG16 and HybridAttention were added in sequence for ablation comparison. The experimental results are shown in Table 1. The table clearly shows the performance indicators of the model under different experimental conditions. The above data provides an empirical basis for verifying the effectiveness of the method of the present invention.

[0052] Table 1 Comparison of Ablation Experiment Results Experiments verified that, using the original UNet as the baseline model, its MIoU, mPA, Precision, and Recall were 39.78%, 44.75%, 59.42%, and 44.75%, respectively, with a computational cost of 3.712T. Introducing VGG16 as the encoder backbone network significantly improved all model metrics, with MIoU, mPA, Precision, and Recall reaching 71.10%, 77.74%, 86.76%, and 77.74%, respectively, while reducing the computational cost to 452.310G, demonstrating the effectiveness of VGG16 in extracting multi-scale features and accelerating convergence. Furthermore, introducing the HybridAttention mechanism (i.e., the complete DSANet-UNet model) further improved MIoU, mPA, Precision, and Recall to 76.14%, 82.31%, 88.95%, and 82.31%, respectively, with only a slight increase in computational cost to 452.441G. Compared to the original UNet, MIoU, mPA, Precision, and Recall are improved by 36.36%, 37.56%, 29.53%, and 37.56%, respectively, while the computational cost is reduced by approximately 88%. Considering all these indicators, the solar cell defect segmentation method based on the improved UNet model proposed in this invention significantly improves segmentation accuracy while greatly reducing computational complexity, making it an ideal model for solar cell defect detection.

[0053] This embodiment addresses the dual requirements of segmentation accuracy and computational efficiency in photovoltaic cell defect detection by designing a deep learning model, DSANet-UNet, for defect segmentation in solar cell EL imaging. Based on the UNet architecture, this model introduces VGG16 as the encoder backbone network, utilizing its deep convolutional structure and pre-trained weights to systematically extract multi-scale features from low-level texture to high-level semantics, enhancing the model's ability to extract defect morphology while accelerating convergence and improving small-sample generalization performance. Furthermore, a hybrid attention mechanism, HybridAttention, is designed, innovatively combining dual-path channel attention with Gumbel-Softmax-based hard-space attention. Channel calibration is achieved through dual-path pooling, and Gumbel-Softmax is used to generate a hard-space attention mask, effectively suppressing complex background interference and sharpening defect boundary responses, thus improving segmentation accuracy while maintaining computational efficiency. In addition, based on publicly available datasets, this invention constructs a segmentation dataset covering multiple typical defect types through pixel-level fine annotation and data augmentation. Experimental results show that, compared with the original UNet and existing attention mechanisms, this invention achieves the best performance in multiple evaluation metrics, realizing an ideal balance between detection accuracy and computational efficiency, and has good application prospects.

[0054] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A method for defect segmentation of solar cells based on an improved UNet algorithm, characterized in that, Includes the following steps: S1: Acquire image data of solar cell defects to be detected as the initial image dataset; S2: Perform geometric data augmentation on the initial image dataset to obtain a preprocessed image dataset; S3: Divide the preprocessed image dataset into a training set, a validation set, and a test set according to a preset ratio; S4: An improved UNet model is constructed based on the UNet algorithm. The improved UNet model includes: replacing the backbone network in the encoder with VGG16, using the deep convolutional structure and pre-trained weights of VGG16 to extract multi-scale features from low-level texture to high-level semantics, and fusing shallow positional information with deep semantic information through skip connections; and introducing a hybrid attention mechanism in the decoder. The hybrid attention mechanism uses global average pooling and global max pooling in parallel for dual-path channel attention calibration, and introduces Gumbel-Softmax to achieve hard-space attention selection to suppress background interference and enhance the accuracy of defect boundary segmentation, thus obtaining the improved UNet model. S5: Iteratively train the improved UNet model using the training set and the validation set, and save the optimal training weights after training to obtain the trained improved UNet model; S6: Test and evaluate the trained improved UNet model using the test set and the optimal training weights to obtain defect segmentation results and evaluation metrics.

2. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S1, the initial image dataset contains 206 images selected from publicly available datasets, and the 206 images are labeled at the pixel level according to defect type. The labeled defect types include black core, edge and corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

3. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In S2, the geometric data augmentation process includes flipping, rotating, scaling, and random cropping; after the geometric data augmentation process, a preprocessed image dataset with 758 samples is obtained, and the defect types covered by the 758 samples include black core, edge and corner defects, printing errors, short circuits, vertical misalignment, and finger defects.

4. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S3, the preprocessed image dataset is divided into a training set, a validation set, and a test set according to a preset ratio of 8:1:

1.

5. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S4, the VGG16 consists of 13 convolutional layers, 5 pooling layers, and 3 fully connected layers. Cascaded 3×3 convolutional kernels are used to replace large receptive field convolutions in order to reduce the number of parameters while maintaining feature extraction capabilities. The kernels pass through convolutional blocks composed of 3×3 convolutional layers in sequence. Each convolutional block is followed by a 2×2 max pooling layer, which is used to halve the feature map size and expand the receptive field.

6. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S4, the hybrid attention mechanism is applied to the feature fusion stage of the decoder. By adaptively adjusting the importance of different channels and spatial locations, the network focuses on key features and suppresses irrelevant information.

7. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S4, the hybrid attention mechanism specifically refers to: The input feature map is calibrated through a channel attention branch. The channel attention branch uses parallel global average pooling and global max pooling to capture the spatial context and generate two complementary channel descriptors. The two descriptors are respectively passed through a bottleneck structure consisting of two 1×1 convolution layers. Then, the outputs of the two branches are added element by element and channel attention weights are generated by the Sigmoid function. The channel attention weights are multiplied element by element with the original input features to obtain the channel-enhanced features. Spatial attention processing is performed on the channel-enhanced features. The spatial attention branch calculates the mean and maximum values ​​along the channel dimension to generate two complementary spatial description maps. These maps are then stitched together by the channels to form a feature map. Subsequently, spatial context modeling is performed using a 7×7 convolutional kernel to generate initial spatial attention weights. The initial spatial attention weights are discretized using the Gumbel-Softmax function to generate a hard spatial attention mask. The hard spatial attention mask is then multiplied pixel-by-pixel with the enhanced features of the channel to highlight key regions and suppress irrelevant background.

8. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S4, the improved UNet model fuses the shallow positional information extracted by VGG16 in the encoder with the deep semantic information in the decoder through skip connections, so as to preserve spatial details and improve the accuracy of segmentation boundaries.

9. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S5, Adam is selected as the optimizer, the number of training iterations is 200, the batch size is 16, the momentum value is set to 0.9, the initial learning rate is set to 0.0001, and the input image size of the model is set to 512×512.

10. The solar cell defect segmentation method based on the improved UNet algorithm according to claim 1, characterized in that: In step S6, the optimal training weights are used to test the model performance on the test set. The performance of the improved UNet model is measured by the mean intersection-union ratio, precision, number of floating-point operations, mean precision, and recall. The defect segmentation results obtained from the test are used as the final output.