Photovoltaic cell defect detection method based on improved YOLOv8n model

CN123032673APending Publication Date: 2026-11-03XIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611253630.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-18
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing defect detection methods suffer from low accuracy in complex industrial environments due to the small defect area of ​​photovoltaic cells.

Method used

An improved method for photovoltaic cell defect detection using the YOLOv8n model is proposed. This method optimizes the network structure, reduces model parameters and computational load, and improves detection accuracy by adjusting the number of detection heads and feature extraction modules, introducing C2f-PConv modules, spatial-to-depth convolution modules, lightweight joint attention mechanisms, and shallow information enhancement modules.

Benefits of technology

While maintaining the model's lightweight design, it improves detection accuracy and target positioning precision, enabling better handling of the location information of small targets and meeting the real-time detection needs of industrial sites.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123032673A_ABST
    Figure CN123032673A_ABST
Patent Text Reader

Abstract

The application discloses a photovoltaic cell defect detection method based on an improved YOLOv8n model, collects a photovoltaic cell defect image original data set, improves the number of detection heads and a feature extraction module of the YOLOv8n model, obtains an improved YOLOv8n model, trains the improved YOLOv8n model, obtains optimal weights, applies the optimal weights on a verification set and a test set, obtains model evaluation indexes, adopts the improved YOLOv8n model to perform photovoltaic cell defect detection, and outputs detection results. According to the characteristics of the photovoltaic cell defect data set, the detection layer and the feature extraction network are improved. Considering the demand for light weight, the complexity and the amount of calculation of the model are reduced while the original detection accuracy is maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of photovoltaic cell defect detection methods, and relates to a photovoltaic cell defect detection method based on an improved YOLOv8n model. Background Technology

[0002] Photovoltaic cells are one of my country's important new energy sources, and the continuous expansion of its industry has made significant contributions to the national economy. However, the impact of photovoltaic cell defects on cell quality and electrical safety cannot be ignored. These defects mainly occur in the crystalline silicon material of photovoltaic cells, especially in the pre-treatment areas of silicon wafers, where their characteristics are more pronounced and are a key means of defect identification. Therefore, the ability to detect these defects in a timely and accurate manner not only provides a foundation for photovoltaic cell quality inspection and monitoring and electrical safety but also represents a research topic of profound significance.

[0003] Traditional defect detection methods rely on the subjective judgment of experts and workers, but this approach has many limitations: slow speed, high false positive rate, and lack of real-time capability, failing to meet the current demand for rapid and accurate defect identification. With technological advancements, the development of convolutional neural networks has made deep learning-based photovoltaic cell defect detection possible, gradually replacing traditional diagnostic methods through automated image detection. The YOLO model's single-stage target detection algorithm ensures high accuracy while detecting photovoltaic cell defects in real time. Nevertheless, the low detection accuracy caused by the small defect area of ​​photovoltaic cells in complex industrial environments still awaits a solution from researchers. Summary of the Invention

[0004] The purpose of this invention is to provide a photovoltaic cell defect detection method based on an improved YOLOv8n model, which solves the problem of low detection accuracy caused by the small defect area of ​​photovoltaic cells in complex industrial environments.

[0005] The technical solution adopted in this invention is a photovoltaic cell defect detection method based on an improved YOLOv8n model. This involves collecting a raw dataset of images of silicon wafers, the raw material for photovoltaic cells, improving the number of detection heads and feature extraction module of the YOLOv8n model to obtain an improved YOLOv8n model, training the improved YOLOv8n model to obtain optimal weights, applying these optimal weights to the validation and test sets to obtain model evaluation metrics, and then using the improved YOLOv8n model to detect photovoltaic cell defects and outputting the detection results.

[0006] The technical solution adopted in this invention is also characterized by: The photovoltaic cell defect detection method based on the improved YOLOv8n model is implemented according to the following steps: Step 1: Collect the original dataset of photovoltaic cell defect images, use data augmentation techniques to augment the original dataset, and divide the augmented photovoltaic cell defect dataset into training set, validation set and test set; Step 2: First, the number of detection layers in the YOLOv8n model is systematically adjusted; then, a C2f-PConv module is constructed to replace the C2f module in the YOLOv8n model; next, a spatial-to-depth convolution module and a lightweight joint attention mechanism are integrated into the feature extraction network of the YOLOv8n model; finally, a shallow information enhancement module is constructed and integrated into the detection layer to obtain the improved YOLOv8n model. Step 3: Train the improved YOLOv8n model using the training set to obtain the optimal weights; Step 4: Apply the optimal weights to the validation set and test set to obtain the model evaluation index, and evaluate the model improvement effect based on the evaluation index. Step 5: Use the improved YOLOv8n model from Step 4 to detect defects in photovoltaic cells and output the detection results.

[0007] Step 1 is implemented in the following steps: Step 1.1: Collect images of photovoltaic panels under different lighting conditions; the method for collecting images of photovoltaic cell defects in Step 1.1 is to take photos by oneself.

[0008] Step 1.2: Use data augmentation techniques to augment the images collected in Step 1.1 and label the images. Divide the dataset images into four categories: only fluorescent light, direct sunlight, dim light, and simulated rain. Step 1.3: Divide the labeled images into training set, test set and validation set in a 7:2:1 ratio.

[0009] Step 2 is implemented in the following steps: Step 2.1: Reduce the original detection heads of the YOLOv8n model (80×80, 40×40, and 20×20) to 80×80 and 40×40, and reset the anchor frame size using automatic anchor frame technology; replace the information fusion module C2f in the model with C2f-PConv, thereby effectively reducing the model parameters. Step 2.2: Based on the new detection layer structure, a spatial-to-depth convolution module is introduced to optimize and improve the feature extraction network of the YOLOv8n model; Step 2.3: Redesign the lightweight joint attention mechanism and introduce it into the SPPF module. Name the improved SPPF module Lite-attention-SPPF module to effectively improve the efficiency of feature information fusion. Step 2.4: Construct a shallow information enhancement module and integrate it into the small target detection layer to enhance the model's ability to perceive sensitive features such as the texture and color of the target.

[0010] In step 2.1, to effectively reduce model parameters, a C2f-PConv module is constructed. The PConv module is specifically designed as follows: the input feature map of size C×H×W is divided into four groups of feature maps of size C×H / 4×W, and then a standard convolution operation with a kernel size of 1×1 is performed on each group. Finally, the four groups of feature maps are combined through channel shuffling to improve information fusion efficiency and then concatenated to output the final result. The PConv module is then introduced into C2f to replace the original convolution module and form the C2f-PConv module.

[0011] Step 2.2 redesigned the feature extraction network of the YOLOv8n model. Specifically, spatial-to-depth convolutions replaced the last two convolutional modules of the YOLOv8n model's backbone network. The spatial-to-depth convolutions work by first transforming the input feature map into four sub-images using a 2×2 grid, then concatenating them along the channel dimension, transforming H×W×C into H / 2×W / 2×4C. This reduces the spatial dimension by a factor of 2 and expands the channel dimension by a factor of 4, without any pixel loss during the process. Finally, a regular convolution with a stride of 1 is applied for fusion and dimensionality reduction.

[0012] In step 2.3, to improve the fusion efficiency of the original SPPF module, the SPPF module is improved into a Lite-attention-SPPF module. The lightweight joint attention mechanism is as follows: In the spatial attention module, after a standard convolution with a kernel size of 1×1 to compress the number of channels to 1 / 8 of the original, a ReLU activation function is used to enhance the non-linear expression, followed by a standard convolution with a kernel size of 1×1 to restore the channels, and finally a Sigmoid activation function is used to obtain the weights of the spatial dimension. In the channel attention module, after an average pooling module with a kernel size of 3×3, a standard convolution with a kernel size of 1×1 to compress the number of channels to 1 / 16 of the original, a ReLU activation function is used to enhance the non-linear expression of the model, and a standard convolution with a kernel size of 1×1 to restore the channels, and finally a Sigmoid activation function is used to obtain the weights of the channel dimension. The weights generated by the two attention modules are then fused with the original feature map.

[0013] The shallow information enhancement module in step 2.4 specifically consists of a color space conversion mechanism and an attention mechanism. The color space conversion module first performs channel compression using a convolution-normalization-SiLU activation function with a kernel of 1 to obtain a feature map of size C / 4×H×W. Then, it performs affine transformation using a standard convolution module with a kernel of 1, and then obtains shallow information features through the SiLU activation function. The feature map calculation formula of the color space conversion mechanism is shown in equation (1).

[0014] in, The feature map representing the input. The feature map representing the output. The standard convolutional layer uses a convolution with a kernel of 1. The input is SiLU activation function, Batch Normalization (BN) is two-dimensional normalization, and the attention mechanism module first performs average pooling, followed by two standard convolutional modules with 3 kernels, and then two SiLU activation functions to obtain a feature map of size C / 4×H×W. Finally, element-wise multiplication based on a broadcast mechanism is used to generate a feature map of dimension C×H×W through weighted fusion, ensuring that it is exactly the same as the input size. The formula for calculating the attention mechanism feature map is shown in equation (2):

[0015] in, The final output feature map of the attention mechanism is GAP, which represents the average pooling operation. This represents the first standard convolution with a kernel size of 3. This represents the second standard convolution with a kernel size of 3. Represents the SiLU activation function; It's batch size. It is the number of channels; Step 3 is implemented in the following steps: Step 3.1, setting hyperparameters: initial learning rate is 0.01, maximum learning rate is 0.1, momentum is 0.937, weight is 0.0005, number of training epochs is 100, training batch size is 16, and Adam optimizer is used as the optimizer. Step 3.2, Model training path selection: Select the above-defined training set for training to obtain the optimal weights.

[0016] Step 4 is implemented in the following steps: Validate and test on the validation and test sets using optimal weights; use the mean to average precision. The parameters and model size are used to evaluate the effectiveness of model improvement. The specific calculation formula is shown in equation (3):

[0017] in, n For the number of categories, AP This represents the average accuracy.

[0018] The beneficial effects of this invention are: The detection method of this invention improves the original detection layer and feature extraction network based on the characteristics of photovoltaic cell defect datasets. To meet the need for lightweight design, the complexity and computational cost of the model are reduced while maintaining the original detection accuracy. By optimizing for the characteristics of photovoltaic cell defects, the original detection layer and feature extraction network are successfully improved, making the model more efficient.

[0019] In addition to improving the original model structure, the detection method of this invention introduces a lightweight joint attention mechanism to further enhance the model's detection accuracy. By integrating and weighting channel and spatial information, it can better understand the relative positional relationships between different dimensions and apply this information to the detection process. Therefore, the model of this invention not only improves detection accuracy while maintaining a lightweight design, but also more precisely locates the target position.

[0020] The detection method of this invention also addresses the small size of photovoltaic cell defects, where traditional detection layers are easily affected by the complexity of the surrounding environment and background. To this end, the detection method of this invention proposes a shallow information enhancement module, enabling it to better handle the positional information of small targets. After optimization, the improved model of this invention achieves significant improvements in convergence speed and positioning accuracy. The optimization measures of this invention not only improve the training effect of the model but also make the model more reliable and accurate in practical applications. Attached Figure Description

[0021] Figure 1 This is a diagram of the improved YOLOv8n network structure of this invention; Figure 2 This is a structural diagram of the shallow information enhancement module proposed in this invention; Figure 3 This invention proposes a joint lightweight attention mechanism; Figure 4 This is a structural diagram of the PConv convolutional module proposed in this invention; Figure 5 This is a diagram of the spatial-to-depth convolutional structure referenced in this invention. Detailed Implementation

[0022] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0023] Example 1 Photovoltaic cells are susceptible to various types of damage during production and long-term outdoor service. Limited by the inherent properties of the substrate, these defects, coupled with the continuous effects of external environmental factors such as moisture erosion and oxidation, wind and sand abrasion, and diurnal temperature stress, gradually lead to aging and deterioration of the modules. These defects are often difficult to detect with the naked eye, exhibiting scattered distribution and subtle texture features. Under natural light, they easily blend into the normal areas of the cell. Furthermore, some minute aging defects have extremely low grayscale differences, making them prone to being missed during actual inspection. In addition, these defects disrupt the photoelectric conversion transmission path of the photovoltaic cell, hindering normal photon absorption and carrier transport, directly causing a significant decrease in the power generation efficiency of the photovoltaic module. Long-term operation with these defects can also easily lead to localized overheating and accelerated circuit aging, potentially causing module failure and shutdown, drastically reducing the overall lifespan of the photovoltaic module, and ultimately adversely affecting the power generation stability and operational economic benefits of the photovoltaic power plant.

[0024] To achieve accurate and efficient detection of such defects, it is first necessary to improve the model's ability to perceive subtle defects and enhance its ability to extract minute flaw features. Secondly, the network structure should be optimized to enhance the model's ability to fuse multi-dimensional features and aggregate information. Finally, by simplifying the network structure and reducing redundant parameters, the model can be lightweighted, effectively improving the algorithm's inference speed and meeting the application requirements of real-time detection and rapid feedback in industrial settings.

[0025] This invention provides a photovoltaic cell defect detection method based on an improved YOLOv8n model. The method involves collecting a raw dataset of photovoltaic cell defect images, improving the number of detection layers and feature extraction module of the YOLOv8n model to obtain an improved YOLOv8n model, training the improved YOLOv8n model to obtain optimal weights, applying these optimal weights to the validation and test sets to obtain model evaluation metrics, and then using the improved YOLOv8n model to detect photovoltaic cell defects and outputting the detection results.

[0026] Example 2 This invention relates to a photovoltaic cell defect detection method based on an improved YOLOv8n model, which is implemented according to the following steps: Step 1: Collect the original dataset of photovoltaic cell defect images, use data augmentation techniques to augment the original dataset, and divide the augmented photovoltaic cell defect dataset into training set, validation set and test set; Step 1.1: Collect images of photovoltaic panels under different lighting conditions. The defect images in Step 1.1 were collected by taking photos by the user. Step 1.2: Use data augmentation techniques to augment the images collected in Step 1.1 and then label the images. Step 1.3: Divide the labeled images into training set, test set and validation set in a 7:2:1 ratio.

[0027] Step 2: Improve the number of detection layers and feature extraction module of YOLOv8n model. Integrate spatial to depth convolution module and lightweight joint attention mechanism into YOLOv8n model. Construct C2f-PConv module to replace C2f module of original YOLOv8n model. Construct shallow information enhancement module and integrate it into detection layer part to obtain improved YOLOv8n model. like Figure 1 As shown, step 2 is implemented in the following steps: Step 2.1: Reduce the original detection layers of the YOLOv8n model (80×80, 40×40, and 20×20) to 80×80 and 40×40, and reset the anchor frame size using automatic anchor frame technology. Replace the information fusion module C2f in the model with C2f-PConv, thereby effectively reducing the model parameters. Step 2.2: Based on the new model structure, a spatial-to-depth convolution module is introduced to optimize and improve the feature extraction network of the YOLOv8n model; Step 2.3: Redesign the lightweight joint attention mechanism and introduce it into the SPPF module. Name the improved SPPF module Lite-attention-SPPF module to effectively improve the efficiency of feature information fusion. Step 2.4: Construct a shallow information enhancement module and integrate it into the small target detection layer to enhance the model's ability to perceive sensitive features such as the texture and color of the target.

[0028] Step 3: Train the improved YOLOv8n model using the training set to obtain the optimal weights; Step 4: Apply the optimal weights to the validation set and test set to obtain the model evaluation index, and evaluate the model improvement effect based on the evaluation index. Step 5: Use the improved YOLOv8n model from Step 4 to detect defects in photovoltaic cells and output the detection results.

[0029] Example 3 Based on Example 2, In step 2.1, to effectively reduce model parameters, a C2f-PConv module is constructed. The PConv module specifically divides the input feature map of size C×H×W into four groups of feature maps of size C×H / 4×W, and then performs standard convolution operations with a kernel size of 1×1 on each group. Finally, the four groups of feature maps are combined through channel shuffling to improve information fusion efficiency and then concatenated to output the final result.

[0030] Step 2.2 redesigned the feature extraction network of the YOLOv8n model. Specifically, spatial-to-depth convolutions replaced the last two convolutional modules of the YOLOv8n model backbone. The spatial-to-depth convolutions work by first transforming the input feature map into four sub-images using a 2×2 grid, then concatenating them along the channel dimension, transforming H×W×C into H / 2×W / 2×4C. This reduces the spatial dimension by a factor of 2 and expands the channel dimension by a factor of 4, without any pixel loss during the process. A regular convolution with a stride of 1 is then applied for fusion and dimensionality reduction.

[0031] In step 2.3, to improve the fusion efficiency of the original SPPF module, the SPPF module is improved into a Lite-attention-SPPF module. Specifically, in the spatial attention module, after a standard convolution with a kernel size of 1×1 to compress the number of channels to 1 / 8 of the original, a ReLU activation function is used to enhance the non-linear expression, followed by a standard convolution with a kernel size of 1×1 to restore the channels, and finally a Sigmoid activation function is used to obtain the spatial dimension weights. In the channel attention module, after an average pooling module with a kernel size of 3×3, a standard convolution with a kernel size of 1×1 to compress the number of channels to 1 / 16 of the original, a ReLU activation function is used to enhance the non-linear expression of the model, and a standard convolution with a kernel size of 1×1 to restore the channels, and finally a Sigmoid activation function is used to obtain the channel dimension weights. The weights generated by the two attention modules are then fused with the original feature map.

[0032] The shallow information enhancement module in step 2.4 specifically consists of a color space conversion mechanism and an attention mechanism. The color space conversion module first performs channel compression using a convolution-normalization-SiLU activation function with a kernel of 1 to obtain a feature map of size C / 4×H×W. Then, it performs affine transformation using a standard convolution module with a kernel of 1, and then obtains shallow information features through the SiLU activation function. The feature map calculation formula of the color space conversion mechanism is shown in equation (1).

[0033] in, The feature map representing the input. The feature map representing the output. The standard convolutional layer uses a convolution with a kernel of 1. The input layer is a SiLU activation function, and Batch Normalization (BN) is a two-dimensional normalization layer. The attention mechanism module first performs average pooling, followed by two standard convolutional modules with 3×3 kernels, and then two SiLU activation functions to obtain a feature map of size C / 4×H×W. Finally, element-wise multiplication based on a broadcast mechanism is used to generate a feature map of dimension C×H×W through weighted fusion, ensuring that it is exactly the same size as the input. The formula for calculating the attention mechanism feature map is shown in equation (2):

[0034] in, The final output feature map of the attention mechanism is GAP, which represents the average pooling operation. This represents the first standard convolution with a kernel size of 3. This represents the second standard convolution with a kernel size of 3. This represents the SiLU activation function.

[0035] Example 4 Based on Example 3, step 3 is specifically implemented according to the following steps: Step 3.1, setting hyperparameters: initial learning rate is 0.01, maximum learning rate is 0.1, momentum is 0.937, weight is 0.0005, number of training epochs is 100, training batch size is 16, and Adam optimizer is used as the optimizer. Step 3.2, Model training path selection: Select the above-defined training set for training to obtain the optimal weights.

[0036] Step 4 is implemented in the following steps: Validate and test on the validation and test sets using optimal weights; use the mean to average precision. The parameters and model size are used to evaluate the effectiveness of model improvement. The specific calculation formula is shown in equation (3):

[0037] in, n For the number of categories, AP This represents the average accuracy.

[0038] Example 5 This invention relates to a photovoltaic cell defect detection method based on an improved YOLOv8n model, which is implemented according to the following steps: Step 1: Capture a dataset of photovoltaic cell defects, perform data augmentation and manual annotation on the dataset, specifically as follows: Step 1.1: Take 417 images of photovoltaic cell defects at different time periods and under different lighting conditions, and use these 417 images as the original images for the photovoltaic cell defect dataset; Step 1.2: Use data augmentation techniques to expand the 417 images to 2085 images, and manually label the 2085 images; Step 1.3: Divide the 2085 labeled images into a 7:2:1 ratio into a training set of 1460 images, a test set of 417 images, and a validation set of 209 images; Step 2: Improve the YOLOv8n model based on the characteristics of the dataset to obtain the improved YOLOv8n model; Step 2.1: The original detection layers of the YOLOv8n model can be divided into 80×80, 40×40, and 20×20. Based on the characteristics of the dataset presented in this invention, 40×40 and 20×20 layers are selected as the detection layers for the improved method of this invention, and the anchor box size is reset using automatic anchor box technology. To reduce the model's parameters and computational complexity, this invention replaces the information fusion module C2f in the model with C2f-PConv, as shown below. Figure 4 As shown, the PConv module specifically works as follows: It divides the input feature map of size C×H×W into four groups of feature maps of size C×H / 4×W, performs standard convolution operations with a kernel size of 1×1 on each group, then applies a Channel Shuffle operation to the four groups of feature maps to improve information fusion efficiency, and finally concatenates them to output the final result. The C2f-PConv module is constructed by introducing the PConv module into C2f to replace the original convolution module. Step 2.2: Based on the new model structure, redesign the feature extraction network of the YOLOv8n model, such as... Figure 1 As shown: Depthwise convolutions are used to replace the last two convolutional modules in the original YOLOv8n model backbone to improve the model's performance in handling low-quality images with poor lighting conditions and unclear images. Specifically, spatial-to-depth convolution transforms the input feature map into four sub-images using a 2×2 grid (e.g., ...). Figure 5 This involves concatenating along the channel dimension, transforming H×W×C into H / 2×W / 2×4C, reducing the spatial density by a factor of 2 and expanding the channels by a factor of 4, without any pixel loss during the entire process. This is followed by a regular convolutional fusion reduction with a stride of 1. Step 2.3: To improve the information fusion efficiency of the fast pyramid pooling module in the backbone network, the feature extraction SPPF module is redesigned and renamed the improved SPPF module as the Lite-attention-SPPF module, such as... Figure 3As shown, a lightweight joint attention mechanism is introduced into the SPPF module to improve the efficiency of model feature information fusion. Specifically, the lightweight joint attention mechanism works as follows: In the spatial attention module, after a standard convolution with a 1×1 kernel size compresses the number of channels to 1 / 8 of the original, a ReLU activation function enhances the non-linear expression, another standard convolution with a 1×1 kernel size restores the channels, and finally a Sigmoid activation function is used to obtain the spatial dimension weights. In the channel attention module, after an average pooling module with a 1×1 kernel size, a standard convolution with a 1×1 kernel size compresses the number of channels to 1 / 16 of the original, a ReLU activation function enhances the model's non-linear expression, another standard convolution with a 1×1 kernel size restores the channels, and finally a Sigmoid activation function is used to obtain the channel dimension weights. The weights generated by the two attention modules are then fused with the original feature map. Step 2.4: Following the improvements in steps 2.2 and 2.3, the model's performance has been significantly enhanced. However, to further improve the model's sensitivity to small target information, this paper constructs a shallow information enhancement module and integrates it into the detection layer, as shown below. Figure 2 As shown, the shallow information enhancement module specifically consists of a color space conversion mechanism and an attention mechanism. The color space conversion module first performs channel compression using a convolution-normalized SiLU activation function with a kernel of 1 to obtain a feature map of size C / 4×H×W. Then, it performs affine transformation using a standard convolution module with a kernel of 1, and then obtains shallow information features through the SiLU activation function. The feature map calculation formula of the color space conversion mechanism is shown in Equation (1):

[0039] in, The feature map representing the input. The feature map representing the output. The standard convolutional layer represents a convolution with a kernel of 1. The SiLU activation function is used, BN is a two-dimensional normalization layer, and the attention mechanism module first performs average pooling, then passes through two standard convolutional modules with 3 kernels, and then through two SiLU activation functions to obtain a feature map of size C / 4×H×W. Finally, element-wise multiplication based on a broadcast mechanism is used to generate a feature map of dimension C×H×W through weighted fusion, ensuring that it is exactly the same as the input size. The formula for calculating the attention mechanism feature map is shown in equation (2):

[0040] in, The final output feature map of the attention mechanism is GAP, which represents the average pooling operation. This represents the first standard convolution with a kernel size of 3. This represents the second standard convolution with a kernel size of 3. This represents the SiLU activation function.

[0041] Step 3 specifically involves: Step 3.1, setting hyperparameters: initial learning rate 0.01, maximum learning rate 0.1, momentum 0.937, weights 0.0005; training epochs 100, training batch size 16, using Adam as the optimizer; Step 3.2 involves selecting the training path for the model by choosing the training set divided above to obtain the optimal weights. Step 4 is as follows: Use optimal weights to validate and test on the validation and test sets; Using the mean to average precision mAP The parameters and model size are used to evaluate the effectiveness of model improvement. mAP The specific calculation formula is shown in equation (10):

[0042] in, n For the number of categories, AP This represents the average accuracy.

[0043] Example 6 To demonstrate the superior performance of the improved YOLOv8n model proposed in this invention in photovoltaic cell defect detection, several different target detection models were selected for comparison, including YOLOv3, YOLOv3-tiny, YOLOv5s, YOLOv8n, and YOLOv9c.

[0044] In the experiments, the same training, validation, and test sets were used, and the experimental parameters were kept consistent. Table 1 shows the comparison results of different models: Table 1 Comparison results of different models

[0045] As can be seen from Table 1, the improved YOLOv8n model exhibits high performance in photovoltaic cell defect detection. mAP The model parameters and model size are smaller; in contrast, the model parameters and model size of the YOLOv3 model, YOLOv3-tiny model, YOLOv5s model, YOLOv7 model, and YOLOv8s model are all larger than those of the model in this invention. mAP The value is lower than that of the model of this invention. mAP value; In summary, the improved YOLOv8n model demonstrates superior performance in photovoltaic cell defect detection.

Claims

1. A photovoltaic cell defect detection method based on an improved YOLOv8n model, characterized in that, The original dataset of photovoltaic cell defect images was collected. The number of detection layers and feature extraction module of the YOLOv8n model were improved to obtain an improved YOLOv8n model. The improved YOLOv8n model was trained to obtain the optimal weights. The optimal weights were applied to the validation set and test set to obtain the model evaluation index. The improved YOLOv8n model was used to detect photovoltaic cell defects and the detection results were output.

2. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 1, characterized in that, The specific steps are as follows: Step 1: Collect the original dataset of photovoltaic cell defect images, use data augmentation techniques to augment the original dataset, and divide the augmented photovoltaic cell defect dataset into training set, validation set and test set; Step 2: Improve the number of detection layers and feature extraction module of YOLOv8n model. Integrate lightweight joint attention mechanism and spatial-to-depth convolution module into YOLOv8n model. Construct C2f-PConv module to replace C2f module of YOLOv8n model. Construct shallow information enhancement module and integrate it into detection layer part to obtain improved YOLOv8n model. Step 3: Train the improved YOLOv8n model using the training set to obtain the optimal weights; Step 4: Apply the optimal weights to the validation set and test set to obtain the model evaluation index, and evaluate the model improvement effect based on the evaluation index. Step 5: Use the improved YOLOv8n model from Step 4 to detect defects in photovoltaic cells and output the detection results.

3. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 2, characterized in that, Step 1 is implemented in the following steps: Step 1: Capture a dataset of photovoltaic cell defects, perform data augmentation and manual annotation on the dataset, specifically as follows: Step 1.1: Take pictures of photovoltaic cell defects at different time periods and under different lighting conditions to serve as the original pictures for the photovoltaic cell defect dataset; Step 1.2: Use data augmentation techniques to augment the images collected in Step 1.1 and label the images. Divide the dataset images into four categories: only fluorescent light, direct sunlight, dim light, and simulated rain. Step 1.3: Divide the labeled images into training set, test set and validation set in a 7:2:1 ratio.

4. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 3, characterized in that, In step 1.1, the method for collecting images of photovoltaic cell defects is to take the photos yourself.

5. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 4, characterized in that, Step 2 is implemented in the following steps: Step 2.1: Reduce the original detection layers of the YOLOv8n model (80×80, 40×40, and 20×20) to 80×80 and 40×40, and reset the anchor frame size using automatic anchor frame technology. Replace the information fusion module C2f in the model with C2f-PConv. Step 2.2: Based on the new detection layer size, the feature extraction network of the YOLOv8n model is redesigned, and a spatial-to-depth convolutional enhancement model is introduced into the feature extraction network. Step 2.3: The feature extraction SPPF module is redesigned, a lightweight joint attention mechanism is introduced into the SPPF module, and the improved SPPF module is named Lite-attention-SPPF module. Step 2.4: Construct a shallow information enhancement module and integrate it into the detection layer to complete the improvement of the YOLOv8n model.

6. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 5, characterized in that, In step 2.1, the neck network of the YOLOv8n model is redesigned, specifically by designing the PConv module: the input feature map of size C×H×W is divided into four groups of feature maps of size C×H / 4×W, and then standard convolution operations with a kernel size of 1×1 are performed on each group. The four groups of feature maps are then subjected to channel shuffling to improve information fusion efficiency. Finally, the output results are concatenated, and the PConv module is introduced into the C2f module to replace the original convolution module.

7. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 5, characterized in that, In step 2.2, to enhance the feature extraction efficiency of the model, spatial-to-depth convolution is introduced into the backbone network of the model. Specifically, spatial-to-depth convolution first transforms the input feature map into four sub-images in a 2×2 grid, then concatenates them in the channel dimension, transforming H×W×C into H / 2×W / 2×4C, reducing the space by a factor of 2 and expanding the channels by a factor of 4. There is no pixel loss in the whole process. Then, a regular convolution with a stride of 1 is added for fusion and dimensionality reduction.

8. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 5, characterized in that, In step 2.3, to improve the information fusion efficiency of the Fast Pyramid Pooling SPPF module, a lightweight joint attention mechanism is constructed. Specifically, the lightweight joint attention mechanism involves: introducing a spatial attention module, which compresses the number of channels to 1 / 8 of the original number using a standard convolution with a 1×1 kernel, enhances the nonlinear expression using a ReLU activation function, restores the channels using a standard convolution with a 1×1 kernel, and finally obtains the spatial dimension weights using a Sigmoid activation function; and a channel attention module, which compresses the number of channels to 1 / 16 of the original number using a 3×3 average pooling module, enhances the nonlinear expression using a ReLU activation function, restores the channels using a standard convolution with a 1×1 kernel, and finally obtains the channel dimension weights using a Sigmoid activation function. The weights generated by the two attention modules are then fused with the original feature map.

9. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 2, characterized in that, Step 2.4 involves constructing a shallow information enhancement module and integrating it into the detection layer. The shallow information enhancement module specifically consists of a color space conversion mechanism and an attention mechanism. The color space conversion module first performs channel compression using a 3×3 convolution-normalization-SiLU activation function to obtain a feature map of size C / 4×H×W. Then, it performs affine transformation using a 3×3 standard convolution module and then uses the SiLU activation function to obtain shallow information features. The feature map calculation formula for the color space conversion mechanism is shown in Equation (1). in, The feature map representing the input. The feature map representing the output. The standard convolutional layer represents a 1×1 convolutional kernel. The SiLU activation function is used, BN is a two-dimensional normalization layer, and the attention mechanism module first performs average pooling, then passes through two standard convolutional modules with 1×1 kernels, and then through two SiLU activation functions to obtain a feature map of size C / 4×H×W. Finally, element-wise multiplication based on a broadcast mechanism is used to generate a feature map of dimension C×H×W through weighted fusion, ensuring that it is exactly the same as the input size. The formula for calculating the attention mechanism feature map is shown in equation (2): in, The final output feature map of the attention mechanism is GAP, which represents the average pooling operation. This represents the first standard convolution with a kernel size of 1×1. This represents the second standard convolution with a kernel size of 1×1. Represents the SiLU activation function; It's batch size. It refers to the number of channels.

10. The photovoltaic cell defect detection method based on the improved YOLOv8n model according to claim 2, characterized in that, Step 3 is implemented in the following steps: Step 3.1, setting hyperparameters: initial learning rate is 0.01, maximum learning rate is 0.1, momentum is 0.937, weight is 0.0005, number of training epochs is 100, training batch size is 16, and Adam optimizer is used as the optimizer. Step 3.2, Model training path selection: Select the above-defined training set for training to obtain the optimal weights; Step 4 is implemented in the following steps: Validate and test on the validation and test sets using optimal weights; use the mean to average precision. The parameters and model size are used to evaluate the effectiveness of model improvement. The specific calculation formula is shown in equation (3): in, n For the number of categories, AP This represents the average accuracy.