A method for detecting cell screen printing defects based on improved YOLOv5
By improving the YOLOv5 network model, combining the CBAM module and small object detection layer, the problems of insufficient detection accuracy and speed and high error detection rate in the prior art are solved, and more efficient and accurate detection of cell screen printing defects is achieved.
Patent Information
- Application Number
- CN202411095016.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-08-12
AI Technical Summary
In the detection of screen printing defects of solar cell cells, the detection accuracy and speed are insufficient, and the error detection rate is high, resulting in low detection reliability and efficiency.
The improved YOLOv5 network model, called the PCDD-YOLOv5 network model, is used to enhance the feature extraction and fusion capabilities by merging C3 modules in the backbone network and adding CBAM modules, and a small object detection layer is added to the neck network to enhance the detection capabilities of small defect targets.
It significantly improves the accuracy of screen printing defect detection of battery cells, reduces the error detection rate, improves the accuracy and efficiency of detection, and ensures effective detection of smaller defect targets.
Smart Images

Figure CN118691601B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of battery cell detection, and in particular to a battery cell screen printing defect detection method based on improved YOLOv5. Background Art
[0002] Photovoltaic power generation has the characteristics of being pollution-free and renewable. Solar power generation is being continuously developed and applied. During the development process, solar cells are the core of converting light energy into electrical energy. Due to the complexity of the solar cell manufacturing process and the instability of human factors, the screen printing process is one of the processes that is prone to defects in the production of cells. This process refers to the screen printing machine printing a predetermined pattern on the cell, and preparing metal electrodes and grid lines on the front and back of the cell through silver paste and aluminum paste to enable it to derive current. The screen printing process mainly produces five screen printing defects: broken grid, thick line, node, leakage and virtual printing. These defects will directly affect the conversion efficiency of solar cells, and also affect the service life of solar cells. They may also bring safety hazards during use. Therefore, it is necessary to perform defect detection on the surface of the cell to ensure that defective cells are removed to ensure product quality and safety.
[0003] For example, the patent document with Chinese patent application number 202311042831.0 and publication date of September 15, 2023, discloses a method and system for detecting screen printing defects of solar cells, including the following contents: obtaining a solar cell image; graying the solar cell image; filtering and denoising the grayed solar cell image; performing brightness equalization on the solar cell image after filtering and denoising; performing contrast equalization on the solar cell image after brightness equalization; registering the solar cell image after contrast equalization; performing bilinear interpolation on the registered solar cell image; detecting whether there is a screen printing defect through a convolutional neural network, and outputting the type of the screen printing defect; constructing a loss function of the convolutional neural network, determining the optimal parameters of the convolutional neural network and updating the model parameters with the goal of minimizing the loss function.
[0004] The above-mentioned literature successively performs grayscale conversion, filtering and noise reduction, brightness balancing, contrast balancing, registration and bilinear interpolation processing on the acquired cell images, and then uses a convolutional neural network to detect cell screen printing defects and output the defect types. In solar cell images, screen printing defects are usually small in size and diverse in shape. Traditional convolutional neural networks cannot meet the detection accuracy and speed in actual industrial production, and false detections may occur, resulting in low reliability and low efficiency in cell screen printing defect detection. Summary of the invention
[0005] The purpose of the present invention is to provide a method for detecting screen printing defects of battery cells based on improved YOLOv5, which can effectively improve the detection accuracy of screen printing defects of battery cells and reduce the false detection rate.
[0006] To achieve the above object, the present invention provides a cell screen printing defect detection method based on improved YOLOv5, which is implemented by an improved YOLOv5 network model, wherein the improved YOLOv5 network model is a PCDD-YOLOv5 network model; after merging the C3 modules in the backbone network of the PCDD-YOLOv5 network model, a CBAM module is added to form a CBAMC3 module, wherein the CBAM module includes a spatial attention module and a channel attention module, and a small target detection layer is added to the top layer of the neck network;
[0007] The following steps are also included:
[0008] S1 collects images of screen printing defects of photovoltaic solar cells through a camera and then builds a data set;
[0009] S2 uses data enhancement to expand the number of cell screen printing defect images in the data set, preprocesses the expanded data set, and then annotates it, and divides it into training set, test set, and validation set according to a preset ratio;
[0010] S3 builds the PCDD-YOLOv5 network model;
[0011] S4 inputs the training set in step S2 into the improved PCDD-YOLOv5 network model, and then outputs the type of screen printing defects of the battery cell after detection by the model;
[0012] S4.1 After the training set in step S2 is input to the C3 module of the backbone network, the input image features are first convolved through the channel attention module and then convolved through the spatial attention module to obtain the output feature map of the output backbone network;
[0013] S4.2 fuses the output feature map of the top layer of the backbone network with the output feature map of the second layer in the backbone network through the small target detection layer to output the feature map;
[0014] S4.3 detects the output feature map and outputs the type of screen printing defects of the battery cell;
[0015] S5 evaluates the model trained in step S4, repeats S1 to S4, determines that the screen printing defect image of the battery cell is input into the model, inputs the screen printing defect image of the battery cell to be detected into the model for detection, and outputs the type of screen printing defect.
[0016] The above settings, by using data enhancement to generate new screen printing defect images, thereby expanding the number of data sets, can effectively alleviate the problem of the lack of screen printing defect images and obtain more data samples; by dividing the expanded data samples into training sets, test sets and validation sets in proportion, it is convenient to input the training set into the PCDD-YOLOv5 network model in the future, so as to detect the screen printing defect images and output the type of screen printing defects; through the C3 module, more efficient feature extraction and fusion can be achieved in the deep network, and CBAM is added after the C3 module. The module can significantly improve the attention and sensitivity to defect features. By utilizing the powerful spatial and channel attention mechanisms of the CBAM module, the channel attention can significantly improve the attention to defect features, and the spatial attention can significantly improve the sensitivity to defect features, so that the model can dynamically adjust the importance of different features and more efficiently and accurately capture the key features in the feature map, thereby improving the accuracy of target detection. In addition, adding a small target detection layer can realize the fusion of the output feature map of the top layer with the feature layer of the second layer, thereby forming a larger detection layer, thereby increasing the magnification of the detection layer, thereby ensuring that smaller defect targets can be detected, thereby improving the detection accuracy of screen printing defects in battery cells and reducing the false detection rate.
[0017] Furthermore, in step S2, data enhancement is performed using a Mosaic function.
[0018] The above settings can randomly combine multiple images to increase the diversity and robustness of samples in the dataset.
[0019] Furthermore, the preprocessing of step S2 includes: correction and normalization processing.
[0020] The above settings make it easier for the image to meet the requirements of the input PCDD-YOLOv5 network.
[0021] Furthermore, in step S2, LabelImg labeling software is used to label each type of screen printing defects, and the training set, test set and validation set are divided according to a ratio of 8.5:1:1.
[0022] The above settings facilitate labeling and database creation, while also ensuring that the training set has sufficient data volume.
[0023] Furthermore, the PCDD-YOLOv5 network model in step S3 includes an input end, a backbone network, a neck network and an output end, and the input end is respectively output through the backbone network and the neck network and then through the output end;
[0024] The backbone network includes Conv module, C3 module, CBAM module and SPPF module;
[0025] The Conv module includes convolutional layers, batch normalization layers, and SiLu activation functions;
[0026] The C3 module includes a first path and a second path, the first path consists of a Conv module and more than two BottleNeck modules, and the second path consists of a Conv module;
[0027] The SPPF module includes the Conv module and the Maxpool module;
[0028] The CBAM module includes a channel attention module and a spatial attention module;
[0029] In the backbone network, two or more C3 modules are merged and connected with the CBAM module to form a CBAMC3_n module;
[0030] The neck network includes a small object detection layer.
[0031] The above settings can significantly improve the model's attention and sensitivity to defect features, thereby better extracting fusion features.
[0032] Furthermore, the S4.1 also includes: adaptively calculating the Anchor value of the training set through a clustering algorithm at the input end to ensure that the Anchor value adapts to the distribution characteristics of the data set, the size of the battery cell image at the input end is 640×640, the batchsize is set to 8, and the epoch is set to 300; extracting the features of the screen printing defect image through the backbone network.
[0033] The above settings first calculate and determine the size of the training set, which can facilitate the subsequent detection of samples in the training set and output the corresponding detection results.
[0034] Furthermore, the step S4.1 also includes S4.1.1 to S4.1.3,
[0035] S4.1.1 In the Conv module, the features of the image are extracted from the training set at the input end through the convolution layer to form a feature map, the model training is accelerated through the batch normalization layer, and the complex nonlinear features in the feature map are extracted through the SiLu activation function;
[0036] S4.1.2 In the C3 module, the image features of the first path and the second path are merged, and then the CBAM module is embedded after two or more C3 modules to form a CBAMC3_n module. In the CBAM module, the important channels for extracting features are selected from the feature map through the channel attention module, and then the spatial position information of different features after passing through the important channels is enhanced through the spatial attention module;
[0037] S4.1.3 In the SPPF module, the feature map after the CBAMC3_n module is pooled twice or more, and then the feature maps before and after pooling are merged and output to the neck network after merging.
[0038] With the above settings, the Conv module can convert the feature map into features suitable for subsequent processing, and the C3 module can achieve more efficient feature extraction and fusion in the deep network. Adding the CBAM module after the C3 module can significantly improve the attention and sensitivity to defect features. The powerful spatial and channel attention mechanism of the CBAM module enables the model to dynamically adjust the importance of different features and capture the key features in the feature map more efficiently and accurately, thereby improving the accuracy of target detection. Multi-scale pooling can effectively capture feature information of different scales in the feature map, so that the model can detect target features of different sizes.
[0039] Furthermore, the step S4.2 further includes:
[0040] S4.2.1 Upsample the top layer of the backbone network through the small object detection layer to expand the size of the feature map;
[0041] S4.2.2 fuses the feature map obtained by upsampling the top layer with the feature map of the second layer in the backbone network, and outputs the fused feature map to the prediction category network and the positioning bounding box network.
[0042] The above settings can retain the feature information of a large number of small targets, significantly improve the model's sensitivity and detection ability for small target defects, meet the diverse needs for defect size recognition, and improve the accuracy of model detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of the working method of the present invention.
[0044] Figure 2 It is a structural schematic diagram of the CBAM module in the present invention.
[0045] Figure 3 It is a schematic diagram of the structure of the CBAMC3_n module in the present invention.
[0046] Figure 4 It is a schematic diagram of the structure of the PCDD-YOLOv5 network in the present invention. DETAILED DESCRIPTION
[0047] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0048] like Figure 1-4As shown, a cell screen printing defect detection method based on improved YOLOv5 includes an improved YOLOv5 network model, the improved YOLOv5 network model is a PCDD-YOLOv5 network model, the PCDD-YOLOv5 network model includes an input end, a backbone network, a neck network and an output end; the input end is output through the backbone network and the neck network and then through the output end;
[0049] The backbone network includes Conv module, C3 module, CBAM module and SPPF module.
[0050] The Conv module includes a convolution layer, a batch normalization layer, and a SiLu activation function;
[0051] The C3 module includes a first path and a second path, the first path consists of a Conv module and more than two BottleNeck modules, and the second path consists of a Conv module;
[0052] The SPPF module includes the Conv module and the Maxpool module;
[0053] The CBAM module includes a channel attention module 1 and a spatial attention module 2; wherein the CBAM module is added after two or more C3 modules are merged to form a CBAMC3 module;
[0054] The following specific steps are also included:
[0055] S1 collects images of screen printing defects of photovoltaic solar cells through a camera and then builds a dataset.
[0056] S2 uses Mosaic to perform data enhancement, and then uses data enhancement to expand the number of battery cell screen printing defect images in the data set. The expanded data set is corrected and normalized for preprocessing, and then LabelImg annotation software is used to annotate each type of screen printing defect, and the training set, test set, and validation set are divided according to the preset ratio of 8.5:1:1.
[0057] S3 builds a PCDD-YOLOv5 network model. In this embodiment, in the backbone network, more than two C3 modules are merged and connected with the CBAM module to form a CBAMC3_n module; in the neck network, a small target detection layer is added.
[0058] S4 inputs the training set in step S2 into the improved PCDD-YOLOv5 network model, and then outputs the type of screen printing defects of the battery cell after detection by the model. Step S4 includes S4.1-S4.3;
[0059] S4.1: After the training set in step S2 is input to the C3 module of the backbone network, the input image features are first convolved through the channel attention module and then convolved through the spatial attention module to obtain the output feature map of the output backbone network; S4.1 includes S4.1.0-S4.1.3
[0060] S4.1.0 adaptively calculates the anchor value of the training set through a clustering algorithm at the input end to ensure that the anchor value adapts to the distribution characteristics of the data set. The size of the cell image at the input end is 640×640, the batch size (i.e., batchsize) is set to 8, and the epoch is set to 300. Epoch is a cycle in the neural network training. In this embodiment, the clustering algorithm is a prior art and will not be described in detail here.
[0061] S4.1.1 In the Conv module, the features of the image are extracted from the training set at the input end to form a feature map through the convolution layer, the model training is accelerated through the batch normalization layer, and the complex nonlinear features in the feature map are extracted through the SiLu activation function; in this embodiment, the convolution layer, the batch normalization layer and the SiLu activation function are all implemented by existing functions;
[0062] S4.1.2 In the C3 module, the image features of the first path and the second path are merged, and then the CBAM module is embedded after more than two C3 modules to form a CBAMC3_n module. In the CBAM module, the important channel for extracting features is selected from the feature map through the channel attention module, and then the spatial attention module is used to enhance the spatial position information of different features after passing through the important channel; in this embodiment, the channel attention module is to compress the input feature map in the spatial dimension through the average function (average pooling) and the maximum function (max pooling), and a total of two one-dimensional vectors can be obtained after two pooling functions. The average pooling function has feedback for each pixel on the input feature map, while the max pooling function has gradient feedback only for the place with the largest response in the feature map during the gradient back propagation calculation. In fact, it is to perform network connection of MLP (fully connected neural network) after compressing the spatial dimension, and finally generate a vector with weight value, so as to determine the weight value of each channel.
[0063] In one embodiment, spatial attention uses average pooling and max pooling to compress the input feature map, and performs average and maximum operations on the input features in the channel dimension, and finally obtains two two-dimensional feature maps, which are spliced together in the channel dimension to obtain a feature map with 2 channels, and then a hidden layer containing a single convolution kernel is used to perform a convolution operation on it, to ensure that the final feature is consistent with the input feature in the spatial dimension. Figure 1 To.
[0064] S4.1.3 In the SPPF module, the feature map after the CBAMC3_n module is pooled twice or more, and then the feature map before and after pooling is merged and output to the neck network after merging.
[0065] S4.2 fuses the output feature map of the top layer of the backbone network with the output feature map of the second layer in the backbone network through the small target detection layer to output the feature map; step S4.2 includes S4.2.1-S4.2.2;
[0066] S4.2.1 Upsample the top layer of the backbone network through the small object detection layer to expand the size of the feature map;
[0067] S4.2.2 fuses the feature map obtained by upsampling the top layer with the feature map of the second layer in the backbone network, and outputs the fused feature map to the prediction category network and the localization bounding box network. Specifically, Figure 4 As shown, in this embodiment, the fusion method is to convolve (Conv) and sample (Upmaple) the second layer output feature map, and then array (Concat) it with CBAMC3_1 to obtain a feature map of size 160*160.
[0068] S4.3 outputs the type of screen printing defects through the prediction category network at the output end, and outputs the location of the screen printing defects through the positioning bounding box network. Specifically, the types of screen printing defects output by the category network include broken grid, thick line, node, leakage and virtual printing; the positioning bounding box network outputs the location of the screen printing defect, such as the specific location point of the screen printing.
[0069] S5 evaluates the model trained in step S4. In this embodiment, the detection performance of the model for defects is evaluated by a confusion matrix. The confusion matrix is shown in Table 1 below:
[0070] Table 1
[0071]
[0072] Among them, the predicted value of TP is high similarity, and the true value is also high similarity. The predicted value of TN is low similarity, and the true value is low similarity. The predicted value of FP is high similarity, and the true value is low similarity. The predicted value of FN is low similarity, and the true value is high similarity.
[0073] Set the accuracy P to
[0074] ;
[0075] The recall rate R is
[0076] ;
[0077] The harmonic mean F1 is
[0078] .
[0079] The value range of the harmonic mean F1 is between 0 and 1. The value of the harmonic mean F1 is used to evaluate the detection performance of the model. If the value of F1 is closer to 1, the detection performance of the model is better.
[0080] After evaluating the detection performance of the model, the data of the model is compared and analyzed. In the model of this embodiment, the screen printing defects of the battery cell image include broken grid, thick line, node, leakage and virtual printing.
[0081] In this embodiment, the influence of different models on the detection performance of the battery cell is analyzed by ablation experiments. In the ablation experiments, the original YOLOv5 network model, the YOLOv5 network model containing the CBAMC3_n module, the YOLOv5 network model containing the small target detection layer (STD), and the PCDD-YOLOv5 network model are respectively set. The PCDD-YOLOv5 network model contains both the CBAMC3_n module and the small target detection layer (STD). The comparison data of the four models are shown in Table 2 below.
[0082] Table 2
[0083]
[0084] Through data analysis, it is found that compared with the original YOLOv5 network model, the improved PCDD-YOLOv5 network model has improved precision P and recall R by 1.75% and 6.87% respectively, and the harmonic mean F1 is improved by 3.05%. The PCDD-YOLOv5 network model improves the detection accuracy and precision, so that it can accurately and quickly identify the type and location of screen printing defects, while avoiding missed detection and false detection.
[0085] Finally, S1 to S4 are repeated, the screen printing defect image of the solar cell to be detected is input into the model for detection, and the type and location of the screen printing defect are output.
[0086] The working principle of the present invention is as follows: by using data enhancement to generate new screen printing defect images to expand the number of data sets, more data samples are obtained, and then the screen printing defects are marked, and the training set, test set and verification set are divided according to a preset ratio, and then the training set is input to the input end of the PCDD-YOLOv5 network, and the CBAMC3_n module is formed by the C3 module and the CBAM module in the backbone network to realize more efficient feature extraction and fusion of the feature map, so that the model can dynamically adjust the importance of different features, more efficiently and accurately capture the key features in the feature map, improve the accuracy of target detection, and add a small target detection layer in the neck network, and fuse the feature map obtained by upsampling the top layer with the feature map of the second layer in the backbone network, and output them to the prediction category network and the positioning bounding box network after fusion, and finally output the type of screen printing defects at the output end through the prediction category network, and output the position of the screen printing defects through the positioning bounding box network, with high detection accuracy and high detection efficiency.
Claims
1. A cell screen printing defect detection method based on improved YOLOv5 is implemented by an improved YOLOv5 network model, wherein the improved YOLOv5 network model is a PCDD-YOLOv5 network model; a C3 module in the backbone network of the PCDD-YOLOv5 network model is merged and a CBAM module is added to form a CBAMC3 module, wherein the CBAM module includes a spatial attention module and a channel attention module, and a small target detection layer is added to the top layer of the neck network; the characteristics are as follows: The following steps are also included: S1 collects images of screen printing defects on photovoltaic solar cells through a camera and then builds a data set; S2 uses data enhancement to expand the number of cell screen printing defect images in the data set, preprocesses the expanded data set, and then annotates it, and divides it into training set, test set, and validation set according to a preset ratio; S3 builds the PCDD-YOLOv5 network model; S4 inputs the training set in step S2 into the improved PCDD-YOLOv5 network model, and then outputs the type of screen printing defects of the battery cell after detection by the model; S4.1 After the training set in step S2 is input to the C3 module of the backbone network, the input image features are first convolved through the channel attention module and then convolved through the spatial attention module to obtain the output feature map of the output backbone network; S4.2 fuses the output feature map of the top layer of the backbone network with the output feature map of the second layer in the backbone network through the small target detection layer to output the feature map; S4.3 detects the output feature map and outputs the type of screen printing defects of the battery cell; S5 evaluates the model trained in step S4, repeats S1 to S4, determines that the screen printing defect image of the battery cell is input into the model, inputs the screen printing defect image of the battery cell to be detected into the model for detection, and outputs the type of screen printing defect.
2. According to claim 1, a method for detecting screen printing defects of a cell based on improved YOLOv5 is characterized in that: In the step S2, data enhancement is performed by using a Mosaic function.
3. According to claim 2, a method for detecting screen printing defects of a cell based on improved YOLOv5 is characterized in that: The preprocessing of step S2 includes: correction and normalization processing.
4. According to claim 3, a method for detecting screen printing defects of a cell based on improved YOLOv5 is characterized in that: In step S2, LabelImg labeling software is used to label each type of screen printing defects, and the training set, test set and validation set are divided according to a ratio of 8.5:1:
1.
5. The method for detecting screen printing defects of a cell based on improved YOLOv5 according to claim 1, characterized in that: The PCDD-YOLOv5 network model in step S3 includes an input end, a backbone network, a neck network and an output end, and the input end is respectively output through the backbone network and the neck network and then through the output end; The backbone network includes Conv module, C3 module, CBAM module and SPPF module; The Conv module includes convolutional layers, batch normalization layers, and SiLu activation functions; The C3 module includes a first path and a second path, the first path is composed of a Conv module and more than two BottleNeck modules, and the second path is composed of a Conv module; The SPPF module includes the Conv module and the Maxpool module; The CBAM module includes a channel attention module and a spatial attention module; In the backbone network, two or more C3 modules are merged and connected with the CBAM module to form a CBAMC3_n module; The neck network includes a small object detection layer.
6. The method for detecting screen printing defects of a cell based on improved YOLOv5 according to claim 1, characterized in that: The S4.1 also includes: adaptively calculating the Anchor value of the training set through a clustering algorithm at the input end to ensure that the Anchor value adapts to the distribution characteristics of the data set, the size of the battery cell image at the input end is 640×640, the batchsize is set to 8, and the epoch is set to 300; extracting the features of the screen printing defect image through the backbone network.
7. The method for detecting screen printing defects of a cell based on improved YOLOv5 according to claim 6, characterized in that: The step S4.1 also includes S4.1.1 to S4.1.3, S4.1.1 In the Conv module, the features of the image are extracted from the training set at the input end through the convolution layer to form a feature map, the model training is accelerated through the batch normalization layer, and the complex nonlinear features in the feature map are extracted through the SiLu activation function; S4.1.2 In the C3 module, the image features of the first path and the second path are merged, and then the CBAM module is embedded after two or more C3 modules to form a CBAMC3_n module. In the CBAM module, the important channels for extracting features are selected from the feature map through the channel attention module, and then the spatial position information of different features after passing through the important channels is enhanced through the spatial attention module; S4.1.3 In the SPPF module, the feature map after the CBAMC3_n module is pooled twice or more, and then the feature maps before and after pooling are merged and output to the neck network after merging.
8. The method for detecting screen printing defects of a cell based on improved YOLOv5 according to claim 1, characterized in that: The step S4.2 further includes: S4.2.1 Upsample the top layer of the backbone network through the small object detection layer to expand the size of the feature map; S4.2.2 fuses the feature map obtained by upsampling the top layer with the feature map of the second layer in the backbone network, and outputs the fused feature map to the prediction category network and the positioning bounding box network.
Citation Information
Patent Citations
Solar cell silk-screen printing defect detection method and system
CN116758080A
Improved YOLOv5-based battery case end face defect real-time detection method
CN114972316A
Steel surface defect detection method based on YOLOv7-ECD
CN116468716A