Lithium battery surface defect intelligent detection method based on deep learning
By generating methods such as adversarial network preprocessing, unsupervised cluster annotation and self-supervised pretraining, the YOLOv8 model is improved, and the data dependence and adaptability problems in lithium battery surface defect detection are solved, achieving high-precision and high-efficiency detection effects.
Patent Information
- Application Number
- CN202510593829.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-05-09
AI Technical Summary
In the detection of surface defects of lithium batteries, existing deep learning detection methods have problems such as strong dependence on large-scale high-quality labeled data, insufficient sensitivity to small target defects, and poor adaptability to complex shapes and extreme aspect ratio defects, resulting in poor detection results.
Using the methods of image preprocessing, unsupervised cluster-assisted annotation, Perlin noise enhancement processing and self-supervised pre-training based on generative adversarial networks, an improved YOLOv8 model is built and combined with cross-stage local feature fusion module, dynamic sampling layer and efficient multi-scale attention module to improve detection performance.
It realizes high accuracy and efficiency of surface defect detection of lithium batteries, reduces manual labeling workload, enhances data set diversity, improves the training effect of the model with few samples, and improves the adaptability and generalization ability to complex defects.
Smart Images

Figure CN120495764A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing technology, and specifically relates to a lithium battery surface defect detection method based on deep learning. Background Art
[0002] As the cornerstone of many strategic emerging industries, lithium batteries are an important pillar for promoting clean energy transformation, intelligent manufacturing and the development of emerging transportation systems.
[0003] Currently, the production and processing of lithium batteries is largely automated. However, during the assembly line process, factors such as machine damage and component collisions can cause surface scratches, breakage, dents, and even more serious defects such as aluminum and liquid leakage. These defects not only affect the appearance of lithium batteries but can also damage their internal structure, leading to performance degradation and even safety hazards such as explosions. Existing deep learning-based defect detection methods have many limitations, including a strong reliance on large-scale, high-quality annotated data, insufficient sensitivity to small defects, and poor adaptability to complex shapes and defects with extreme aspect ratios.
[0004] The development of the YOLO series in the field of industrial defect detection is of great significance for improving detection performance and adapting to diverse industrial scenarios. However, when applied to the field of lithium battery surface defect detection, the YOLO series model has limited capabilities, especially when the defect size is small and the contrast with the background is low, which can easily lead to missed detections and false detections. Secondly, the model is insufficient in feature extraction, making it difficult to accurately capture the key information of complex defects. In addition, the YOLO series model performs poorly when processing lithium battery surface images with low contrast and high background noise.
[0005] Therefore, how to efficiently and accurately detect surface defects of lithium batteries has become a difficult problem that needs to be solved urgently in the lithium battery industry. Summary of the Invention
[0006] In response to the above-mentioned deficiencies in the prior art, the deep learning-based intelligent detection method for lithium battery surface defects provided by the present invention solves the problems of strong dependence on large and high-quality labeled data, insufficient sensitivity to small target defects, and poor adaptability to complex shapes and extreme aspect ratio defects when using existing deep learning detection methods for lithium battery defect detection, which in turn affects the detection effect of lithium battery surface defects.
[0007] In order to achieve the above-mentioned purpose of the invention, the technical solution adopted by the present invention is: a method for intelligent detection of lithium battery surface defects based on deep learning, comprising the following steps:
[0008] S1. Perform unsupervised clustering-assisted defect annotation on the collected lithium battery surface images, and perform defect enhancement processing to construct a lithium battery surface image dataset;
[0009] S2. Use unlabeled defect images from related fields to perform self-supervised pre-training on the YOLOv8 model, and retain the pre-trained weights of the YOLOv8 model backbone network;
[0010] S3. Build an improved YOLOv8 model and migrate the pre-trained weights of the backbone network to the improved YOLOv8 model;
[0011] S4. Use the lithium battery surface image dataset to train the improved YOLOv8 model to obtain a defect detection model;
[0012] S5. Input the surface image of the lithium battery to be inspected into the defect detection model to obtain the defect detection result.
[0013] Furthermore, the step S1 includes the following sub-steps:
[0014] S11. Denoising the collected lithium battery surface image based on a generative adversarial network to obtain a denoised lithium battery surface image;
[0015] The generator of the generative adversarial network is a U-Net network, and the discriminator is a PatchGAN network;
[0016] S12, performing standardization, normalization, data enhancement, image cropping, and recalibration processing on the denoised lithium battery surface image in sequence to obtain a standard lithium battery surface image;
[0017] S13. Build an unsupervised clustering model to cluster the standard lithium battery surface images, and determine and annotate the labels of each cluster based on expert opinions;
[0018] S14, performing defect enhancement processing based on Perlin noise on the defect standard lithium battery surface image to expand the data volume of the defect standard lithium battery surface image;
[0019] S15. Composing a lithium battery surface image dataset with the defect standard lithium battery surface image after defect enhancement processing and the normal standard lithium battery surface image.
[0020] Furthermore, in step S13, the unsupervised clustering model includes a FACE autoencoder and a hierarchical clustering module;
[0021] The process of clustering the input standard lithium battery surface image by the unsupervised clustering model is as follows:
[0022] S13-1. Extract features from the standard lithium battery surface image using the FACE autoencoder to obtain a feature vector.
[0023] S13-2. In the hierarchical clustering module, the input feature vectors are clustered layer by layer. In the clustering process, mutual information constraints are introduced to determine the mutual information between the feature vectors and the cluster categories. The parameters of the FACE autoencoder and the hierarchical clustering module are reversely updated by maximizing the mutual information.
[0024] S13-3. Repeat steps S13-1 to S13-2 until the unsupervised clustering model converges, and output the clustering results through the hierarchical clustering module.
[0025] Furthermore, in step S13-2, the clustering target of layer-by-layer clustering is:
[0026]
[0027] The clustering optimization goal of each layer is:
[0028]
[0029] Where, represents the total loss of layer-by-layer clustering, represents the clustering loss during the l-th layer clustering, KL(·) represents the divergence function used to measure the difference between the clustering results of the current layer and the previous layer, R (l) and S (l) Represent the clustering results of the current layer and the previous layer respectively, θ * Represents the model parameters that minimize the KL divergence, μ * represents the set of cluster centers that minimizes the KL divergence, r ij Indicates the membership of feature vector i to cluster j, S ij represents the distribution strength of the i-th eigenvector in the cluster, n j represents the total number of samples in cluster j;
[0030] The mutual information constraint is expressed as:
[0031]
[0032] Where I(Z;Y) represents the mutual information between the feature vector Z and the cluster category Y, q(y|z) represents the probability distribution of cluster category assignment, and H(Y) represents the entropy of the cluster category. It represents the expectation of the joint distribution p(z,y) of the feature vector Z and the cluster category Y.
[0033] Furthermore, the step S14 includes the following sub-steps:
[0034] S14-1. Extract high-dimensional feature information from defective standard lithium battery surface images and increase image resolution by upsampling.
[0035] S14-2. Based on the defective standard lithium battery surface image, Perlin noise is introduced to generate a synthetic abnormal image;
[0036] S14-3, comparing the generated abnormal image with a high-resolution defective standard lithium battery surface image in a feature space, and generating an adapted feature map by adjusting the feature mapping;
[0037] S14-4. Based on the adapted feature map, adding disturbance to the synthetic abnormal image to obtain a disturbed abnormal image;
[0038] S14-5, merging the disturbed abnormal image and the adapted feature map, and performing defect segmentation and classification through the segmentation head and the classification head;
[0039] The segmentation head is used to detect the defect locations in the input image and generate a defect segmentation map; the classification head is used to classify the defect segmentation map and determine its defect type;
[0040] S14-6. Based on the defect segmentation map for determining the defect type, the data volume of the defect standard lithium battery surface image is expanded.
[0041] Furthermore, step S2 includes the following sub-steps:
[0042] S21. Collect unlabeled defect images in related fields and perform data enhancement processing on them to obtain enhanced images;
[0043] S22. Replace the encoder in the SimCLR framework with the backbone network of the YOLOv8 model to form a self-supervised training model, and use the enhanced images to pre-train the self-supervised training model;
[0044] During the pre-training process, the backbone network is used to extract features from the enhanced image, and the extracted features are mapped to a low-dimensional representation space through the projection head to obtain the corresponding feature representation;
[0045] S23. Repeat the pre-training process until the self-supervised training model converges, retaining the pre-trained weights of the YOLOv8 model backbone network;
[0046] The loss function for training the self-supervised training model is expressed as:
[0047]
[0048] Where, represents the contrast loss, z i and z j Represents the representation vectors obtained after two different enhanced views of the same image are extracted and projected, z kRepresents the representation vectors of different images after feature extraction and projection, τ is used to control the distinction between positive and negative samples in contrastive learning, k is an index variable used to traverse all sample pairs, and N is the number of samples in each batch.
[0049] Furthermore, in step S3, the improved YOLOv8 model includes a Backbone network, a Neck network, and a Head network;
[0050] The Backbone network includes a first convolutional layer, a first batch normalization layer, a first activation function, a first cross-stage local feature fusion module, a second convolutional layer, a second batch normalization layer, a second activation function, a second cross-stage local feature fusion module, a third convolutional layer, a third batch normalization layer, a third activation function, a third cross-stage local feature fusion module, a fourth convolutional layer, a fourth batch normalization layer, a fourth activation function, a fourth cross-stage local feature fusion module and a fast spatial pyramid pooling layer connected in sequence;
[0051] The Neck network includes a feature fusion module of a fourth custom sampling rate, a second dynamic sampling layer, a third connection layer, a feature fusion module of a third custom sampling rate, a second dynamic sampling layer, a second connection layer, a feature fusion module of a second custom sampling rate, a first dynamic sampling layer, a first connection layer, a feature fusion module of a first custom sampling rate, a first efficient multi-scale attention module, a fifth convolutional layer, a fifth batch normalization layer, a fifth activation function, a fourth connection layer, a feature fusion module of a fifth custom sampling rate, a second efficient multi-scale attention module, a sixth convolutional layer, a sixth batch normalization layer, a sixth activation function, a fifth connection layer, a feature fusion module of a sixth custom sampling rate, and a third efficient multi-scale attention module, which are connected in sequence;
[0052] The input end of the first connection layer is further connected to the first activation function, the input end of the second connection layer is further connected to the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is further connected to the output end of the third cross-stage local feature fusion module, and the input end of the feature fusion module with the fourth custom sampling rate is further connected to the output end of the fast spatial pyramid pooling layer;
[0053] The Head network includes a first detection head, a second detection head and a third detection head; the input end of the first detection head is connected to the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected to the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected to the output end of the third efficient multi-scale attention module.
[0054] Furthermore, the processing process of the first to fourth cross-stage local feature fusion modules on the input feature map is as follows:
[0055] S41, grouping the input feature map along the x-axis pooling branch, the y-axis pooling branch, and the convolution branch;
[0056] S42, performing bidirectional feature fusion on feature maps from different sources, and introducing a learning weight coefficient in the fusion process to adaptively weight features from different sources to obtain fused features;
[0057] S43, after the fusion features are connected to the convolution layer, they are processed by the sigmoid activation function and the weights are redistributed to obtain the multi-scale feature representation;
[0058] Among them, the formula for adaptive weighting is:
[0059] P out =∑(w i ·p i ) / (ε+∑w i )
[0060] Where, P out Represents the adaptively weighted feature map, p i Represents feature maps from different sources, w i Indicates p i The corresponding weight coefficient, ε, represents a small constant for stable calculation.
[0061] Furthermore, the upsampling process of the input feature map by the first to second dynamic upsampling layers is expressed as:
[0062] X up =Dysample(X low ,θ(X low ))+β·EdgeEnhance(X low )
[0063] Where, X up Represents the upsampled feature map, X low represents the low-resolution feature map, i.e., the input feature map, Dysample(·) represents the parameterized dynamic upsampling operation, EdgeEnhance(·) represents the edge enhancement function, θ(·) represents the upsampling parameter adaptively generated according to the low-resolution feature map, and β represents the balance coefficient.
[0064] Furthermore, the process of performing spatial-channel dual attention enhancement on the input feature map by the first to third efficient multi-scale attention modules is expressed as:
[0065] EMA(X)=σ(Conv 1×1 (Concat(Pool x (x),Pool y(x),DSConv(x)))e X+γ·GlobalContext(X)
[0066] Where EMA(X) represents the attention score, σ(·) represents the Sigmoid activation function, and Conv 1×1 (·) represents convolution, Concat(·) represents concatenation, Pool x (x) represents pooling along the x-axis, Pool y (x) represents pooling along the y-axis, DSConv(x) represents depthwise separable convolution, GlobalContext(·) represents capturing global context information, X represents the input feature map, γ represents the loss coefficient, and e represents matrix multiplication.
[0067] The method of the present invention achieves the combination of high precision and high efficiency in detecting surface defects of lithium batteries, which is specifically reflected in:
[0068] (1) The present invention performs preprocessing such as denoising based on a generative adversarial network on the collected lithium battery surface images, ensuring the consistency of the quality of the lithium battery surface images and providing a high-quality data foundation for subsequent training based on the improved YOLOv8 model. These processes not only improve the quality of the data, but also lay a solid foundation for the accuracy and generalization ability of the subsequent model.
[0069] (2) The present invention greatly reduces the workload of manual labeling and ensures the uniqueness of the labels through unsupervised clustering-assisted labeling based on the FACE autoencoder and hierarchical clustering module, combined with the method of expert confirmation of defect labels, and quickly obtains a large amount of high-quality label data for subsequent training and use of the YOLOv8 model.
[0070] (3) Based on the defective lithium battery surface images obtained by unsupervised clustering-assisted annotation, the present invention synthesizes representative defect samples through a defect enhancement synthesis process based on Perlin noise to fill the scarce sample categories, thereby enhancing the diversity of the defective lithium battery surface image dataset and improving the training effect of the model in the case of few samples.
[0071] (4) This invention collects unlabeled defect images from other related fields to perform self-supervised pre-training of the YOLOv8 model, providing high-quality data suitable for self-supervised learning for lithium battery surface defect detection tasks. The data not only covers five typical lithium battery surface defects, such as cracks, pits, wrinkles, plaques, and dirt, but also incorporates surface defect samples of various industrial materials such as metal, wood, silk, and rails. This combination of diverse data not only ensures the characteristics of lithium battery surface defects, but also improves the adaptability and generalization ability of the self-supervised learning model in other industrial defect detection scenarios.
[0072] (5) The present invention provides an improved YOLOv8 model with high detection performance. By designing a cross-stage local feature fusion module, a dynamic sampling layer and an efficient multi-scale attention module, the accuracy and real-time performance of lithium battery surface defect detection are improved. Among them, the cross-stage local feature fusion module optimizes the representation capability of multi-scale features, the Dysample dynamic upsampling mechanism of the dynamic sampling layer enhances the perception of defect boundaries, and the EMA hybrid attention mechanism of the efficient multi-scale attention module improves the model's ability to pay attention to defect areas. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 Flowchart of the deep learning-based intelligent detection method for lithium battery surface defects provided by the present invention.
[0074] Figure 2 This is a schematic diagram of the improved YOLOv8 model structure provided by the present invention.
[0075] Figure 3 This is a flowchart of the processing of input feature maps by the first to fourth cross-stage local feature fusion modules provided by the present invention. DETAILED DESCRIPTION
[0076] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.
[0077] The embodiment of the present invention provides a method for intelligent detection of lithium battery surface defects based on deep learning, such as Figure 1 As shown, the following steps are included:
[0078] S1. Perform unsupervised clustering-assisted defect annotation on the collected lithium battery surface images, and perform defect enhancement processing to construct a lithium battery surface image dataset;
[0079] S2. Use unlabeled defect images from related fields to perform self-supervised pre-training on the YOLOv8 model, and retain the pre-trained weights of the YOLOv8 model backbone network;
[0080] S3. Build an improved YOLOv8 model and migrate the pre-trained weights of the backbone network to the improved YOLOv8 model;
[0081] S4. Use the lithium battery surface image dataset to train the improved YOLOv8 model to obtain a defect detection model;
[0082] S5. Input the surface image of the lithium battery to be inspected into the defect detection model to obtain the defect detection result.
[0083] Step S1 of the embodiment of the present invention includes the following sub-steps:
[0084] S11. Denoising the collected lithium battery surface image based on a generative adversarial network to obtain a denoised lithium battery surface image;
[0085] Among them, the generator of the generative adversarial network is the U-Net network, and the discriminator is the PatchGAN network;
[0086] S12, performing standardization, normalization, data enhancement, image cropping, and recalibration processing on the denoised lithium battery surface image in sequence to obtain a standard lithium battery surface image;
[0087] S13. Build an unsupervised clustering model to cluster the standard lithium battery surface images, and determine and annotate the labels of each cluster based on expert opinions;
[0088] S14, performing defect enhancement processing based on Perlin noise on the defect standard lithium battery surface image to expand the data volume of the defect standard lithium battery surface image;
[0089] S15. Composing a lithium battery surface image dataset with the defect standard lithium battery surface image after defect enhancement processing and the normal standard lithium battery surface image.
[0090] In step S11 of this embodiment, to ensure the clarity and accuracy of lithium battery surface images, a high-precision CMOS sensor and a professional industrial camera, combined with a precise optical system, were used to capture lithium battery surface images on a lithium battery production line. The image resolution was 3000 x 3000 pixels, meeting the specifications of the YOLOv8 model and providing high-quality image data for subsequent deep learning model training. The lithium battery surface images captured in this embodiment cover typical lithium battery surface defect types, including pits, edge wrinkles, damage, bumps, indentations, dirt, and wrinkles.
[0091] In step S11 of this embodiment, in order to remove the noise in the surface image of the lithium battery, especially the factors that may affect the image intelligence such as light spots and blur that may appear during the shooting process; in this embodiment, a denoising method based on a generative adversarial network (GAN) is adopted. The denoised image is generated by training a generator in the generative adversarial network (GAN), and the similarity between the generated image and the real clean image is judged by the discriminator, thereby optimizing the output of the generator to achieve the effect of removing noise.
[0092] Specifically, in this embodiment, the generator in the generative adversarial network is a U-Net network structure, and the discriminator is a PatchGAN network structure. The U-Net network structure uses an encoder and a decoder. The encoder extracts image features, and the decoder reconstructs the image. A skip connection is added between the encoder and decoder to preserve image details. The PatchGAN structure outputs the discrimination result for each patch in the image.
[0093] In the above-mentioned adversarial generative network, for the generator, its training loss function is:
[0094] L gen =L adv +λL L1
[0095] Where, L adv Denotes the adversarial loss, L L1 represents the L1 loss to ensure that the image generated by the generator is as close as possible to the real clean image at the pixel level, and λ represents the weight coefficient used to balance the adversarial loss and L1 loss.
[0096] For the discriminator, its training loss function is:
[0097] L disc =L real +L fake
[0098] Where, L real Represents the real image loss to encourage the discriminator to correctly identify the real clean image, L fake Represents the generated image loss to encourage the discriminator to correctly identify the images generated by the generator.
[0099] In step S12 of this embodiment, all denoised images are standardized, and the pixel value range is adjusted to between 0 and 1. In order to improve the generalization ability of the model and reduce overfitting, data enhancement processing is performed on the image, specifically including random rotation (randomly rotating the image by a certain angle to enhance the model's ability to recognize defects in different directions), random flipping (including horizontal flipping and vertical flipping), random scaling (zooming in and out of the image), and random cropping (cropping out some areas from the image to simulate defect images under different shooting angles). Furthermore, for original images of different sizes, this embodiment crops and recalibrates them to ensure that the size of all images input into the model is a uniform 640×640 pixels. This process avoids image deformation by maintaining the aspect ratio of the image, thereby retaining the true form of the defect to the greatest extent.
[0100] The above processing steps ensure the consistency of the quality of lithium battery surface images and provide a high-quality data foundation for subsequent YOLOv8 model training. These processes not only improve the quality of the data, but also lay a solid foundation for the accuracy and generalization ability of the subsequent model.
[0101] In step S13 of this embodiment, the unsupervised clustering model includes a FACE autoencoder and a hierarchical clustering module. This invention proposes an innovative unsupervised clustering-assisted annotation method that combines the FACE autoencoder and the hierarchical clustering Soft K-Means algorithm. This method overcomes the bottleneck of traditional manual annotation and effectively improves annotation efficiency through automation.
[0102] In this embodiment, the process of clustering the input standard lithium battery surface image by the unsupervised clustering model is as follows:
[0103] S13-1. Extract features from the standard lithium battery surface image using the FACE autoencoder to obtain a feature vector.
[0104] S13-2. In the hierarchical clustering module, the input feature vectors are clustered layer by layer. In the clustering process, mutual information constraints are introduced to determine the mutual information between the feature vectors and the cluster categories. The parameters of the FACE autoencoder and the hierarchical clustering module are reversely updated by maximizing the mutual information.
[0105] S13-3. Repeat steps S13-1 to S13-2 until the unsupervised clustering model converges, and output the clustering results through the hierarchical clustering module.
[0106] In step S13-1 of this embodiment, the processed standard lithium battery surface image is processed by the FACE autoencoder. The FACE autoencoder is an unsupervised deep learning model. Its core task is to compress the image data into a low-dimensional feature vector through the encoder and reconstruct the image through the decoder. The goal of this step is to extract the high-dimensional features of the image so that the subsequent clustering module can use these features for classification.
[0107] In step S13-2 of this embodiment, the feature vector extracted by the FACE autoencoder is passed to the hierarchical clustering module. In this module, the image features are refined and assigned to different cluster categories. The hierarchical clustering algorithm avoids the boundary fuzziness problem of hard clustering by calculating the probability value of each sample belonging to a certain cluster.
[0108] When performing layer-by-layer clustering, the clustering goal of layer-by-layer clustering is:
[0109]
[0110] The clustering optimization goal of each layer is:
[0111]
[0112] Where, represents the total loss of layer-by-layer clustering, represents the clustering loss during the l-th layer clustering, KL(·) represents the divergence function used to measure the difference between the clustering results of the current layer and the previous layer, R (l) and S (l) Represent the clustering results of the current layer and the previous layer respectively, θ * Represents the model parameters that minimize the KL divergence, μ * represents the set of cluster centers that minimizes the KL divergence, r ij Indicates the membership of feature vector i to cluster j, S ij represents the distribution strength of the i-th eigenvector in the cluster, n j represents the total number of samples in cluster j.
[0113] In the clustering process, in order to further enhance the discriminability of clustering, mutual information constraints are introduced in this embodiment. Mutual information is used to measure the correlation between feature vectors and cluster categories. By maximizing mutual information, the classification ability of the clustering model can be enhanced, so that samples of the same category are clustered together, while samples of different categories are effectively distinguished.
[0114] Among them, the mutual information constraint is expressed as:
[0115]
[0116] Where I(Z;Y) represents the mutual information between the feature vector Z and the cluster category Y, q(y|z) represents the probability distribution of cluster category assignment, and H(Y) represents the entropy of the cluster category. It represents the expectation of the joint distribution p(z,y) of the feature vector Z and the cluster category Y.
[0117] After the above-mentioned hierarchical clustering and mutual information optimization, the clustering results are output. Since the clustering results of each layer are based on the output of the previous layer, the clustering process is gradually refined, ensuring that the final clustering results are more accurate.
[0118] After generating preliminary clustering results based on the unsupervised clustering model, experts only need to confirm a small number of representative images. Once confirmed, the labels for the entire cluster are determined, and annotation is then performed based on this. This significantly reduces the workload of manual annotation and ensures consistency and accuracy. This method allows us to quickly obtain a large amount of high-quality labeled data for subsequent training of improved YOLOv8 models.
[0119] In this example, in the lithium battery surface defect detection task, although most defect images were successfully labeled and provided effective training data after unsupervised clustering-assisted labeling, insufficient sample data for certain defect categories was sometimes encountered. This was particularly true for rare defects such as bumps and edge wrinkles, which occur less frequently in actual production, resulting in a scarcity of labeled data.
[0120] To solve this problem, this implementation proposes a defect enhancement process based on Perlin, which aims to fill these scarce sample categories by synthesizing representative defect samples, enhance the diversity of the training data set, and thus improve the training effect of the model in the case of few samples; this embodiment uses Perlin noise, a natural texture generation technology, to effectively solve the problem of insufficient samples in defect detection tasks.
[0121] Step S14 of this embodiment includes the following sub-steps:
[0122] S14-1. Extract high-dimensional feature information from defective standard lithium battery surface images and increase image resolution by upsampling.
[0123] Among them, the real defect images in the standard lithium battery surface image data, especially those rare defect categories that are insufficient in the annotated data, are used as the basic samples of the synthesis process to provide a reference for the subsequent generation of high-quality synthetic samples;
[0124] Specifically, high-dimensional feature information is extracted, such as the texture and shape of the defect; the upsampling process increases the resolution of the image to ensure that the generated synthetic sample has sufficient details and can maintain visual consistency with the original image;
[0125] S14-2. Based on the defective standard lithium battery surface image, Perlin noise is introduced to generate a synthetic abnormal image;
[0126] Specifically, Perlin noise is an algorithm for generating natural textures that can provide smooth and continuous random noise. This noise can simulate the natural features that may appear in the surface defect image of lithium batteries. The representation of the synthetic abnormal image is:
[0127]
[0128] Where M represents the surface image of a defective standard lithium battery, Mg represents Gaussian noise, ε represents perturbation noise, η represents the intensity adjustment coefficient, and Perlin(M) represents the result of applying Perlin noise to the surface image of a defective standard lithium battery. Represents the image mixing operation; in this way, the system can generate new defect samples with diversity while maintaining the characteristics of the original defects;
[0129] S14-3, comparing the generated abnormal image with a high-resolution defective standard lithium battery surface image in a feature space, and generating an adapted feature map by adjusting the feature mapping;
[0130] Specifically, the purpose of feature adaptation in this step is to ensure that the generated synthetic image not only maintains its structural characteristics but also aligns with the characteristics of real lithium battery surface defect samples in the training dataset. In this process, the synthetic feature map is compared with the original image, and the feature map is adjusted to make the synthetic image more similar to the representation of real defects, thereby improving the quality and effectiveness of the synthetic sample.
[0131] S14-4. Based on the adapted feature map, adding disturbance to the synthetic abnormal image to obtain a disturbed abnormal image;
[0132] Specifically, based on the adapted feature map, perturbations are added to the synthetic anomaly images to enhance their robustness in various environments and simulate images of lithium battery surface defects that may appear under different interference conditions. This step further improves the quality and practicality of the synthetic samples, making them more suitable for defect detection in actual production environments.
[0133] S14-5, merging the disturbed abnormal image and the adapted feature map, and performing defect segmentation and classification through the segmentation head and the classification head;
[0134] The segmentation head is used to detect the defect locations in the input image and generate a defect segmentation map; the classification head is used to classify the defect segmentation map and determine its defect type;
[0135] S14-6. Based on the defect segmentation map for determining the defect type, the data volume of the defect standard lithium battery surface image is expanded.
[0136] In an embodiment of the present invention, in the task of lithium battery surface defect detection, the performance of the deep learning model depends largely on the quality and quantity of training data; however, in actual industrial applications, obtaining a large number of defect images with precise annotations is often costly and time-consuming; to solve this problem, the present invention proposes a self-supervised training process, which uses an unlabeled defect image dataset related to the lithium battery field (such as FineDefect) for self-supervised training, significantly improving the model's initial characterization capability of complex defect features.
[0137] Based on this, step S2 of the embodiment of the present invention includes the following sub-steps:
[0138] S21. Collect unlabeled defect images in related fields and perform data enhancement processing on them to obtain enhanced images;
[0139] Specifically, the pre-training process first collects unlabeled images from the FineDefect dataset. These images do not require manual annotation and can be directly used in the self-supervised learning process, greatly reducing the data preparation cost.
[0140] Furthermore, the unlabeled images are enhanced by random rotation (randomly rotating the image by a certain angle to enhance the model's ability to identify defects in different directions), random flipping (including horizontal and vertical flipping), random scaling (zooming in and out of the image), and random cropping (cropping out parts of the image to simulate defect images under different shooting angles).
[0141] S22. Replace the encoder in the SimCLR framework with the backbone network of the YOLOv8 model to form a self-supervised training model, and use the enhanced images to pre-train the self-supervised training model;
[0142] During the pre-training process, the backbone network is used to extract features from the enhanced image, and the extracted features are mapped to a low-dimensional representation space through the projection head to obtain the corresponding feature representation;
[0143] Specifically, the features extracted by the encoder are mapped to a low-dimensional representation space through the projection head network to obtain the final feature representation. The projection head is composed of a multi-layer perceptron (MLP), specifically a linear layer followed by a ReLU activation function, followed by another linear layer. This design enables the backbone network to learn more general feature representations, while the projection head can convert these features into a representation suitable for contrastive learning.
[0144] S23. Repeat the pre-training process until the self-supervised training model converges, retaining the pre-trained weights of the YOLOv8 model backbone network.
[0145] In this embodiment, the self-supervised pre-training model adopts an improved contrast loss function, which is expressed as:
[0146]
[0147] Where, represents the contrast loss, z i and z j Represents the representation vectors obtained after two different enhanced views of the same image are extracted and projected, z k Represents the representation vectors of different images after feature extraction and projection, τ is used to control the distinction between positive and negative samples in contrastive learning, k is an index variable used to traverse all sample pairs, and N is the number of samples in each batch.
[0148] In this embodiment, by minimizing the above-mentioned contrast loss, the model learns to bring different perspectives of the same image closer together while pushing the representations of different images further apart, thereby learning discriminative feature representations. Compared with the traditional SimCLR framework, this embodiment uses the sin function to calculate the similarity between vectors instead of cosine similarity. This improvement enables the model to better capture subtle differences in defect features.
[0149] In this embodiment, based on the SimCLR framework, the present invention makes a breakthrough improvement to traditional self-supervised learning by replacing the encoder in the SimCLR framework with an independently designed YOLOv8 backbone network; and using a large number of unlabeled defect images in FineDefect for pre-training, significantly improving the model's initial representation capability of complex defect features.
[0150] In an embodiment of the present invention, in the task of lithium battery surface defect detection, the detection performance of the model directly affects the accuracy of defect recognition. In order to further improve the detection effect, especially the ability to identify tiny defects on the surface of lithium batteries, the present invention proposes a Super-Detect improvement framework based on the YOLOv8 model, which achieves the unity of high precision and high efficiency.
[0151] In step S3 of the embodiment of the present invention, as Figure 2 As shown in the figure, the improved YOLOv8 model mainly contains three key innovative structures, including a cross-stage local feature fusion module, a dynamic sampling layer, and an efficient multi-scale attention module. These improvements enable the model to achieve higher accuracy and efficiency in detecting subtle defects.
[0152] Specifically, in Figure 2 In
[15] , the improved YOLOv8 model includes Backbone network, Neck network and Head network;
[0153] The Backbone network includes a first convolutional layer, a first batch of normalization layers, a first activation function, a first cross-stage local feature fusion module, a second convolutional layer, a second batch of normalization layers, a second activation function, a second cross-stage local feature fusion module, a third convolutional layer, a third batch of normalization layers, a third activation function, a third cross-stage local feature fusion module, a fourth convolutional layer, a fourth batch of normalization layers, a fourth activation function, a fourth cross-stage local feature fusion module, and a fast spatial pyramid pooling layer, which are connected in sequence;
[0154] The Neck network includes a feature fusion module of a fourth custom sampling rate, a second dynamic sampling layer, a third connection layer, a feature fusion module of a third custom sampling rate, a second dynamic sampling layer, a second connection layer, a feature fusion module of a second custom sampling rate, a first dynamic sampling layer, a first connection layer, a feature fusion module of a first custom sampling rate, a first efficient multi-scale attention module, a fifth convolutional layer, a fifth batch normalization layer, a fifth activation function, a fourth connection layer, a feature fusion module of a fifth custom sampling rate, a second efficient multi-scale attention module, a sixth convolutional layer, a sixth batch normalization layer, a sixth activation function, a fifth connection layer, a feature fusion module of a sixth custom sampling rate, and a third efficient multi-scale attention module, which are connected in sequence;
[0155] The input end of the first connection layer is also connected to the first activation function, the input end of the second connection layer is also connected to the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is also connected to the output end of the third cross-stage local feature fusion module, and the input end of the fourth custom sampling rate feature fusion module is also connected to the output end of the fast spatial pyramid pooling layer;
[0156] The head network includes a first detection head, a second detection head and a third detection head; the input end of the first detection head is connected to the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected to the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected to the output end of the third efficient multi-scale attention module.
[0157] In this embodiment, the cross-stage local feature fusion module optimizes multi-scale feature fusion through a bidirectional feature full learning network, significantly enhancing the ability to detect tiny defects. Figure 3 As shown in Figure 2, the cross-stage local feature fusion module adopts a pyramid-like network structure. It fully utilizes feature information of different scales through multi-level feature extraction and fusion. Specifically, it processes the input feature map as follows:
[0158] S41, grouping the input feature map along the x-axis pooling branch, the y-axis pooling branch, and the convolution branch;
[0159] S42, performing bidirectional feature fusion on feature maps from different sources, and introducing a learning weight coefficient in the fusion process to adaptively weight features from different sources to obtain fused features;
[0160] S43, after the fusion features are connected to the convolution layer, they are processed by the sigmoid activation function and the weights are redistributed to obtain the multi-scale feature representation;
[0161] Among them, the formula for adaptive weighting is:
[0162] P out =∑(wi ·p i ) / (ε+∑w i )
[0163] Where, P out Represents the adaptively weighted feature map, p i Represents feature maps from different sources, w i Indicates p i The corresponding weight coefficient, ε, represents a small constant for stable calculation.
[0164] In this embodiment, unlike traditional one-way feature fusion, the cross-stage local feature fusion module realizes bidirectional feature flow from top to bottom and from bottom to top, so that the underlying detail features and the high-level semantic features can fully interact with each other.
[0165] In this embodiment, in order to better process feature information of different scales, especially to enhance the perception of defect boundaries, the present invention proposes a dynamic upsampling mechanism. Based on this, the upsampling process of the input feature map by the first to second dynamic upsampling layers is expressed as follows:
[0166] X up =Dysample(X low ,θ(X low ))+β·EdgeEnhance(X low )
[0167] Where, X up Represents the upsampled feature map, X low represents the low-resolution feature map, i.e., the input feature map, Dysample(·) represents the parameterized dynamic upsampling operation, EdgeEnhance(·) represents the edge enhancement function, θ(·) represents the upsampling parameter adaptively generated according to the low-resolution feature map, and β represents the balance coefficient.
[0168] In the dynamic upsampling mechanism proposed in this embodiment, the upsampling parameter θ(·) is dynamically generated based on the content of the input feature map, allowing the upsampling process to be adjusted according to the content characteristics of different regions. EdgeEnhance(·) is specifically used to enhance defect boundary features. Edge information is extracted through a multi-scale gradient operator, further highlighting the defect boundary features, which is crucial for accurately locating defect boundaries. During the dynamic upsampling process, the original feature information is retained through residual connections, avoiding the loss of important information during the upsampling process.
[0169] In this embodiment, to enhance the model’s ability to focus on defect areas, the present invention proposes an efficient multi-scale attention module, which includes the following key components:
[0170] Multi-dimensional pooling: through Poolx and Pool y Perform average pooling in the horizontal and vertical directions to capture feature distribution information in different directions;
[0171] Depthwise separable convolution: used to extract spatial features while reducing computational complexity;
[0172] Feature fusion and activation: Multiple pooling results and convolution features are connected through the Concat operation, and then the attention weight map is generated through 1×1 convolution and σ activation function;
[0173] Global Context Enhancement: GlobalContext improves the model's adaptability to complex backgrounds by capturing global context information. This module aggregates global information through a self-attention mechanism and fuses it with local features, enabling the model to better understand the relationship between defects and background.
[0174] Based on the above key components, the process of efficient multi-scale attention module to perform spatial-channel dual attention enhancement on the input feature map is expressed as:
[0175] EMA(X)=σ(Conv 1×1 (Concat(Pool x (x),Pool y (x),DSConv(x)))e X+γ·GlobalContext(X)
[0176] Where EMA(X) represents the attention score, σ(·) represents the Sigmoid activation function, and Conv 1×1 (·) represents convolution, Concat(·) represents concatenation, Pool x (x) represents pooling along the x-axis, Pool y (x) represents pooling along the y-axis, DSConv(x) represents depthwise separable convolution, GlobalContext(·) represents capturing global context information, X represents the input feature map, γ represents the loss coefficient, and e represents matrix multiplication.
[0177] In this embodiment, the improved YOLOv8 model achieves both high precision and high efficiency in detecting tiny defects on the surface of lithium batteries through the synergistic effect of various components. Specifically, the cross-stage local feature fusion module optimizes the representation of multi-scale features, the dynamic upsampling mechanism of the dynamic sampling layer (Dysample) enhances the perception of defect boundaries, and the EMA hybrid attention mechanism of the efficient multi-scale attention module improves the model's ability to focus on defect areas.
[0178] Specific embodiments are used in the present invention to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.
[0179] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and it should be understood that the scope of protection of the present invention is not limited to such specific descriptions and embodiments. Those skilled in the art can make various other specific variations and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and such variations and combinations are still within the scope of protection of the present invention.
Claims
1. A deep learning-based intelligent detection method for lithium battery surface defects, characterized in that: The following steps are involved: S1. Perform unsupervised clustering-assisted defect annotation on the collected lithium battery surface images, and perform defect enhancement processing to construct a lithium battery surface image dataset; S2. Use unlabeled defect images from related fields to perform self-supervised pre-training on the YOLOv8 model, and retain the pre-trained weights of the YOLOv8 model backbone network; S3. Build an improved YOLOv8 model and migrate the pre-trained weights of the backbone network to the improved YOLOv8 model; S4. Use the lithium battery surface image dataset to train the improved YOLOv8 model to obtain a defect detection model; S5. Input the surface image of the lithium battery to be inspected into the defect detection model to obtain the defect detection result.
2. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 1, characterized in that: The step S1 includes the following sub-steps: S11. Denoising the collected lithium battery surface image based on a generative adversarial network to obtain a denoised lithium battery surface image; The generator of the generative adversarial network is a U-Net network, and the discriminator is a PatchGAN network; S12, performing standardization, normalization, data enhancement, image cropping, and recalibration processing on the denoised lithium battery surface image in sequence to obtain a standard lithium battery surface image; S13. Build an unsupervised clustering model to cluster the standard lithium battery surface images, and determine and annotate the labels of each cluster based on expert opinions; S14, performing defect enhancement processing based on Perlin noise on the defect standard lithium battery surface image to expand the data volume of the defect standard lithium battery surface image; S15. Composing a lithium battery surface image dataset with the defect standard lithium battery surface image after defect enhancement processing and the normal standard lithium battery surface image.
3. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 2, characterized in that: In step S13, the unsupervised clustering model includes a FACE autoencoder and a hierarchical clustering module; The process of clustering the input standard lithium battery surface image by the unsupervised clustering model is as follows: S13-1. Extract features from the standard lithium battery surface image using the FACE autoencoder to obtain a feature vector. S13-2. In the hierarchical clustering module, the input feature vectors are clustered layer by layer. In the clustering process, mutual information constraints are introduced to determine the mutual information between the feature vectors and the cluster categories. The parameters of the FACE autoencoder and the hierarchical clustering module are reversely updated by maximizing the mutual information. S13-3. Repeat steps S13-1 to S13-2 until the unsupervised clustering model converges, and output the clustering results through the hierarchical clustering module.
4. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 2, characterized in that: In step S13-2, the clustering target of layer-by-layer clustering is: The clustering optimization goal of each layer is: Where, represents the total loss of layer-by-layer clustering, represents the clustering loss during the l-th layer clustering, KL(·) represents the divergence function used to measure the difference between the clustering results of the current layer and the previous layer, R (l) and S (l) Represent the clustering results of the current layer and the previous layer respectively, θ * Represents the model parameters that minimize the KL divergence, μ * represents the set of cluster centers that minimizes the KL divergence, r ij Indicates the membership of feature vector i to cluster j, S ij represents the distribution strength of the i-th eigenvector in the cluster, n j represents the total number of samples in cluster j; The mutual information constraint is expressed as: Where I(Z;Y) represents the mutual information between the feature vector Z and the cluster category Y, q(y|z) represents the probability distribution of cluster category assignment, and H(Y) represents the entropy of the cluster category. It represents the expectation of the joint distribution p(z,y) of the feature vector Z and the cluster category Y.
5. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 2, characterized in that: The step S14 includes the following sub-steps: S14-1. Extract high-dimensional feature information from defective standard lithium battery surface images and increase image resolution by upsampling. S14-2. Based on the defective standard lithium battery surface image, Perlin noise is introduced to generate a synthetic abnormal image; S14-3, comparing the generated abnormal image with a high-resolution defective standard lithium battery surface image in a feature space, and generating an adapted feature map by adjusting the feature mapping; S14-4. Based on the adapted feature map, adding disturbance to the synthetic abnormal image to obtain a disturbed abnormal image; S14-5, merging the disturbed abnormal image and the adapted feature map, and performing defect segmentation and classification through the segmentation head and the classification head; The segmentation head is used to detect the defect locations in the input image and generate a defect segmentation map; the classification head is used to classify the defect segmentation map and determine its defect type; S14-6. Based on the defect segmentation map for determining the defect type, the data volume of the defect standard lithium battery surface image is expanded.
6. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 1, characterized in that: The step S2 comprises the following sub-steps: S21. Collect unlabeled defect images in related fields and perform data enhancement processing on them to obtain enhanced images; S22. Replace the encoder in the SimCLR framework with the backbone network of the YOLOv8 model to form a self-supervised training model, and use the enhanced images to pre-train the self-supervised training model; During the pre-training process, the backbone network is used to extract features from the enhanced image, and the extracted features are mapped to a low-dimensional representation space through the projection head to obtain the corresponding feature representation; S23. Repeat the pre-training process until the self-supervised training model converges, retaining the pre-trained weights of the YOLOv8 model backbone network; The loss function for training the self-supervised training model is expressed as: Where, represents the contrast loss, z i and z j Represents the representation vectors obtained after two different enhanced views of the same image are extracted and projected, z k Represents the representation vectors of different images after feature extraction and projection, τ is used to control the distinction between positive and negative samples in contrastive learning, k is an index variable used to traverse all sample pairs, and N is the number of samples in each batch.
7. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 1, characterized in that: In step S3, the improved YOLOv8 model includes a Backbone network, a Neck network, and a Head network; The Backbone network includes a first convolutional layer, a first batch normalization layer, a first activation function, a first cross-stage local feature fusion module, a second convolutional layer, a second batch normalization layer, a second activation function, a second cross-stage local feature fusion module, a third convolutional layer, a third batch normalization layer, a third activation function, a third cross-stage local feature fusion module, a fourth convolutional layer, a fourth batch normalization layer, a fourth activation function, a fourth cross-stage local feature fusion module and a fast spatial pyramid pooling layer connected in sequence; The Neck network includes a feature fusion module of a fourth custom sampling rate, a second dynamic sampling layer, a third connection layer, a feature fusion module of a third custom sampling rate, a second dynamic sampling layer, a second connection layer, a feature fusion module of a second custom sampling rate, a first dynamic sampling layer, a first connection layer, a feature fusion module of a first custom sampling rate, a first efficient multi-scale attention module, a fifth convolutional layer, a fifth batch normalization layer, a fifth activation function, a fourth connection layer, a feature fusion module of a fifth custom sampling rate, a second efficient multi-scale attention module, a sixth convolutional layer, a sixth batch normalization layer, a sixth activation function, a fifth connection layer, a feature fusion module of a sixth custom sampling rate, and a third efficient multi-scale attention module, which are connected in sequence; The input end of the first connection layer is further connected to the first activation function, the input end of the second connection layer is further connected to the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is further connected to the output end of the third cross-stage local feature fusion module, and the input end of the feature fusion module with the fourth custom sampling rate is further connected to the output end of the fast spatial pyramid pooling layer; The Head network includes a first detection head, a second detection head and a third detection head; the input end of the first detection head is connected to the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected to the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected to the output end of the third efficient multi-scale attention module.
8. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 7, characterized in that: The processing process of the input feature map by the local feature fusion module from the first to the fourth stage is as follows: S41, grouping the input feature map along the x-axis pooling branch, the y-axis pooling branch, and the convolution branch; S42, performing bidirectional feature fusion on feature maps from different sources, and introducing a learning weight coefficient in the fusion process to adaptively weight features from different sources to obtain fused features; S43, after the fusion features are connected to the convolution layer, they are processed by the sigmoid activation function and the weights are redistributed to obtain the multi-scale feature representation; Among them, the formula for adaptive weighting is: P out =∑(w i ·p i ) / (ε+∑w i ) Where, P out Represents the adaptively weighted feature map, p i Represents feature maps from different sources, w i Indicates p i The corresponding weight coefficient, ε, represents a small constant for stable calculation.
9. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 7, characterized in that: The upsampling process of the input feature map from the first to the second dynamic upsampling layer is expressed as: X up =Dysample(X low ,θ(X low ))+β·EdgeEnhance(X low ) Where, X up Represents the upsampled feature map, X low represents the low-resolution feature map, i.e., the input feature map, Dysample(·) represents the parameterized dynamic upsampling operation, EdgeEnhance(·) represents the edge enhancement function, θ(·) represents the upsampling parameter adaptively generated according to the low-resolution feature map, and β represents the balance coefficient.
10. The method for intelligent detection of lithium battery surface defects based on deep learning according to claim 7, characterized in that: The process of performing spatial-channel dual attention enhancement on the input feature map by the first to third efficient multi-scale attention modules is expressed as follows: EMA(X)=σ(Conv 1×1 (Concat(Pool x (x),Pool y (x),DSConv(x)))e X+γ·GlobalContext(X) Where EMA(X) represents the attention score, σ(·) represents the Sigmoid activation function, and Conv 1×1 (·) represents convolution, Concat(·) represents concatenation, Pool x (x) represents pooling along the x-axis, Pool y (x) represents pooling along the y-axis, DSConv(x) represents depthwise separable convolution, GlobalContext(·) represents capturing global context information, X represents the input feature map, γ represents the loss coefficient, and e represents matrix multiplication.
Citation Information
Patent Citations
Lithium battery surface defect detection method based on deep learning multi-channel fusion
CN119478486A
Cited By
Lithium battery appearance defect detection system and method based on deep learning
CN121236048A
Lithium battery appearance defect detection system and method based on deep learning
CN121236048B
Knee meniscus injury detection method and system fusing multiple sequences and contrast learning
CN121767758A