Battery surface defect detection method based on DEIM algorithm
Through the battery surface defect detection method based on DEIM algorithm, edge features are extracted and deep and shallow layer features are fused, which solves the problem of poor detection effect in surface defect detection of cylindrical lithium batteries, and achieves higher detection accuracy and speed.
Patent Information
- Application Number
- CN202510633509.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-05
AI Technical Summary
The existing DEIM algorithms are poor in detecting surface defects of cylindrical lithium batteries, especially extrusion and depression defects, mainly due to the lack of edge feature fusion and semantic differences in depth and shallow layer feature maps, resulting in insufficient detection accuracy.
The battery surface defect detection method based on DEIM algorithm is adopted. By constructing the battery surface defect data set, the edge features of the shallow network are extracted using wavelet convolution, and fused with the deep feature map to filter local feature noise, alleviate semantic differences, and build backbone networks, encoding networks and decoding networks to improve detection accuracy.
It effectively improves the accuracy and speed of surface defect detection of cylindrical lithium batteries, solves the problem of poor detection results in the existing technology, and provides stronger defect detection capabilities.
Smart Images

Figure CN120431079A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of defect identification, and in particular relates to a battery surface defect detection method based on a DEIM algorithm. Background Art
[0002] Green and low-carbon are the environmental protection themes of our time, and we will achieve carbon peak and carbon neutrality. Since its advent in the 1990s, lithium batteries have occupied a large market share in energy consumption due to their high energy density, high specific capacity, no memory effect, low self-discharge rate, and long life. Among them, cylindrical lithium batteries are widely used in many fields such as instrumentation, transportation, and medical equipment. However, surface defects are inevitable in the production, use, and transportation of lithium batteries. Such defects will directly affect the life, performance, and stability of the battery, and thus lead to safety issues such as fire and explosion. Therefore, whether an effective industrial surface defect detection method can be found to ensure efficient and low-risk production of lithium batteries has become a difficult problem that needs to be solved urgently in the new energy industry.
[0003] Currently, industrial defect detection relies primarily on manual visual inspection. Manual inspection, in order to avoid high rates of missed detection and false positives, requires significant manpower and time, making it unable to meet the practical production needs of modern industries. With the continuous improvement of hardware computing power and the continuous innovation of algorithm models, the introduction of deep learning has greatly improved defect detection accuracy and reduced the cost of designing defect detection systems. In the field of supervised object detection, there are two main types of algorithms: one-stage object detection algorithms and two-stage object detection algorithms. Both algorithms train network models by learning from a large number of labeled defect samples to identify defect categories. One-stage algorithms are faster and more accurate than two-stage algorithms, meeting the speed and accuracy requirements for defect detection in actual production.
[0004] Most defects in defect detection are unique parts of a component's surface. The sudden change in pixel values at the boundary between the defective and normal areas is called an edge feature, which is a very important type of defect feature. DEIM is an efficient end-to-end, one-stage object detection network. However, DEIM's detection performance is poor for defects such as extrusion and dents found in battery defect datasets. This is because DEIM's feature fusion network does not incorporate sufficient edge features, and the fused deep and shallow feature maps exhibit semantic differences. Summary of the Invention
[0005] In order to solve the above technical problems, the present invention proposes a battery surface defect detection method based on the DEIM algorithm to solve the problems existing in the above-mentioned prior art.
[0006] To achieve the above objectives, the present invention provides a battery surface defect detection method based on the DEIM algorithm, comprising:
[0007] Based on the surface images of cylindrical lithium batteries, a battery surface defect dataset was constructed;
[0008] Constructing a battery surface defect detection network based on the DEIM algorithm, and training the battery surface defect detection network based on the battery surface defect dataset to obtain a trained battery surface defect detection network;
[0009] The battery image to be detected is input into the trained battery surface defect detection network to obtain the battery surface defect detection result.
[0010] Optionally, the process of constructing a battery surface defect dataset includes:
[0011] Perform data enhancement on the surface images of cylindrical lithium batteries to obtain an enhanced dataset;
[0012] The enhanced dataset was annotated using Labelimg software and divided into training set, validation set and test set to obtain the battery surface defect dataset.
[0013] Optionally, the battery surface defect detection network includes: a backbone network, an encoding network, and a decoding network;
[0014] The process of training the battery surface defect detection network based on the battery surface defect dataset includes:
[0015] Crop the images in the battery surface defect dataset to a uniform size to obtain an input image;
[0016] Input the input image into the backbone network for feature extraction to obtain feature maps P2, P3, and P4;
[0017] The encoding network is used to process the feature map P4 to obtain the relevant feature C4;
[0018] Based on the feature maps P2, P3 and the related feature C4, the fused feature maps M1, F2, and F3 are obtained;
[0019] The decoding network is used to process the fused feature maps M1, F2, and F3 to obtain classification results and prediction boxes.
[0020] Optionally, the process of inputting the input image into the backbone network for feature extraction to obtain feature maps P2, P3, and P4 includes:
[0021] The input image is input into the backbone network, and 4 times down-sampled through the Stem structure to generate a 64-channel feature map;
[0022] The 64-channel feature map passes through 4 LDS layers and 4 HG blocks to obtain the output feature maps P2, P3, and P4 of the last three HG blocks.
[0023] Optionally, the encoding network includes: a multi-head self-attention layer and a WTFPN network; the WTFPN network includes bottom-up and up-bottom;
[0024] The process of obtaining the fused feature maps M1, F2, and F3 based on the feature maps P2, P3 and the related feature C4 includes:
[0025] Input the feature maps P2, P3 and the related feature C4 into bottom-up, and obtain the edge feature T3 in P3 based on wavelet convolution;
[0026] The edge feature T3 is concatenated with the upsampled correlation feature C4, and M3 is obtained through CSP.
[0027] The feature map P2 is convolved with wavelet to obtain T2;
[0028] The T2, P3 and upsampled M3 are concatenated and fused, and M2 is obtained through CSP;
[0029] The upsampled M2 is concatenated with P2 and M1 is obtained through CSP.
[0030] Input M1, M2, and M3 into the up-bottom, concatenate and fuse M1 and M2 after wavelet convolution, and obtain F2 through CSP;
[0031] The wavelet convolved F2, wavelet convolved M2 and M3 are concatenated and fused, and F3 is obtained through CSP.
[0032] Optionally, the process of obtaining the edge feature T3 in P3 based on wavelet transform includes:
[0033] Perform an average pooling operation on P3, and input the average pooled P3 into the first branch and the second branch respectively; wherein the second branch also includes a first sub-branch and a second sub-branch;
[0034] The first branch filters the local characteristic noise of P3 to obtain a first feature;
[0035] The P3 is subjected to wavelet convolution by the first sub-branch of the second branch to obtain feature maps of four scales;
[0036] The P3 is gated convolved through the second sub-branch of the second branch to obtain weights of four feature maps;
[0037] Multiplying the feature maps of the four scales by the weights of the four feature maps to obtain a second feature;
[0038] The first feature and the second feature are added together to obtain T3.
[0039] Optionally, the calculation expression of the edge feature T3 is:
[0040] T3=Conv(W,X C )+X L
[0041] In the formula, T3 represents the edge feature, X L represents the first feature, X C Represents the second feature, and W represents the convolution kernel weight.
[0042] Optionally, the decoding network includes: a decoding layer and a D-Fine detection head.
[0043] Compared with the prior art, the present invention has the following advantages and technical effects:
[0044] Based on the end-to-end, one-stage object detection algorithm DEIM, this paper constructs a surface defect detection network for cylindrical lithium batteries. This network effectively extracts edge features from shallow layers through wavelet convolution and integrates them into deep feature maps. It also filters out noise from certain local features, alleviating the problem of local feature degradation caused by semantic differences. Ultimately, this improves the network's defect detection capabilities and provides a technical reference for battery surface defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:
[0046] Figure 1 Flowchart of a method for detecting surface defects of cylindrical lithium batteries based on the DEIM algorithm according to an embodiment of the present invention;
[0047] Figure 2 This is a structural diagram of a cylindrical lithium battery surface defect detection method based on the DEIM algorithm according to an embodiment of the present invention;
[0048] Figure 3 A structural diagram of the WTFPN provided in an embodiment of the present invention;
[0049] Figure 4 A structural diagram of wavelet convolution provided by an embodiment of the present invention;
[0050] Figure 5 This is a diagram showing the defect detection effect involved in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0052] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0053] Example 1
[0054] like Figure 1 As shown, this embodiment provides a battery surface defect detection method based on the DEIM algorithm, including the following steps: constructing a battery surface defect dataset based on cylindrical lithium battery surface images; constructing a battery surface defect detection network based on the DEIM algorithm, and training the battery surface defect detection network based on the battery surface defect dataset to obtain a trained battery surface defect detection network; inputting the battery image to be detected into the trained battery surface defect detection network to obtain a battery surface defect detection result. The specific implementation process is as follows:
[0055] S1. Collect surface images of cylindrical lithium batteries and construct a battery surface defect dataset;
[0056] S2. Build a battery surface defect detection network based on the DEIM algorithm; it consists of three main components: a backbone network, an encoding network, and a decoding network. The backbone network, also known as the feature extraction network, consists of the HGNetV2 network and is responsible for extracting defect features. The encoding network consists of a multi-head self-attention layer and a WTFPN network, which is an improvement on the original PAFPN network. Using a designed wavelet convolution, it first downsamples the shallow feature map, extracts edge features, retains local features, and then fuses them with the deep feature map. This effectively introduces edge features while mitigating semantic differences. The decoding network, consisting of a decoding layer and a D-Fine detection head, outputs the classification results and prediction boxes.
[0057] The process of training the battery surface defect detection network based on the battery surface defect dataset includes: cropping the images in the battery surface defect dataset to a uniform size to obtain the input image; inputting the input image into the backbone network for feature extraction to obtain feature maps P2, P3, and P4; using the encoding network to process the feature map P4 to obtain the relevant feature C4; based on the feature maps P2, P3 and the relevant feature C4, the fused feature maps M1, F2, and F3 are obtained; using the decoding network to process the fused feature maps M1, F2, and F3 to obtain the classification results and prediction boxes.
[0058] Based on the feature maps P2, P3 and related features C4, the process of obtaining the fused feature maps M1, F2 and F3 includes: inputting the feature maps P2, P3 and related features C4 into bottom-up, and obtaining the edge feature T3 in P3 based on wavelet convolution; splicing and fusing the edge feature T3 with the upsampled related feature C4, and obtaining M3 through CSP; convolving the feature map P2 with wavelet to obtain T2; splicing and fusing T2, P3 and the upsampled M3, and obtaining M2 through CSP; splicing and fusing the upsampled M2 with P2, and obtaining M1 through CSP; inputting M1, M2 and M3 into up-bottom, splicing and fusing the wavelet-convolved M1 with M2, and obtaining F2 through CSP; splicing and fusing the wavelet-convolved F2, the wavelet-convolved M2 and M3, and obtaining F3 through CSP.
[0059] S3. Use the dataset to train a battery surface defect detection network based on the DEIM algorithm;
[0060] S4. Input the battery image to be inspected into the network obtained in S3 to detect the type and location of the defect.
[0061] Step S1 includes the following: collecting images of surface defects of cylindrical lithium batteries; performing data enhancement operations on the collected data set to obtain an enhanced data set, including cropping, mirroring, rotation, translation, adding noise, and adjusting brightness; annotating the enhanced data set using Labelimg software, and dividing the data set into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0062] The battery surface defect detection network in step S2 is based on the DEIM algorithm, such as Figure 2 As shown, it includes backbone network, encoding network and decoding network.
[0063] First, the input image is uniformly cropped to 640*640*3 dimensions and then fed into the backbone network HGNetV2. In HGNetV2, the image first passes through the Stem structure, where it undergoes 4x downsampling to generate a 64-channel feature map. The image then passes through four LDS layers and four HG blocks. The LDS layer is a 1x downsampling layer, and the HG block can hierarchically extract different features from the feature map. Finally, the feature extraction network saves the output feature maps P2, P3, and P4 of the last three HG blocks, and then resizes the feature channels through 1x1 convolution. The resized dimensions are 80*80*128, 40*40*128, and 20*20*128, respectively.
[0064] The encoding network consists of a multi-head self-attention layer and a WTFPN. Because P4 has the strongest local features and the lowest resolution, inputting P4 into the multi-head self-attention layer can obtain the correlation feature C4 between features with minimal computational cost. The PAFPN in the original DEIM directly fuses shallow and deep feature maps, which not only fails to obtain sufficient edge features but also causes local feature degradation due to semantic differences. The WTFPN uses wavelet convolution to extract shallow edge features, filters some of the shallow noise, and then fuses them with the deep feature map. This allows the deep feature map to obtain edge features while avoiding the degradation of local features.
[0065] like Figure 3 As shown in Figure 2, the WTFPN network is divided into two parts: bottom-up and up-bottom. The input of bottom-up is P2, P3, and C4. First, the edge features in P3 are obtained by wavelet transform, as shown in Figure 2. Figure 4 As shown in the wavelet convolution, P3 is first average pooled to integrate redundant features, and then P3 is used as the input of the two branches. The first branch filters the local feature noise through two-dimensional convolution (Conv2d), regularization (BN), and activation function (SiLU) to obtain X L , that is, the first feature, this part is calculated as shown in the following formula:
[0066] X=AvgPool(P3) (1)
[0067] X L =Conv(W,X) (2)
[0068] Among them, Conv is to execute Conv2d, BN, SiLU in sequence, and W is the convolution kernel weight of Conv2d. L This can alleviate semantic differences for subsequent fusion. A portion of the second branch, the first sub-branch, obtains a large number of edge features through wavelet transform. The present invention uses Haar wavelet transform because it is simple and efficient. To implement a two-dimensional wavelet transform on an image, the present invention designs four filters in the width and height dimensions, as shown in the following equations:
[0069]
[0070] Among them, f LL is a low-pass filter, f LH ,f HL ,f HH The present invention then uses these four filters as weights for group convolution, and performs low-pass filtering and high-pass filtering on the feature map of each channel to obtain feature maps of four scales, as shown in the following formula:
[0071] [X LL,X LH ,X HL ,X HH ]=Conv([f LL ,f LH ,f HL ,f HH ],X) (4)
[0072] The feature map at each scale is half the resolution of the original feature map X. LL is the low-frequency component of X, X LH 、X HL 、X HH are the horizontal, vertical, and diagonal high-frequency components of X.
[0073] The other part of the second branch, the second sub-branch, is the gated convolution. The input of the gated convolution is the original feature map X. The purpose is to obtain a weight tensor through maximum pooling, 1×1 convolution and sigmoid activation function. The local features represent that the pixels at these points have a higher weight. Then the weight generated by each channel feature map is multiplied by the corresponding four scale feature maps to obtain X. C , i.e. the second feature, strengthens the edge features of the target area and reduces the edge features of the background area. This part of the calculation can be expressed as follows:
[0074] X C =[X LL ,X LH ,X HL ,X HH ]×Conv(W,MaxPool(X)) (5)
[0075] Then the filtered edge features X are processed by group convolution C The two branches are then combined to obtain T3. The purpose of gated convolution is to obtain edge features around the location of the detection target, and then the features obtained by multiplying the two parts are integrated through grouped convolution. Finally, the two branches are added to obtain T3, where W represents the convolution kernel weight. The calculation of this part is as follows:
[0076] T3=Conv(W,X C )+X L (6)
[0077] Next, T3 is concatenated with the upsampled C4 and fused through CSP to obtain M3. T2, obtained by wavelet convolution of P2, is then concatenated with P3 and the upsampled M3, and again fused through CSP to obtain M2. The upsampled M2 is then concatenated with P2 and fused through CSP to obtain M1. The up-bottom inputs are M1, M2, and M3, and the above operation is repeated to obtain the final outputs M1, F2, and F3. The calculation for this part is as follows:
[0078]
[0079] Among them, CSP is a feature integration module. It is a splicing operation, and AWTDown is a wavelet convolution.
[0080] The decoding network consists of a decoding layer and a D-Fine detection head. The input is M1, F2, and F3, and the output is the classification result and the prediction box. Figure 5 , which is a diagram showing the defect detection effect involved in an embodiment of the present invention.
[0081] In step S3, the battery defect detection network based on the DEIM algorithm is trained using the training set and validation set from the battery defect dataset for a total of 200 rounds. After the training is completed, the weight of the network with the highest validation set accuracy is used for testing.
[0082] In step S4 of the embodiment of the present invention, the optimal network weight obtained in S3 is used to detect battery images in the test set in the data set to test the actual performance of the network.
[0083] In summary, this paper proposes a surface defect detection method for cylindrical lithium batteries based on the DEIM algorithm. This method uses wavelet transforms to collect edge features from shallow feature maps, enhancing the network's defect detection capabilities. Furthermore, it employs local feature filtering, gated convolution, and downsampling followed by concatenation to address semantic discrepancies, minimizing the problem of local feature degradation.
[0084] The above are merely preferred embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A battery surface defect detection method based on DEIM algorithm, characterized in that: The following steps are involved: Based on the surface images of cylindrical lithium batteries, a battery surface defect dataset was constructed; Constructing a battery surface defect detection network based on the DEIM algorithm, and training the battery surface defect detection network based on the battery surface defect dataset to obtain a trained battery surface defect detection network; The battery image to be detected is input into the trained battery surface defect detection network to obtain the battery surface defect detection result.
2. The battery surface defect detection method based on the DEIM algorithm according to claim 1, characterized in that: The process of building a battery surface defect dataset includes: Perform data enhancement on the surface images of cylindrical lithium batteries to obtain an enhanced dataset; The enhanced dataset was annotated using Labelimg software and divided into training set, validation set and test set to obtain the battery surface defect dataset.
3. The battery surface defect detection method based on the DEIM algorithm according to claim 1, characterized in that: The battery surface defect detection network includes: a backbone network, an encoding network, and a decoding network; The process of training the battery surface defect detection network based on the battery surface defect dataset includes: Crop the images in the battery surface defect dataset to a uniform size to obtain an input image; Input the input image into the backbone network for feature extraction to obtain feature maps P2, P3, and P4; The encoding network is used to process the feature map P4 to obtain the relevant feature C4; Based on the feature maps P2, P3 and the related feature C4, the fused feature maps M1, F2, and F3 are obtained; The decoding network is used to process the fused feature maps M1, F2, and F3 to obtain classification results and prediction boxes.
4. The battery surface defect detection method based on the DEIM algorithm according to claim 3, characterized in that: The process of inputting the input image into the backbone network for feature extraction to obtain feature maps P2, P3, and P4 includes: The input image is input into the backbone network, and 4 times down-sampled through the Stem structure to generate a 64-channel feature map; The 64-channel feature map passes through 4 LDS layers and 4 HG blocks to obtain the output feature maps P2, P3, and P4 of the last three HG blocks.
5. The battery surface defect detection method based on the DEIM algorithm according to claim 4, characterized in that: The encoding network includes: a multi-head self-attention layer and a WTFPN network; the WTFPN network includes bottom-up and up-bottom; The process of obtaining the fused feature maps M1, F2, and F3 based on the feature maps P2, P3 and the related feature C4 includes: Input the feature maps P2, P3 and the related feature C4 into bottom-up, and obtain the edge feature T3 in P3 based on wavelet convolution; The edge feature T3 is concatenated with the upsampled correlation feature C4, and M3 is obtained through CSP. The feature map P2 is convolved with wavelet to obtain T2; The T2, P3 and upsampled M3 are concatenated and fused, and M2 is obtained through CSP; The upsampled M2 is concatenated with P2 and M1 is obtained through CSP. Input M1, M2, and M3 into the up-bottom, concatenate and fuse M1 and M2 after wavelet convolution, and obtain F2 through CSP; The wavelet convolved F2, wavelet convolved M2 and M3 are concatenated and fused, and F3 is obtained through CSP.
6. The battery surface defect detection method based on DEIM algorithm according to claim 5, characterized in that: The process of obtaining the edge feature T3 in P3 based on wavelet transform includes: Perform an average pooling operation on P3, and input the average pooled P3 into the first branch and the second branch respectively; wherein the second branch also includes a first sub-branch and a second sub-branch; The first branch filters the local characteristic noise of P3 to obtain a first feature; The P3 is subjected to wavelet convolution by the first sub-branch of the second branch to obtain feature maps of four scales; The P3 is gated convolved through the second sub-branch of the second branch to obtain weights of four feature maps; Multiplying the feature maps of the four scales by the weights of the four feature maps to obtain a second feature; The first feature and the second feature are added together to obtain T3.
7. The battery surface defect detection method based on DEIM algorithm according to claim 6, characterized in that: The calculation expression of edge feature T3 is: T3=Conv(W,X C )+X L In the formula, T3 represents the edge feature, X L represents the first feature, X C Represents the second feature, and W represents the convolution kernel weight.
8. The battery surface defect detection method based on DEIM algorithm according to claim 7, characterized in that: The decoding network includes: a decoding layer and a D-Fine detection head.