A deep learning-based intelligent detection method for surface defects of lithium batteries

By constructing a lithium battery surface image dataset using generative adversarial networks and unsupervised clustering techniques, and improving the YOLOv8 model, the data dependency and adaptability issues of lithium battery surface defect detection in existing technologies are resolved, achieving efficient and accurate defect detection.

CN120495764BActive Publication Date: 2026-02-13SICHUAN UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510593829.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2026-02-13
Estimated Expiration
2045-05-09

AI Technical Summary

Technical Problem

Existing deep learning detection methods for lithium battery surface defect detection suffer from several drawbacks, including strong dependence on large-scale, high-quality labeled data, insufficient sensitivity to small target defects, and poor adaptability to defects with complex shapes and extreme aspect ratios, resulting in unsatisfactory detection performance.

Method used

Image denoising based on generative adversarial networks is employed. A lithium battery surface image dataset is constructed by combining unsupervised clustering and Perlin noise enhancement techniques. Furthermore, the YOLOv8 model structure is improved through self-supervised pre-training to enhance detection performance.

Benefits of technology

It achieves high-precision and high-efficiency detection of lithium battery surface defects, reduces the workload of manual annotation, improves the model's generalization ability and adaptability to complex defects, and enhances the ability to identify small target defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495764B_ABST
    Figure CN120495764B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on deep learning's lithium battery surface defect intelligent detection method, comprising: S1, the unsupervised clustering auxiliary defect labeling of the lithium battery surface image collected is carried out, and defect enhancement processing is carried out, constructs lithium battery surface image dataset;S2, using the unlabeled defect image of relevant field is to YOLOv8 model self-supervision pretraining, and reserve YOLOv8 model backbone network pretraining weight;S3, improved YOLOv8 model is constructed, and the pretraining weight of backbone network is migrated to improved YOLOv8 model;S4, using lithium battery surface image dataset is to improved YOLOv8 model training, obtains defect detection model;S5, the lithium battery surface image to be detected is input into defect detection model, obtains defect detection result.The method of the application realizes the high accuracy and high efficiency of the lithium battery surface defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of image processing, and particularly relates to a lithium battery surface defect detection method based on deep learning. BACKGROUND

[0002] As the cornerstone of many strategic emerging industries, lithium batteries are an important pillar for promoting the transformation of clean energy, intelligent manufacturing, and the development of emerging transportation systems.

[0003] Currently, the production and processing of lithium batteries have basically achieved full-process automation, but in the production process, factors such as machine damage and component collision may cause surface scratches, damage, pits, and even more serious aluminum and liquid leakage defects. These defects not only affect the appearance of lithium batteries, but also may damage their internal structure, leading to reduced performance and even safety hazards such as explosions. Existing deep learning detection has many limitations in defect detection, including strong dependence on large-scale high-quality labeled data, insufficient sensitivity to small target defects, poor adaptability to complex shapes and extreme aspect ratio defects, etc.

[0004] Among them, the development of YOLO series in the field of industrial defect detection is of great significance to improve the detection performance and adapt to diversified industrial scenarios, but when applied to the field of lithium battery surface defect detection, the YOLO series model has limited ability, especially when the defect size is small and the contrast with the background is low, which may lead to missed detection and false detection. 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 lithium battery surface defects has become a difficult problem to be solved in the lithium battery industry. SUMMARY

[0006] In view of the above deficiencies in the prior art, the intelligent detection method for lithium battery surface defects based on deep learning provided by the present application solves the problem of 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 when using existing deep learning detection methods for lithium battery defect detection, thereby affecting the detection effect of lithium battery surface defects.

[0007] In order to achieve the above-mentioned application purposes, the technical scheme adopted by the present application is as follows: an intelligent detection method for lithium battery surface defects based on deep learning, comprising the following steps:

[0008] S1, unsupervised clustering assisted defect labeling is performed on the collected lithium battery surface image, and defect enhancement processing is performed to construct a lithium battery surface image dataset;

[0009] S2, pre-training the YOLOv8 model in a self-supervised manner using unlabeled defect images in the relevant field, and retaining the pre-training weights of the backbone network of the YOLOv8 model;

[0010] S3, constructing an improved YOLOv8 model, and migrating the pre-training weights of the backbone network to the improved YOLOv8 model;

[0011] S4, training the improved YOLOv8 model using a lithium battery surface image dataset to obtain a defect detection model;

[0012] S5, inputting a lithium battery surface image to be detected into the defect detection model to obtain a defect detection result.

[0013] Further, the step S1 comprises 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, sequentially performing standardization, normalization, data enhancement, image cropping and re-calibration processing on the denoised lithium battery surface image to obtain a standard lithium battery surface image;

[0017] S13, constructing an unsupervised clustering model to cluster the standard lithium battery surface image, and determining and labeling the labels of each cluster in combination with expert opinions;

[0018] S14, performing defect enhancement processing based on Perlin noise on the defect standard lithium battery surface image to expand the data amount of the defect standard lithium battery surface image;

[0019] S15, combining the defect standard lithium battery surface image after defect enhancement processing and the normal standard lithium battery surface image to form a lithium battery surface image dataset.

[0020] Further, in the step S13, the unsupervised clustering model comprises a FACE autoencoder and a hierarchical clustering module.

[0021] The process of the unsupervised clustering model clustering the input standard lithium battery surface image is as follows:

[0022] S13-1, extracting features of the standard lithium battery surface image through the FACE autoencoder to obtain a feature vector;

[0023] S13-2, in the hierarchical clustering module, the input feature vector is clustered layer by layer, and mutual information constraint is introduced in the clustering process to determine the mutual information between the feature vector and the clustering category, and the parameters of the FACE auto-encoder and the hierarchical clustering module are updated reversely by maximizing the mutual information;

[0024] S13-3, repeating steps S13-1 to S13-2 until the unsupervised clustering model converges, and outputting the clustering result through the hierarchical clustering module.

[0025] Further, in step S13-2, the clustering target of the layer-by-layer clustering is:

[0026]

[0027] The clustering optimization target of each layer is:

[0028]

[0029] In the formula, L represents the total loss of layer-by-layer clustering, L represents the clustering loss when clustering the l-th layer, KL(·) represents a divergence function for measuring the difference between the current layer and the clustering result of the previous layer, R (l) and S (l) respectively represent the clustering results of the current layer and the previous layer, θ * represents the model parameters that minimize the KL divergence, μ * represents the set of clustering centers that minimize the KL divergence, r ij represents the membership degree of feature vector i belonging to cluster j, S ij represents the assignment strength of the i-th feature vector in the cluster, n j represents the total number of samples in cluster j.

[0030] The mutual information constraint is represented as:

[0031]

[0032] In the formula, I(Z;Y) represents the mutual information between the feature vector Z and the clustering category Y, q(y|z) represents the probability distribution of the clustering category assignment, H(Y) represents the entropy of the clustering category, represents the expectation of the joint distribution p(z,y) of the feature vector Z and the clustering category Y.

[0033] Further, the step S14 includes the following sub-steps:

[0034] S14-1, extracting high-dimensional feature information from the surface image of the defective standard lithium battery, and raising the image resolution through upsampling;

[0035] S14-2, on the basis of the defect standard lithium battery surface image, a Perlin noise is introduced to generate a synthetic abnormal image;

[0036] S14-3, the generated abnormal image is compared with the high-resolution defect standard lithium battery surface image in the feature space, and an adapted feature map is generated by adjusting the feature mapping;

[0037] S14-4, based on the adapted feature map, perturbations are added to the synthetic abnormal image to obtain a perturbed abnormal image;

[0038] S14-5, the perturbed abnormal image and the adapted feature map are merged, and the segmentation head and the classification head are used for defect segmentation and classification;

[0039] The segmentation head is used to detect the defect position in the input image to generate a defect segmentation map; the classification head is used to classify the defect segmentation map to determine the defect type;

[0040] S14-6, based on the defect segmentation map of the determined defect type, the data amount of the defect standard lithium battery surface image is expanded.

[0041] Further, the step S2 comprises the following sub-steps:

[0042] S21, collecting unlabeled defect images in the related field and performing data enhancement processing to obtain enhanced images;

[0043] S22, replacing the encoder in the SimCLR framework with the backbone network of the YOLOv8 model to form a self-supervised training model, and pre-training the self-supervised training model using the enhanced images;

[0044] During the pre-training process, the enhanced images are feature-extracted by the backbone network, and the extracted features are mapped to a low-dimensional representation space through the projection head to obtain corresponding feature representations;

[0045] S23, repeating the pre-training process until the self-supervised training model converges, and retaining the pre-training weight of the YOLOv8 model backbone network;

[0046] The loss function for training the self-supervised training model is represented as:

[0047]

[0048] In the formula, represents the contrast loss, z i and z j represent the representation vectors obtained by the two different enhanced perspectives of the same image through the feature extraction and projection head, z krepresents the representation vectors obtained after feature extraction and projection head of different images, τ represents the control used to control the discrimination between positive and negative samples in contrast learning, k is an index variable for traversing all sample pairs, and N represents the number of samples in each batch.

[0049] Further, in the 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 fourth custom sampling rate feature fusion module, a second dynamic sampling layer, a third connection layer, a third custom sampling rate feature fusion module, a second dynamic sampling layer, a second connection layer, a second custom sampling rate feature fusion module, a first dynamic sampling layer, a first connection layer, a first custom sampling rate feature fusion module, 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 fifth custom sampling rate feature fusion module, 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 sixth custom sampling rate feature fusion module, and a third efficient multi-scale attention module connected in sequence.

[0052] The input end of the first connection layer is further connected with the first activation function, the input end of the second connection layer is further connected with the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is further connected with 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 further connected with 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 with the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected with the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected with the output end of the third efficient multi-scale attention module.

[0054] Further, the processing process of the first to fourth cross-stage local feature fusion modules on the input feature map is as follows:

[0055] S41, group the input feature maps along the x-axis pooling branch, the y-axis pooling branch and the convolution layer branch respectively;

[0056] S42, bidirectional feature fusion is performed on the feature maps of different sources, and learning weight coefficients are introduced in the fusion process to adaptively weight the features of different sources, thereby obtaining fused features;

[0057] S43, after the fused features pass through a connection convolution layer, multi-scale feature representations are output by s-type activation function and reweighting processing;

[0058] wherein the adaptive weighting formula is:

[0059] P out =∑(w i ·p i ) / (ε+∑w i )

[0060] In the formula, P out represents the feature map after adaptive weighting, p i represents the feature map of different sources, w i represents the corresponding weight coefficient of p i , and ε represents a small constant for stable calculation.

[0061] Further, the upsampling process of the first to second dynamic upsampling layers on the input feature map is represented as:

[0062] X up =Dysample(X low ,θ(X low ))+β·EdgeEnhance(X low )

[0063] In the formula, X up represents the feature map after upsampling, X low represents the low-resolution feature map, i.e. the input feature map, Dysample(·) represents a parameterized dynamic upsampling operation, EdgeEnhance(·) represents an edge enhancement function, θ(·) represents the upsampling parameters adaptively generated according to the low-resolution feature map, and β represents a balance coefficient.

[0064] Further, the process of the first to third efficient multi-scale attention modules for spatial-channel dual attention enhancement on the input feature map is represented as:

[0065] EMA(X)=σ(Conv 1×1 (Concat(Pool x (x),Pool y(x), DSConv(x))) e X + γ · GlobalContext(X)

[0066] wherein EMA(X) represents an attention score, σ(·) represents a Sigmoid activation function, Conv 1×1 (·) represents a convolution, Concat(·) represents a concatenation operation, Pool x (x) represents a pooling along an x-axis, Pool y (x) represents a pooling along a y-axis, DSConv(x) represents a depth separable convolution, GlobalContext(·) represents capturing global context information, X represents an input feature map, γ represents a loss coefficient, and e represents a matrix multiplication.

[0067] The method of the present application realizes the unification of high precision and high efficiency in detecting the surface defects of lithium batteries, which is specifically embodied in:

[0068] (1) The present application carries out denoising and other preprocessing processes based on a generative adversarial network for collecting lithium battery surface images, ensuring the consistency of the quality of the lithium battery surface images, and providing a high-quality data basis 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 application greatly reduces the workload of manual labeling by using unsupervised clustering assisted labeling based on FACE autoencoder and hierarchical clustering module, and ensures the uniqueness of the labeling, quickly obtains a large amount of high-quality label data for subsequent training and use of the YOLOv8 model.

[0070] (3) Based on the defect lithium battery surface images obtained by unsupervised clustering assisted labeling, the present application synthesizes representative defect samples to fill in the scarce sample categories through a defect enhancement synthesis process based on Perlin noise, enhances the diversity of the defect lithium battery surface image dataset, and thus improves the training effect of the model in the case of few samples.

[0071] (4) The present application collects unannotated defect images in other related fields for self-supervised pre-training of the YOLOv8 model, providing high-quality data suitable for self-supervised learning for the lithium battery surface defect detection task. Not only does it cover five typical lithium battery surface defects such as cracks, pits, wrinkles, patches, and dirt, but it also integrates surface defect samples of various industrial materials such as metal, wood, silk, and steel rails. Through the combination of such diversified data, the characteristics of the lithium battery surface defects are ensured, and the adaptability and generalization ability of the self-supervised learning model in other industrial defect detection scenarios are also improved.

[0072] (5) The application provides an improved YOLOv8 model with high detection performance, which improves the accuracy and real-time performance of lithium battery surface defect detection by designing a cross-stage local feature fusion module, a dynamic sampling layer and an efficient multi-scale attention module, wherein the cross-stage local feature fusion module optimizes the representation ability of multi-scale features, the Dysample dynamic up-sampling mechanism of the dynamic sampling layer enhances the perception of defect boundaries, and the EMA mixed attention mechanism of the efficient multi-scale attention module improves the attention ability of the model to defect areas. BRIEF DESCRIPTION OF DRAWINGS

[0073] Figure 1 A deep learning-based lithium battery surface defect intelligent detection method flowchart is provided for the application.

[0074] Figure 2 An improved YOLOv8 model structure diagram is provided for the application.

[0075] Figure 3 A first to fourth cross-stage local feature fusion module processing flowchart for input feature maps is provided for the application. DETAILED DESCRIPTION

[0076] The specific embodiments of the application are described below to facilitate understanding of the application by those skilled in the art, but it should be clear that the application is not limited to the scope of the specific embodiments, and for those skilled in the art, it is obvious that various changes are within the spirit and scope of the application as defined in the appended claims, and all applications utilizing the concept of the application are within the scope of protection.

[0077] The application embodiment provides a deep learning-based lithium battery surface defect intelligent detection method, as shown in Figure 1 , comprising the following steps:

[0078] S1, unsupervised clustering assisted defect labeling is performed on the collected lithium battery surface image, and defect enhancement processing is performed to construct a lithium battery surface image dataset;

[0079] S2, a YOLOv8 model is pre-trained in a self-supervised manner using unlabeled defect images in the relevant field, and the pre-training weights of the backbone network of the YOLOv8 model are retained;

[0080] S3, an improved YOLOv8 model is constructed, and the pre-training weights of the backbone network are migrated to the improved YOLOv8 model;

[0081] S4, the improved YOLOv8 model is trained using the lithium battery surface image dataset to obtain a defect detection model;

[0082] S5, input the surface image of the lithium battery to be detected into the defect detection model to obtain a defect detection result.

[0083] The step S1 of the embodiment of the application comprises the following sub-steps:

[0084] S11, denoising the collected surface image of the lithium battery based on a generative adversarial network to obtain a denoised surface image of the lithium battery;

[0085] The generator of the generative adversarial network is a U-Net network, and the discriminator is a PatchGAN network.

[0086] S12, sequentially performing standardization, normalization, data enhancement, image cropping and re-calibration on the denoised surface image of the lithium battery to obtain a standard surface image of the lithium battery;

[0087] S13, constructing an unsupervised clustering model to cluster the standard surface image of the lithium battery, and determining and labeling the labels of each cluster in combination with expert opinions.

[0088] S14, performing defect enhancement processing based on Perlin noise on the defect standard surface image of the lithium battery to expand the data amount of the defect standard surface image of the lithium battery.

[0089] S15, combining the defect standard surface image of the lithium battery after the defect enhancement processing and the normal standard surface image of the lithium battery to form a surface image data set of the lithium battery.

[0090] In the step S11 of the embodiment, in order to ensure the clarity and accuracy of the surface image of the lithium battery, a high-precision CMOS sensor and a professional industrial camera are used in combination with a precise optical system to collect the surface image of the lithium battery on the lithium battery production line. The resolution of the image is 3000*3000 pixels, which meets the specification requirements of the YOLOv8 model and provides high-quality image data for the training of the subsequent deep learning model; the surface image of the lithium battery collected in the embodiment covers typical defect types of the surface of the lithium battery, including pits, edge wrinkles, damage, bumps, indentations, dirt, wrinkles, etc.

[0091] In the step S11 of the embodiment, in order to eliminate the noise in the surface image of the lithium battery, especially the factors affecting the intelligence of the image such as light spots and blurring that may occur during shooting; in the embodiment, a denoising method based on a generative adversarial network (GAN) is used, in which a generator generates a denoised image through training, and a discriminator judges the similarity between the generated image and the real clean image, so as to optimize the output of the generator and achieve the effect of removing noise.

[0092] Specifically, in the adversarial generative network in this embodiment, the generator is a U-Net network structure, and the discriminator is a PatchGAN network structure; wherein the U-Net network structure adopts an encoder and a decoder part, the encoder extracts image features, the decoder reconstructs the image, and a skip connection is added between the encoder and the decoder to retain image detail information. The PatchGAN structure outputs the discrimination result of each patch in the image.

[0093] In the adversarial generative network described above, for the generator, the training loss function is:

[0094] L gen =L adv +λL L1

[0095] In the formula, L adv represents 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 a weight coefficient for balancing the adversarial loss and the L1 loss.

[0096] For the discriminator, the training loss function is:

[0097] L disc =L real +L fake

[0098] In the formula, L real represents the real image loss to prompt the discriminator to correctly identify the real clean image, and L fake represents the generated image loss to prompt the discriminator to correctly identify the image generated by the generator.

[0099] In step S12 of this embodiment, all the denoised images are subjected to standardization processing, 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, the image is subjected to data enhancement processing, specifically including random rotation (randomly rotating the image by a certain angle to enhance the recognition ability of the model for defects in different directions), random flipping (including horizontal flipping and vertical flipping), random scaling (enlarging and reducing the image), and random cropping (cropping part of the area from the image to simulate defect images under different shooting angles). Further, for original images of different sizes, they are cropped and re-calibrated in this embodiment to ensure that the size of all images input into the model is uniform, i.e., 640x640 pixels. This process avoids image distortion by maintaining the aspect ratio of the image, thereby retaining the true form of the defect to the greatest extent.

[0100] Through the above processing steps, the consistency of the lithium battery surface image in quality is ensured, and the subsequent training based on the YOLOv8 model provides a high-quality data basis, and 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. The present application proposes an innovative unsupervised clustering assisted labeling method, which combines the FACE autoencoder and the hierarchical clustering Soft K-Means algorithm, breaks through the bottleneck of traditional reliance on manual labeling, and effectively improves the labeling efficiency through automation.

[0102] In this embodiment, the process of the unsupervised clustering model clustering the input standard lithium battery surface image is as follows:

[0103] S13-1, extracting features of the standard lithium battery surface image through the FACE autoencoder to obtain a feature vector;

[0104] S13-2, in the hierarchical clustering module, the input feature vector is clustered layer by layer, and mutual information between the feature vector and the clustering category is determined by introducing mutual information constraint in the clustering process, and the parameters of the FACE autoencoder and the hierarchical clustering module are updated in reverse by maximizing the mutual information;

[0105] S13-3, repeating steps S13-1 to S13-2 until the unsupervised clustering model converges, and outputting the clustering result 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, which is an unsupervised deep learning model. Its core task is to compress image data into low-dimensional feature vectors through the encoder, and to 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 which the features of the image are refined and assigned to different clustering categories. The hierarchical clustering algorithm calculates the probability value of each sample belonging to a certain cluster, avoiding the boundary ambiguity problem of hard clustering.

[0108] When performing layer-by-layer clustering, the clustering target for layer-by-layer clustering is:

[0109]

[0110] The clustering optimization objective of each layer is:

[0111]

[0112] wherein, represents the total loss of layer-by-layer clustering, represents the clustering loss when clustering the l-th layer, KL(·) represents a divergence function for measuring the difference between the current layer and the clustering result of 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 clustering centers that minimize the KL divergence, r ij represents the membership of feature vector i belonging to cluster j, S ij represents the assignment strength of the i-th feature vector 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 class are clustered together, and samples of different categories are effectively distinguished.

[0114] wherein, the mutual information constraint is represented as:

[0115]

[0116] wherein, I(Z;Y) represents the mutual information between feature vector Z and cluster category Y, q(y|z) represents the probability distribution of cluster category assignment, H(Y) represents the entropy of the cluster category, represents the expectation of the joint distribution p(z,y) of feature vector Z and cluster category Y.

[0117] After the above hierarchical clustering and mutual information optimization, the clustering result is output. Since the clustering result of each layer is based on the output of the previous layer, this makes the clustering process gradually refined, ensuring that the final clustering result is more accurate.

[0118] After generating the preliminary clustering result based on the unsupervised clustering model, the expert only needs to confirm a small number of representative images. After the expert confirms, the label of the entire clustering cluster can be determined, and labeling is performed on this basis, thereby greatly reducing the workload of manual labeling and ensuring the consistency and accuracy of labeling. In this way, we can quickly obtain a large amount of high-quality labeled data for subsequent improvement of the training of the YOLOv8 model.

[0119] In this embodiment, in the task of lithium battery surface defect detection, after unsupervised clustering assisted labeling, although most of the defect images can be successfully labeled and provide effective training data, sometimes there are still insufficient sample data for some specific defect categories. Especially for some rare defects such as convex points, edge wrinkles, etc., their occurrence frequency is low in the actual production process, which leads to the problem of sample scarcity in the labeled data.

[0120] To solve this problem, this embodiment proposes a defect enhancement processing based on Perlin, which aims to fill in 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; In this embodiment, the natural texture generation technology of Perlin noise is used to effectively solve the problem of insufficient samples in the defect detection task.

[0121] The step S14 of the embodiment includes the following sub-steps:

[0122] S14-1, extracting high-dimensional feature information from the defect standard lithium battery surface image, and up-sampling to the image resolution;

[0123] Among them, for the real defect images in the standard lithium battery surface image data, especially those rare defect categories with insufficient quantity in the labeled data, these original images are used as the basis samples for the synthesis process, providing a reference for generating high-quality synthetic samples subsequently;

[0124] Specifically, the extracted high-dimensional feature information includes features such as the texture and shape of the defect; The up-sampling process increases the resolution of the image to ensure that the generated synthetic samples have sufficient details and can maintain visual consistency with the original image;

[0125] S14-2, introducing Perlin noise based on the defect standard lithium battery surface image to generate a synthetic abnormal image;

[0126] Specifically, Perlin noise is an algorithm for generating natural textures, which can provide smooth and continuous random noise. This noise can simulate the natural features that may appear in the lithium battery surface defect image; Wherein, the synthetic abnormal image is represented as:

[0127]

[0128] In the formula, M represents the defect standard lithium battery surface image, Mg represents Gaussian noise, ε represents perturbation noise, η represents the intensity adjustment coefficient, Perlin(M) represents the result of applying Perlin noise to the defect standard lithium battery surface image, Indicates an image mixing operation; in this way, the system can generate new defect samples with diversity on the basis of maintaining the original defect features;

[0129] S14-3, compare the generated abnormal image with the high-resolution defect standard lithium battery surface image in the feature space, and generate 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 features, but also conforms to the features of the real lithium battery surface defect samples in the training data set. In this process, the synthetic feature map is compared with the original image, and the synthetic image is adjusted by adjusting the feature mapping, so that it is closer to the performance of the real defect, improving the quality and effectiveness of the synthetic sample;

[0131] S14-4, based on the adapted feature map, adding perturbation to the synthetic abnormal image to obtain a perturbed abnormal image;

[0132] Specifically, based on the adapted feature map, perturbation is added to the synthetic abnormal image to enhance the robustness of the synthetic abnormal image under various environments, simulate the lithium battery surface defect image that may appear under different interference conditions; This step further improves the quality and practicality of the synthetic sample, making it more suitable for defect detection in actual production environment;

[0133] S14-5, merge the perturbed abnormal image and the adapted feature map, and perform defect segmentation and classification through the segmentation head and the classification head;

[0134] The segmentation head is used to detect the defect position in the input image to generate a defect segmentation map; the classification head is used to classify the defect segmentation map to determine the defect type;

[0135] S14-6, based on the defect segmentation map of the determined defect type, expanding the data amount of the defect standard lithium battery surface image.

[0136] In the lithium battery surface defect detection task in the embodiment of the application, the performance of the deep learning model depends largely on the quality and quantity of the training data; however, in actual industrial applications, it is often costly and time-consuming to obtain a large number of defect images with accurate annotations; In order to solve this problem, the self-supervised training process is proposed in the application, which uses unlabeled defect image data sets related to the field of lithium batteries (such as FineDefect) for self-supervised training, which significantly improves the initial representation ability of the model for complex defect features.

[0137] Based on this, the step S2 of the embodiment of the application comprises the following sub-steps:

[0138] S21, collect unlabeled defect images in the related field and perform data enhancement processing to obtain enhanced images;

[0139] Specifically, the pre-training process first collects unlabeled images from the FineDefect dataset. These images do not require human annotation and are directly used in the self-supervised learning process, greatly reducing the data preparation cost.

[0140] Further, the unlabeled images are enhanced, including random rotation (randomly rotating the image by a certain angle to enhance the model's recognition ability for 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 part 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 pre-train the self-supervised training model using the enhanced images;

[0142] During the pre-training process, the backbone network extracts features from the enhanced images, and the extracted features are mapped to a low-dimensional representation space through the projection head to obtain corresponding feature representations;

[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 multiple layers of perceptron (MLP), and the specific structure is a linear layer followed by a ReLU activation function, and then a linear layer; such design enables the backbone network to learn more general feature representations, and the projection head can convert these features into a suitable representation form for contrastive learning.

[0144] S23, repeat the pre-training process until the self-supervised training model converges, and retain the pre-training weights of the YOLOv8 model backbone network.

[0145] In this embodiment, the self-supervised pre-training model uses an improved contrastive loss function, which is represented as:

[0146]

[0147] In the formula, represents the contrastive loss, z i and z j represent the representation vectors obtained after feature extraction and projection head for two different enhanced views of the same image, z k represent the representation vectors obtained after feature extraction and projection head for different images, τ represents a variable used to control the discrimination between positive and negative samples in contrastive learning, k is an index variable used to traverse all sample pairs, and N represents the number of samples in each batch.

[0148] In the embodiment, by minimizing the contrast loss, the model learns to pull the different perspectives of the same image closer, while pushing the representations of different images further apart, thereby learning a discriminative feature representation; compared with the traditional SimCLR framework, the similarity between vectors is calculated using the sin function in the embodiment, instead of the cosine similarity, which improves the model's ability to capture subtle differences in defect features.

[0149] In the embodiment, based on the SimCLR framework, the application makes a breakthrough improvement on the traditional self-supervised learning, replacing the encoder in the SimCLR framework with the backbone network of the self-designed YOLOv8; pre-training using a large number of unlabeled defect images in FineDefect significantly improves the model's initial representation ability for complex defect features.

[0150] In the embodiment of the application, 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 recognition ability of small defects on the surface of lithium battery, the application proposes a Super-Detect improvement framework based on the YOLOv8 model, realizing the unification of high precision and high efficiency.

[0151] In step S3 of the embodiment of the application, as shown in Figure 2 The improved YOLOv8 model mainly includes three key innovative structures, including a cross-stage local feature fusion module, a dynamic sampling layer and an efficient multi-scale attention module, which enable the model to achieve higher precision and efficiency when detecting subtle defects.

[0152] Specifically, in the Figure 2 Improved YOLOv8 model includes Backbone network, Neck network and Head network;

[0153] 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.

[0154] The Neck network comprises, in sequence, a fourth custom sampling rate feature fusion module, a second dynamic sampling layer, a third connection layer, a third custom sampling rate feature fusion module, a second dynamic sampling layer, a second connection layer, a second custom sampling rate feature fusion module, a first dynamic sampling layer, a first connection layer, a first custom sampling rate feature fusion module, a first efficient multi-scale attention module, a fifth convolution layer, a fifth batch normalization layer, a fifth activation function, a fourth connection layer, a fifth custom sampling rate feature fusion module, a second efficient multi-scale attention module, a sixth convolution layer, a sixth batch normalization layer, a sixth activation function, a fifth connection layer, a sixth custom sampling rate feature fusion module, and a third efficient multi-scale attention module.

[0155] The input end of the first connection layer is further connected with the first activation function, the input end of the second connection layer is further connected with the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is further connected with 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 further connected with the output end of the fast spatial pyramid pooling layer.

[0156] The Head network comprises a first detection head, a second detection head, and a third detection head. The input end of the first detection head is connected with the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected with the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected with the output end of the third efficient multi-scale attention module.

[0157] In the present embodiment, the cross-stage local feature fusion module optimizes multi-scale feature fusion through a bidirectional feature full learning network, significantly enhancing the detection capability for micro defects, as shown in Figure 3 As shown in the figure, the cross-stage local feature fusion module adopts a network structure similar to a pyramid, fully utilizing feature information of different scales through multi-level feature extraction and fusion. The processing of the input feature map is specifically as follows:

[0158] S41, group the input feature map along the x-axis pooling branch, the y-axis pooling branch, and the convolution layer branch, respectively;

[0159] S42, perform bidirectional feature fusion on the feature maps of different sources, and introduce a learning type weight coefficient in the fusion process to adaptively weight the features of different sources, to obtain fused features;

[0160] S43, after the fused features pass through a connection convolution layer, output multi-scale feature representations through an s-type activation function and a reweighting process;

[0161] The formula for adaptive weighting is as follows:

[0162] P out =∑(wi • p i ) / (ε+∑w i )

[0163] where P out denotes the adaptive weighted feature map, p i denotes the feature map of different sources, w i denotes the corresponding weight coefficient of p i , and ε denotes a small constant for stable calculation.

[0164] In the embodiment, unlike the 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 bottom-level detail features and the high-level semantic features can fully interact.

[0165] In the embodiment, in order to better process feature information of different scales, especially to enhance the perception ability of defect boundaries, the application proposes a dynamic upsampling mechanism. Based on this, the upsampling process of the first to second dynamic upsampling layers on the input feature map is represented as:

[0166] X up = Dysample(X low , θ(X low ))+ β·EdgeEnhance(X low )

[0167] where X up denotes the upsampled feature map, X low denotes the low-resolution feature map, i.e., the input feature map, Dysample(·) denotes a parameterized dynamic upsampling operation, EdgeEnhance(·) denotes an edge enhancement function, θ(·) denotes upsampled parameters adaptively generated according to the low-resolution feature map, and β denotes a balance coefficient.

[0168] In the above dynamic upsampling mechanism proposed in the embodiment, the upsampled parameters θ(·) are dynamically generated according to the content of the input feature map, so that the upsampling process can be adjusted according to the content characteristics of different regions; EdgeEnhance(·) is specially used to enhance the defect boundary features, extracts edge information through a multi-scale gradient operator, further highlights the defect boundary features, and is crucial for accurately positioning the defect boundary; in the above dynamic upsampling process, the original feature information is preserved through residual connection, avoiding the loss of important information in the upsampling process.

[0169] In the embodiment, in order to enhance the attention ability of the model to the defect area, the application proposes an efficient multi-scale attention module, which includes the following key components:

[0170] Multi-dimensional pooling: Poolx and Pool y Average pooling in 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 Concat operation, and then 1x1 convolution and sigma activation function are used to generate attention weight map;

[0173] Global context enhancement: GlobalContext improves the adaptability of the model to complex backgrounds by capturing global context information; this module aggregates global information through self-attention mechanism and fuses with local features, enabling the model to better understand the relationship between defects and backgrounds.

[0174] Based on the above key components, the process of efficient multi-scale attention module for spatial-channel dual attention enhancement of input feature map is represented as:

[0175] EMA(X) = sigma(Conv 1×1 (Concat(Pool x (x), Pool y (x), DSConv(x)))e X + gamma.GlobalContext(X)

[0176] In the formula, EMA(X) represents attention score, sigma(·) represents Sigmoid activation function, Conv 1×1 (·) represents convolution, Concat(·) represents concatenation operation, Pool x (x) represents pooling along x-axis, Pool y (x) represents pooling along y-axis, DSConv(x) represents depthwise separable convolution, GlobalContext(·) represents capturing global context information, X represents input feature map, gamma represents loss coefficient, and e represents matrix multiplication.

[0177] In this embodiment, through the synergistic effect of each component, the improved YOLOv8 model realizes the unification of high precision and high efficiency in detecting small defects on the surface of lithium batteries. Specifically, the cross-stage local feature fusion module optimizes the representation ability of multi-scale features, the Dysample dynamic up-sampling 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 attention ability of the model to the defect area.

[0178] The principles and implementation manners of the present application are described by using specific examples in the present application, and the above examples are only used for helping to understand the method of the present application and its core idea; meanwhile, for the ordinary skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges can be changed, and the above description should not be understood as the limitation of the present application.

[0179] Those skilled in the art will appreciate that the examples described herein are presented for purposes of aiding the reader in understanding the principles of the present application and are not intended to limit the scope of the present application to just such specifically recited examples and embodiments. Various modifications and alterations of the present application are possible and within the scope of the present application as would be understood by those skilled in the art, and it is intended to encompass all such modifications and alterations as fall within the scope of the present application.

Claims

1.A deep learning-based intelligent detection method for surface defects of lithium batteries, characterized in that, The method comprises the following steps: S1, unsupervised clustering assisted defect labeling is performed on the collected lithium battery surface image, and defect enhancement processing is performed, and a lithium battery surface image dataset is constructed; S2, the YOLOv8 model is pre-trained in a self-supervised manner using unlabeled defect images in the relevant field, and the pre-training weights of the backbone network of the YOLOv8 model are reserved; S3, an improved YOLOv8 model is constructed, and the pre-training weights of the backbone network are migrated to the improved YOLOv8 model; S4, the improved YOLOv8 model is trained using the lithium battery surface image dataset to obtain a defect detection model; S5, the surface image of the lithium battery to be detected is input into the defect detection model to obtain a defect detection result; The step S1 comprises the following steps: S11, the collected lithium battery surface image is denoised based on a generative adversarial network to obtain a denoised lithium battery surface image; Wherein, the generator of the generative adversarial network is a U-Net network, and the discriminator is a PatchGAN network; S12, the denoised lithium battery surface image is sequentially subjected to standardization, normalization, data enhancement, image cropping and re-calibration processing to obtain a standard lithium battery surface image; S13, a standard lithium battery surface image is clustered using an unsupervised clustering model, and the labels of each cluster are determined and labeled in combination with expert opinions; S14, the defect standard lithium battery surface image is subjected to defect enhancement processing based on Perlin noise to expand the data amount of the defect standard lithium battery surface image; S15, the defect standard lithium battery surface image after defect enhancement processing and the normal standard lithium battery surface image are combined to form a lithium battery surface image dataset; In the step S13, the clustering target of the hierarchical clustering module in the unsupervised clustering model when introducing mutual information constraint for layer-by-layer clustering is: The clustering optimization target of each layer is: wherein, denotes the total loss of layer-wise clustering, denotes the clustering loss of the l-th layer clustering, denotes a divergence function for measuring the difference between the current layer and the clustering result of the previous layer, and denote the clustering results of the current layer and the previous layer, respectively, denotes the model parameters that minimize the KL divergence, denotes the set of clustering centers that minimize the KL divergence, denotes the membership of the feature vector i to the cluster j, denotes the assignment strength of the i-th feature vector in the cluster, denotes the total number of samples of the cluster j; The mutual information constraint is expressed as: In the formula, Representing the eigenvector Clustering categories Mutual information between them This represents the probability distribution of cluster category assignments. Entropy representing the cluster categories, Represents the eigenvector Clustering categories joint distribution The expectation. 2.The deep learning-based lithium battery surface defect intelligent detection method of claim 1, wherein, In the step S13, the unsupervised clustering model comprises a FACE autoencoder and a hierarchical clustering module; The process of the unsupervised clustering model clustering the input standard lithium battery surface image is: S13-1, the standard lithium battery surface image is subjected to feature extraction by the FACE autoencoder to obtain a feature vector; S13-2, the input feature vector is subjected to layer-by-layer clustering in the hierarchical clustering module, and the mutual information between the feature vector and the clustering category is determined by introducing mutual information constraint in the clustering process, and the parameters of the FACE autoencoder and the hierarchical clustering module are updated in reverse by maximizing the mutual information; S13-3, steps S13-1 to S13-2 are repeated until the unsupervised clustering model converges, and the clustering result is output by the hierarchical clustering module. 3.The deep learning-based lithium battery surface defect intelligent detection method of claim 1, wherein, The step S14 comprises the following steps: S14-1, high-dimensional feature information is extracted from the defect standard lithium battery surface image, and the image resolution is raised by upsampling; S14-2, Perlin noise is introduced based on the defect standard lithium battery surface image to generate a synthetic abnormal image; S14-3, compare the generated abnormal image with the high-resolution defect standard lithium battery surface image in the feature space, and generate an adapted feature map by adjusting the feature mapping; S14-4, based on the adapted feature map, add perturbations in the synthetic abnormal image to obtain a perturbed abnormal image; S14-5, merge the perturbed abnormal image and the adapted feature map, and perform defect segmentation and classification through the segmentation head and the classification head; The segmentation head is used to detect the defect position in the input image to generate a defect segmentation map; the classification head is used to classify the defect segmentation map to determine the defect type; S14-6, based on the defect segmentation map of the determined defect type, expand the data amount of the defect standard lithium battery surface image. 4.The deep learning-based lithium battery surface defect intelligent detection method of claim 1, wherein, The step S2 includes the following sub-steps: S21, collect unlabeled defect images in the related field, and perform data enhancement processing 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 pre-train the self-supervised training model using the enhanced images; In the pre-training process, the enhanced images are feature-extracted by the backbone network, and the extracted features are mapped to a low-dimensional representation space through a projection head to obtain corresponding feature representations; S23, repeat the pre-training process until the self-supervised training model converges, and retain the pre-training weight of the YOLOv8 model backbone network; The loss function for training the self-supervised training model is represented as: wherein, represents the contrastive loss, and represents the representation vectors obtained by the feature extraction and projection head for two different augmented views of the same image, represents the representation vectors obtained by the feature extraction and projection head for different images, represents the control of the discrimination between positive and negative samples in the contrastive learning, k is an index variable for traversing all sample pairs, and N represents the number of samples in each batch. 5.The deep learning-based lithium battery surface defect intelligent detection method according to claim 1, characterized in that, In the 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, which are connected in sequence; The Neck network includes a fourth custom sampling rate feature fusion module, a second dynamic sampling layer, a third connection layer, a third custom sampling rate feature fusion module, a second dynamic sampling layer, a second connection layer, a second custom sampling rate feature fusion module, a first dynamic sampling layer, a first connection layer, a first custom sampling rate feature fusion module, 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 fifth custom sampling rate feature fusion module, 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 sixth custom sampling rate feature fusion module, a third efficient multi-scale attention module, which are connected in sequence; The input end of the first connection layer is further connected with a first activation function, the input end of the second connection layer is further connected with the output end of the second cross-stage local feature fusion module, the input end of the third connection layer is further connected with the output end of the third cross-stage local feature fusion module, and the input end of the fourth self-defined sampling rate feature fusion module is further connected with the output end of the fast spatial pyramid pooling layer; The Head network comprises a first detection head, a second detection head and a third detection head; the input end of the first detection head is connected with the output end of the first efficient multi-scale attention module, the input end of the second detection head is connected with the output end of the second efficient multi-scale attention module, and the input end of the third detection head is connected with the output end of the third efficient multi-scale attention module. 6.The deep learning-based lithium battery surface defect intelligent detection method according to claim 5, characterized in that, The processing process of the first to fourth cross-stage local feature fusion modules on the input feature map is as follows: S41, grouping the input feature map along the x-axis pooling branch, the y-axis pooling branch and the convolution layer branch respectively; S42, bidirectional feature fusion is performed on the feature maps of different sources, and a learning weight coefficient is introduced in the fusion process to adaptively weight the features of different sources to obtain fused features; S43, after the fused features pass through a connection convolution layer, multi-scale feature representation is output through s-type activation function and reweighting processing; The adaptive weighting formula is as follows: In the formula, denotes the feature map after adaptive weighting, denotes the feature map of different sources, denotes corresponding weight coefficients, denotes a small constant calculated stably. 7.The deep learning-based lithium battery surface defect intelligent detection method according to claim 5, characterized in that, The up-sampling process of the first to second dynamic up-sampling layers on the input feature map is as follows: wherein, denotes the up-sampled feature map, denotes the low-resolution feature map, i.e. the input feature map, denotes a parametric dynamic up-sampling operation, denotes an edge enhancement function, denotes up-sampling parameters generated adaptively from the low-resolution feature map, denotes a balancing coefficient. 8.The deep learning-based lithium battery surface defect intelligent detection method according to claim 5, characterized in that, The process of the first to third efficient multi-scale attention modules on the input feature map for spatial-channel double attention enhancement is as follows: wherein, denotes attention score, denotes Sigmoid activation function, denotes convolution, denotes concatenation operation, denotes pooling along x-axis, denotes pooling along y-axis, denotes depthwise separable convolution, denotes capturing global context information, denotes input feature map, denotes loss coefficient, denotes matrix multiplication.

Citation Information

Patent Citations

  • Lithium battery surface defect detection method based on deep learning multi-channel fusion

    CN119478486A