Complex multi-scale adaptive battery shell defect detection method
By designing the RepDSC_ASKA module, AMF module and improved LMFLoss loss function in dry battery surface defect detection, the problem of insufficient detection accuracy and robustness in the prior art is solved, and a more efficient and accurate defect detection effect is achieved.
Patent Information
- Application Number
- CN202510455139.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-04-11
AI Technical Summary
The prior art lacks accuracy and robustness in dry battery surface defect detection, which is difficult to meet the modern industry's demand for efficient and accurate defect detection.
The complex multi-scale adaptive battery case defect detection method is adopted, and the model's detection ability to detect complex multi-scale defects and adaptability to complex backgrounds is improved by designing RepDSC_ASKA module, AMF module and improved LMFLoss loss function.
It significantly improves detection accuracy and robustness, and is better than the existing YOLO series models, especially in complex background and multi-scale defect detection tasks, enhancing the applicability and performance of the model.
Smart Images

Figure CN119963564A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of battery surface defect detection, and in particular relates to a complex multi-scale adaptive battery shell defect detection method. Background Art
[0002] In the industrial manufacturing process, dry cell batteries are key components widely used in consumer electronics, medical equipment and new energy fields, and their surface quality directly affects the performance and safety of the products. However, due to the limitations of production processes, equipment precision and working environment, dry cell batteries will inevitably produce a series of surface defects such as pitting, scratches and dents during the production process. These defects will not only reduce the electrical performance and service life of the battery, but may also cause serious problems such as electrolyte leakage, short circuit and even explosion, posing a potential threat to user safety and equipment operation. Therefore, efficient and accurate detection of dry cell surface defects is crucial to ensure product quality and safety.
[0003] At present, many companies still rely on traditional manual visual inspection methods. However, this method has problems such as low efficiency, high cost, susceptibility to personnel fatigue and subjective judgment, and it is difficult to meet the needs of modern industry for efficient and precise production. In addition, the surface defects of dry cells are complex and diverse, and have low distinction from the background. Traditional rule-based detection methods often show obvious limitations when dealing with defects of different sizes, shapes and complex backgrounds. In recent years, with the rapid development of deep learning technology, object detection algorithms based on convolutional neural networks (CNNs) have achieved remarkable results in industrial surface defect detection tasks. For example, the YOLO series of algorithms have been widely used in the field of industrial inspection due to their high efficiency and real-time performance.
[0004] As a new member of the YOLO series, YOLOv9 inherits the advantages of previous models, improves the accuracy and real-time performance of target detection by improving the network structure and optimizing the algorithm process, and has achieved remarkable results in general target detection tasks. However, when YOLOv9 is directly applied to the task of dry cell surface defect detection, it still faces some special challenges, such as defect morphology diversity, background complexity, and category imbalance. Therefore, it is necessary to further optimize and adjust the existing target detection methods to meet the needs of dry cell surface defect detection and improve its applicability and performance in industrial production scenarios. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a complex multi-scale adaptive battery casing defect detection method that solves the problem that traditional detection methods are insufficient in accuracy and robustness and are difficult to meet the needs of modern industry for efficient and accurate defect detection.
[0006] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: a complex multi-scale adaptive battery shell defect detection method, comprising the following steps:
[0007] S1. Obtain a data set of surface defects of dry cell batteries;
[0008] S2, inputting the dry cell surface defect data set into the backbone network to obtain the first to third defect features;
[0009] S3, inputting the first to third defect features into the bottleneck layer to obtain the first to sixth detection features;
[0010] S4. Input the first to sixth detection features into the decoding prediction end to obtain the battery shell defect detection result.
[0011] Further: In S1, the dry cell surface defect data set divides the dry cell surface defects into: crushing, scratches, pits, U-shaped, mouth wrinkles and mouth cracks.
[0012] The beneficial effects of the above further scheme are: the self-made dry cell surface defect dataset Battery-Defects is used for experimental verification, and the public steel plate surface defect dataset GC10-DET with similar morphology to dry cell defects is used for cross-domain performance evaluation to further verify the generalization ability of the proposed method.
[0013] Further: in S2, the backbone network includes a first convolution module, a second convolution module, an ELAN1 module, a first Aconv module, a first RepDSC_ASKA module, a second Aconv module, a second RepDSC_ASKA module, a third Aconv module and a third RepDSC_ASKA module connected in sequence;
[0014] The dry cell surface defect dataset is input into the backbone network, and the first to third defect features are output through the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module respectively.
[0015] The beneficial effects of the above further scheme are as follows: in the backbone network part, a RepDSC_ASKA module is designed for feature extraction, and the model's detection ability for fine local structures and complex global morphology is enhanced through an adaptive multi-scale feature extraction mechanism.
[0016] Further: the structures of the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module are the same, and the specific working process of the structure is:
[0017] S21. Perform a convolution operation on the input feature map of the structure and divide the generated result into components along the channel dimension. and ;
[0018] S22, will Enter the RepNCSP module through two Convolution gets the components and , the amount Pass it to the bottleneck layer for feature extraction to obtain components , and then the amount and Connect in the channel dimension and convolve the connected components to obtain components ;
[0019] S23, the amount Input DSC_ASKA module for feature extraction and obtain components ;
[0020] S24, the amount Input the RepNCSP module and the DSC_ASKA module in turn to obtain the components ;
[0021] S25, the amount , , and After connection, a Conv operation is performed to obtain the output feature map of the structure.
[0022] Furthermore: the DSC_ASKA module adjusts the convolution kernel through a learnable offset parameter, which is specifically:
[0023] Expand the convolution kernel K on the grid, starting from the center grid position to the grid position far away from the center, and increase the offset of each grid position by a random number. , ;
[0024] The DSC_ASKA module includes a ConvM submodule, a first DSConv submodule, a second DSConv submodule, an ASKA submodule, and a feature fusion submodule connected in sequence, the input of the ConvM submodule is also input into the first DSConv submodule and the second DSConv submodule, and the output of the ConvM submodule and the first DSConv submodule is also input into the ASKA submodule;
[0025] The specific workflow of the ASKA submodule is as follows:
[0026] A1. Obtain the input feature map of the ASKA submodule, extract features through several convolution branches of different sizes, and obtain a fused feature map;
[0027] A2. Perform global average pooling on the fused feature map to generate a global descriptor;
[0028] A3. Input the global descriptor into two fully connected layers in sequence to generate the weights of each convolution branch;
[0029] A4. Perform weighted summation on the outputs of each convolution branch according to the weights to obtain the output feature map of the ASKA submodule.
[0030] Further: in S3, the bottleneck layer includes a first AMF module, a second AMF module, a fourth RepDSC_ASKA module, a fifth RepDSC_ASKA module, a sixth RepDSC_ASKA module, a seventh RepDSC_ASKA module, an eighth RepDSC_ASKA module, a ninth RepDSC_ASKA module, a fourth Aconv module and a fifth Aconv module;
[0031] The first AMF module, the fourth RepDSC_ASKA module, the fifth RepDSC_ASKA module, the fourth Aconv module, the sixth RepDSC_ASKA module, the fifth Aconv module and the seventh RepDSC_ASKA module are connected in sequence;
[0032] The second AMF module, the eighth RepDSC_ASKA module and the ninth RepDSC_ASKA module are connected in sequence.
[0033] The beneficial effects of the above further scheme are as follows: in the bottleneck layer, an AMF module is introduced to improve the adaptability of the model to complex backgrounds and multi-scale defects through multi-level feature fusion.
[0034] Further: S3 is specifically:
[0035] The third defect feature is input into the first AMF module, the feature output by the first AMF module is upsampled and then fused with the second defect feature, the fused feature is input into the fourth RepDSC_ASKA module, the feature output by the fourth RepDSC_ASKA module is upsampled and then fused with the first defect feature, the fused feature is input into the fifth RepDSC_ASKA module to obtain the first detection feature, the first detection feature is input into the fourth Aconv module, the feature output by the fourth Aconv module is fused with the feature output by the fourth RepDSC_ASKA module, the fused feature is input into the sixth RepDSC_ASKA module to obtain the second detection feature, the second detection feature is input into the fifth Aconv module, the feature output by the fifth Aconv module is fused, the fused feature is input into the seventh RepDSC_ASKA module to obtain the third detection feature;
[0036] The third defect feature is input into the second AMF module to obtain the sixth detection feature. The sixth detection feature is upsampled and fused with the second defect feature. The fused feature is input into the eighth RepDSC_ASKA module to obtain the fifth detection feature. The fifth detection feature is upsampled and fused with the first defect feature. The fused feature is input into the ninth RepDSC_ASKA module to obtain the fourth detection feature.
[0037] Further: The structure of the first AMF module and the second AMF module is the same, and the specific working process of the structure is:
[0038] B1. Input the input feature map of the structure into three parallel branches and one global branch respectively, fuse the output features of all branches, and input the fused features into the channel attention mechanism LSE module;
[0039] Three parallel branches are set up , and The convolution kernel of
[0040] B2. The channel attention mechanism LSE module outputs the attention weight of each channel in the input feature map, multiplies the attention weight of each channel with the input feature map channel by channel, and obtains the weighted feature map;
[0041] B3. Input the weighted feature map into the first Convolutional layer, obtain the output feature map of the structure.
[0042] Further: In B2, the workflow of the channel attention mechanism LSE module is as follows:
[0043] The feature map input by the channel attention mechanism LSE module is sequentially input into the global average pooling layer, the second Convolutional layer, ReLU activation function layer, third The convolution layer and the Sigmoid activation function layer generate channel weights, which are element-wise multiplied with the feature map input by the channel attention mechanism LSE module to obtain the attention weight of each channel.
[0044] Further: S4 is specifically:
[0045] The first to sixth detection features are input into the decoding prediction end, and based on the preset Ciou loss function and LMFLoss loss function, a defect prediction result of each detection feature is generated to obtain a battery shell defect detection result;
[0046] LMFLoss loss function The specific expression is:
[0047]
[0048] In the formula, is the first hyperparameter, is the second hyperparameter, is the LDAM loss, It is Focal Loss, and its specific expression is:
[0049]
[0050]
[0051] In the formula, For battery shell defect detection category The predicted probability of is the adjustment factor, x is the sample, y is the label corresponding to x, It is a model composed of a backbone network, a bottleneck layer, and a prediction end. is the output of the model, is the index value after margin adjustment, where is the margin parameter, For a specific category, is the number of categories.
[0052] The beneficial effects of the above further scheme are: to address the problem of imbalanced data set categories, an improved LMFLoss loss function is proposed to effectively improve the model's learning ability for rare category defects.
[0053] The beneficial effects of the present invention are:
[0054] (1) This paper proposes a complex multi-scale adaptive battery shell defect detection method based on improved YOLOv9s for the dry cell surface defect detection task. By designing the RepDSC_ASKA module, AMF module and improved LMFLoss loss function, the model's detection capability for complex multi-scale defects, adaptability to complex backgrounds and learning ability for rare category defects are effectively improved. Experimental results show that the proposed method has achieved detection accuracy and robustness superior to existing methods on both the self-made Battery-Defects dataset and the public GC10-DET dataset, verifying its effectiveness and generalization ability in specific tasks and cross-domain scenarios. Experimental results show that the improved method proposed in this paper is superior to existing methods in terms of detection accuracy and robustness, providing an efficient and reliable solution for dry cell surface defect detection.
[0055] (2) In the comparative experiments, the proposed method was comprehensively compared with the existing mainstream target detection models (such as YOLOv5s, YOLOv8s, YOLOv9s, YOLOv10s, YOLOv11s, etc.). The experimental results show that the proposed method is superior to the existing YOLO series models in key indicators such as precision, recall and mAP. In particular, in complex background and multi-scale defect detection tasks, the proposed method shows stronger robustness and higher generalization ability, further proving its application potential in industrial surface defect detection tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 The present invention is a flow chart of a complex multi-scale adaptive battery casing defect detection method.
[0057] Figure 2 This is the improved MSA-YOLO network structure diagram.
[0058] Figure 3 This is the structural diagram of the RepDSC_ASKA module.
[0059] Figure 4 Schematic diagram of dynamic feature extraction of DSC_ASKA module.
[0060] Figure 5 This is a schematic diagram of the DSC_ASKA module structure.
[0061] Figure 6 This is the workflow diagram of the ASKA submodule.
[0062] Figure 7 Figure 2 is a schematic diagram of the structure of the AMF module.
[0063] Figure 8 Distribution plot of the number of defects for each category. DETAILED DESCRIPTION
[0064] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0065] like Figure 1 As shown, in one embodiment of the present invention, a complex multi-scale adaptive battery casing defect detection method comprises the following steps:
[0066] S1. Obtain a data set of surface defects of dry cells;
[0067] S2, inputting the dry cell surface defect data set into the backbone network to obtain the first to third defect features;
[0068] S3, inputting the first to third defect features into the bottleneck layer to obtain the first to sixth detection features;
[0069] S4. Input the first to sixth detection features into the decoding prediction end to obtain the battery shell defect detection result.
[0070] In industrial production, dry cell surface defect detection faces many challenges: various defect types, significant feature differences, complex and irregular shapes, low distinction between defects and backgrounds, and uneven distribution of defect categories. These problems lead to the inadequacy of traditional detection methods in terms of accuracy and robustness, making it difficult to meet the needs of modern industry for efficient and accurate defect detection. In order to solve these problems, the present invention uses the YOLOv9 algorithm as the baseline network, and makes targeted improvements and optimizations to it. Specifically, the present invention redesigns the feature extraction module, feature fusion strategy, and loss function, and proposes a new algorithm framework to improve the accuracy and adaptability of dry cell surface defect detection. The improved network structure is as follows: Figure 2 shown.
[0071] In S1, the dry cell surface defect dataset divides the dry cell surface defects into: crushing, scratches, pits, U-shaped, mouth wrinkles and mouth cracks.
[0072] In S2, the backbone network includes the first convolution module, the second convolution module, the ELAN1 (efficient layer aggregation network) module, the first Aconv (average pooling convolution) module, the first RepDSC_ASKA module, the second Aconv module, the second RepDSC_ASKA module, the third Aconv module, and the third RepDSC_ASKA module, which are connected in sequence;
[0073] The dry cell surface defect dataset is input into the backbone network, and the first to third defect features are output through the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module respectively.
[0074] In the task of battery surface defect detection, there are usually significant differences in the morphology, location and size of the defects, which makes the role of feature extraction operations in model performance particularly critical. Traditional convolutional neural networks (CNNs) usually use fixed-scale convolution kernels for feature extraction. However, when faced with defects with large scale differences or complex shapes, fixed-scale convolutions are prone to lose important key information, resulting in decreased detection performance. To address this problem, the present invention designs a RepDSC_ASKA module to improve the model's sensitivity to complex structures and multi-scale features. The core of this module is to introduce a deformable convolution (DSC_ASKA) module and an adaptive multi-scale receptive field mechanism (Adaptive Spatial Kernel Attention, ASKA) to dynamically optimize the feature extraction strategy, thereby more accurately capturing the local details and global morphology of defects. The structural diagram of the RepDSC_ASKA module is shown in the figure. Figure 3 shown.
[0075] The structures of the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module are the same, and the specific working process of the structure is as follows:
[0076] S21. Perform a convolution operation on the input feature map of the structure and divide the generated result into components along the channel dimension. and ;
[0077] S22, will Enter the RepNCSP module through two Convolution gets the components and , the amount Pass it to the bottleneck layer for feature extraction to obtain components , and then the amount and Connect in the channel dimension and convolve the connected components to obtain components ;
[0078] S23, the amount Input DSC_ASKA module for feature extraction and obtain components ;
[0079] S24, the amount Input the RepNCSP module and the DSC_ASKA module in turn to obtain the components ;
[0080] S25, the amount , , and After connection, a Conv operation is performed to obtain the output feature map of the structure.
[0081] The DSC_ASKA module adjusts the convolution kernel through a learnable offset parameter, which is:
[0082] Expand the convolution kernel K on the grid, starting from the center grid position to the grid position far away from the center, and increase the offset of each grid position by a random number. , ;
[0083] In this embodiment, the DSC_ASKA module introduces a learnable offset parameter to enable the convolution kernel to adaptively adjust its sampling position, thereby better capturing the defect characteristics of irregular shapes, such as Figure 4 As shown, the DSC_ASKA module converts the typical The convolution kernel is expanded.
[0084] The coordinates of the center grid are , is the horizontal coordinate of the center grid, is the ordinate of the center grid, the expansion coefficient is 1, and the convolution kernel is straightened in the x-axis and y-axis directions respectively, thereby realizing deformed convolution. The position of each grid is represented as , is the horizontal coordinate of the grid, is the vertical coordinate of the grid, where c ={0,1,2,3,4} represents the distance from the horizontal or vertical position to the center of the convolution kernel. , Indicates the offset of each selected grid position, which is a cumulative process. is a decimal, and the coordinates are usually in integer form, so bilinear interpolation is used, expressed as:
[0085]
[0086] Among them, K is the decimal place, To enumerate all integer spatial positions, B is a bilinear interpolation kernel, which can be decomposed into two one-dimensional kernels. That is:
[0087]
[0088] In the formula, is the decimal position on the x-axis, is the decimal position on the y-axis, List all integer spatial positions in the x-axis direction, List all integer spatial positions in the y-axis direction;
[0089] From a central location Initially, the position of the grid away from the center depends on the position of the previous grid, compared to , The offset has increased , ensuring that the convolution kernel conforms to the linear morphological structure. Through this cumulative offset mechanism, the convolution kernel can adaptively adjust its sampling position to capture the local details of the defect more accurately.
[0090] like Figure 5 As shown, the DSC_ASKA module includes a ConvM submodule, a first DSConv (dynamic snake convolution) submodule, a second DSConv submodule, an ASKA submodule and a feature fusion submodule connected in sequence, the input of the ConvM submodule is also input into the first DSConv submodule and the second DSConv submodule, and the output of the ConvM submodule and the first DSConv submodule is also input into the ASKA submodule;
[0091] In this embodiment, the DSC_ASKA module integrates an adaptive multi-scale receptive field mechanism. The core idea of the DSC_ASKA module is to extract features through multiple convolution branches of different sizes, dynamically calculate the weight of each branch, and then accurately fuse multi-scale features. The goal of this process is to capture multi-scale information without significantly increasing the amount of calculation.
[0092] like Figure 6 As shown in the figure, the workflow of the ASKA submodule is as follows:
[0093] A1. Obtain the input feature map of the ASKA submodule, extract features through several convolution branches of different sizes, and obtain a fused feature map;
[0094] In this embodiment, the ASKA submodule processes the input feature map through M convolution branches to obtain M feature maps, and adds these feature maps to obtain a fused feature map U, where the convolution kernel of the first convolution branch is 1*1, the second is 3*3, and so on, the mth is (2m-1)*(2m-1);
[0095]
[0096] Where y is the input feature map, The convolution operation of the mth convolution branch on the input feature map y;
[0097] A2, perform global average pooling on the fused feature map to generate a global descriptor S;
[0098]
[0099] In the formula, GAP represents the global average pooling operation, and the obtained S is the average value of each channel;
[0100] A3. Input the global descriptor into two fully connected layers in sequence to generate the weights of each convolution branch;
[0101] Among them, a fully connected layer transformation is performed on the global descriptor S, and an intermediate result Z is output;
[0102]
[0103] In the formula, FC represents the fully connected layer transformation;
[0104] Then, the intermediate result is mapped to the weight of each convolution branch through the second fully connected layer and reshaped into W;
[0105]
[0106] Among them, W represents the weight of each convolution branch. After Softmax normalization, the sum of the weights is guaranteed to be 1.
[0107] A4. Perform weighted summation on the outputs of each convolution branch according to the weights to obtain the output feature map V of the ASKA submodule.
[0108]
[0109] In the formula, is the weight of the mth convolution branch, is the output of the mth convolution branch. With this method, the module can adaptively assign weights to convolution branches of different sizes, thereby accurately fusing multi-scale features without significantly increasing the amount of computation.
[0110] In S3, the bottleneck layer includes the first AMF module, the second AMF module, the fourth RepDSC_ASKA module, the fifth RepDSC_ASKA module, the sixth RepDSC_ASKA module, the seventh RepDSC_ASKA module, the eighth RepDSC_ASKA module, the ninth RepDSC_ASKA module, the fourth Aconv module and the fifth Aconv module;
[0111] The first AMF module, the fourth RepDSC_ASKA module, the fifth RepDSC_ASKA module, the fourth Aconv module, the sixth RepDSC_ASKA module, the fifth Aconv module and the seventh RepDSC_ASKA module are connected in sequence;
[0112] The second AMF module, the eighth RepDSC_ASKA module and the ninth RepDSC_ASKA module are connected in sequence.
[0113] In this embodiment, at the neck of YOLOv9s, the original Spatial Pyramid Pyramid Ensemble with Lightweight Networks (SPPELAN) module enhances the feature representation capability through multi-level maximum pooling, aiming to extract global features of different scales. However, for the surface defect detection task of dry cells, due to the single image background and the low distinction between defects and background, the traditional pooling strategy has obvious limitations in the ability to extract and distinguish multi-level defects under complex backgrounds. To this end, the present invention proposes an innovative AMF module to replace the original SPPELAN module. This module significantly improves the model's sensitivity to detail features and overall detection performance by combining multi-scale feature extraction with a lightweight attention mechanism.
[0114] S3 is specifically:
[0115] The third defect feature is input into the first AMF module, the feature output by the first AMF module is upsampled and then fused with the second defect feature, the fused feature is input into the fourth RepDSC_ASKA module, the feature output by the fourth RepDSC_ASKA module is upsampled and then fused with the first defect feature, the fused feature is input into the fifth RepDSC_ASKA module to obtain the first detection feature, the first detection feature is input into the fourth Aconv module, the feature output by the fourth Aconv module is fused with the feature output by the fourth RepDSC_ASKA module, the fused feature is input into the sixth RepDSC_ASKA module to obtain the second detection feature, the second detection feature is input into the fifth Aconv module, the feature output by the fifth Aconv module is fused, the fused feature is input into the seventh RepDSC_ASKA module to obtain the third detection feature;
[0116] The third defect feature is input into the second AMF module to obtain the sixth detection feature. The sixth detection feature is upsampled and fused with the second defect feature. The fused feature is input into the eighth RepDSC_ASKA module to obtain the fifth detection feature. The fifth detection feature is upsampled and fused with the first defect feature. The fused feature is input into the ninth RepDSC_ASKA module to obtain the fourth detection feature.
[0117] like Figure 7 As shown, the structure of the first AMF module and the second AMF module is the same, and the specific working process of the structure is:
[0118] B1. Input the input feature map of the structure into three parallel branches and one global branch respectively, fuse the output features of all branches, and input the fused features into the channel attention mechanism LSE module;
[0119] Three parallel branches are set up , and The convolution kernel of
[0120] In this embodiment, the AMF module contains three parallel branches, which respectively extract local features of different scales through three different sizes of convolution kernels: 1×1, 3×3 and 5×5. , and , thereby enhancing the diversity of features. Let the input feature map be X, these convolution operations can be expressed as:
[0121]
[0122]
[0123]
[0124] In addition, a global branch is designed to perform single-channel convolution using the global average of the input feature map to supplement the global context information. The multi-scale branch and the global branch together form a comprehensive multi-scale feature representation.
[0125]
[0126] in, represents the value of the cth channel at position (i, j), H and W are the height and width of the feature map respectively. Perform convolution operation to obtain global feature representation ;
[0127]
[0128] Features from different scales , , and global features Splice them together to get the final multi-scale feature representation y;
[0129]
[0130] The splicing operation here is performed along the channel dimension, that is, the number of channels of each feature map is merged.
[0131] B2. The channel attention mechanism LSE module outputs the attention weight of each channel in the input feature map, multiplies the attention weight of each channel with the input feature map channel by channel, and obtains the weighted feature map;
[0132] B3. Input the weighted feature map into the first Convolutional layer, obtain the output feature map of the structure.
[0133] In B2, the workflow of the channel attention mechanism LSE module is as follows:
[0134] The feature map input by the channel attention mechanism LSE module is sequentially input into the global average pooling layer, the second Convolutional layer, ReLU activation function layer, third The convolution layer and the Sigmoid activation function layer generate channel weights, which are element-wise multiplied with the feature map input by the channel attention mechanism LSE module to obtain the attention weight of each channel.
[0135] In this embodiment, in order to further enhance the expression of key features, a lightweight channel attention mechanism LSE (Lightweight Squeeze-and-Excitation) is introduced. First, the input feature map is processed by global average pooling to extract the global statistical features of each channel to obtain a channel-level global feature vector z, that is:
[0136]
[0137] In the formula, is the eigenvalue of the i-th row and j-th column;
[0138] Then, after two layers Convolution performs nonlinear mapping on the global feature vector z. The first layer Convolution increases the number of channels from Down to , get a new vector s; s is activated by the ReLU function to get the intermediate representation ;
[0139]
[0140]
[0141] in, and are the weights and biases of the convolutional layer, , r is a hyperparameter;
[0142] Second floor Convolution restores the intermediate representation to the original number of channels , and get the output vector :
[0143]
[0144] in, is the weight of the convolution layer, is the bias value of the convolution layer.
[0145] Finally, the channel weight is generated through the Sigmoid activation function to obtain the attention weight of each channel , the attention weights are then compared with the input feature map Multiply each channel to get the attention weight of each channel :
[0146]
[0147] In this way, through channel-level weighting, the model can highlight the information of important channels while suppressing unimportant channels, thereby improving the ability to capture key features.
[0148] After the multi-scale features are concatenated in the channel dimension, they are weighted by the channel weights generated by the LSE attention mechanism. The weighted features are then processed through a Convolution is used to reduce the dimension to reduce the computational burden and ensure efficient connection with subsequent network modules. In this way, the AMF module can not only effectively integrate multi-scale features, but also significantly reduce the computational complexity through lightweight design strategies. This module fully considers the diversity of feature expression and the use of global context information, so that the model's ability to capture key features in complex backgrounds can be improved.
[0149] S4 is specifically:
[0150] The first to sixth detection features are input into the decoding prediction end, and based on the preset Ciou loss function and LMFLoss loss function, a defect prediction result of each detection feature is generated to obtain a battery shell defect detection result;
[0151] In the production of dry cell batteries, the daily output is huge, the number of defective products is small, and the defect categories are unevenly distributed, which will lead to poor performance of the model in predicting rare categories. Therefore, the present invention introduces the LMFLoss loss function to solve the problem of category imbalance, so that the model can better learn the characteristics of those rare categories.
[0152] The core idea of LMFLoss is to adjust the loss contribution of each category by marginalizing the category frequency, that is, it assigns a weight to each category, which is inversely proportional to the frequency of the category. In this way, the loss of rare categories will account for a larger proportion of the total loss, prompting the model to pay more attention to these rare categories.
[0153] The Large Margin-aware Focal (LMF) loss is a linear combination of Focal Loss and LDAM, weighted by two hyperparameters.
[0154] LMFLoss loss function The specific expression is:
[0155]
[0156] In the formula, is the first hyperparameter, is the second hyperparameter, is the LDAM loss, It is Focal Loss, and its specific expression is:
[0157]
[0158]
[0159] In the formula, For battery shell defect detection category The predicted probability of is the adjustment factor, x is the sample, y is the label corresponding to x, It is a model composed of a backbone network, a bottleneck layer, and a prediction end. is the output of the model, is the index value after margin adjustment, where is the margin parameter, For a specific category, is the number of categories.
[0160] The present invention also provides the following experimental data to verify the effect of the scheme of the present invention:
[0161] Step 1: Prepare the dataset:
[0162] The experiments of the present invention are mainly carried out on the self-made dry battery surface defect dataset Battery-Defects. Therefore, this section mainly introduces the self-made dataset. In addition, the present invention also uses the public steel plate surface defect dataset GC10-DET, which has defects similar to those of the self-made dataset, to evaluate the proposed method, in order to test its performance more comprehensively and make a fairer comparison. GC10-DET is a surface defect dataset collected in real industry and released by Tianjin University. It contains ten types of surface defects, namely punching (Pu), weld (Wl), crescent gap (Cg), water spot (Water Spot), water spot (Ws), oil spot (Os), silk spot (Ss), inclusion (In), rolling pit (Rp), crease (Cr), waist crease (Wf). The collected defects are all on the surface of the steel plate. The dataset includes 2292 grayscale images with an image size of 2048. The 1000 dataset is arbitrarily divided into training and test sets in a ratio of 7:3.
[0163] The self-made dataset of the present invention divides the surface defects of dry cell batteries into 6 categories: compression marks (CD), scratches (SH), pits (PT), U-shaped (UT), mouth wrinkles (PM), and mouth cracks (CM). The original self-made dry cell dataset Battery-Defects has a total of 1940 images. The number of samples is small and the distribution of various defects shows significant imbalance, such as Figure 8 As shown. In order to overcome this limitation and improve the diversity of the metadata dataset to enhance the generalization performance of the model, the present invention uses image enhancement techniques such as flipping and enhanced contrast images to 3x augment the Battery-Defects dataset. Finally, it is arbitrarily divided in a ratio of 7:3, with 4656 images as the training set and 1164 images as the test set.
[0164] Step 2: Configure the experimental environment:
[0165] The experiment of the present invention is built on the deep learning framework Pytorch, and the relevant tests are carried out using the Ubuntu system. The specific experimental configuration is shown in Table 1.
[0166] Table 1 Experimental environment configuration
[0167]
[0168] The experiment of the present invention is improved and trained based on the YOLOv9s network model, and no pre-trained weights are used in the training process. In order to ensure smooth convergence of the two data sets and fully demonstrate the superiority of the method of the present invention on different data sets, the present invention sets different training rounds for the two data sets while keeping other training hyperparameters consistent. Because the image sizes of the two data sets are different, in the experiment, the present invention sets the BatchSize of the Battery-Defects data set training to 8, and the resolution of the training image is 1280×1280 pixels; the Batch Size of the GC10-DET data set training is set to 16, and the resolution of the training image is 640×640 pixels. Other training hyperparameters are shown in Table 2.
[0169] Table 2 Model training parameters
[0170]
[0171] Step 3: Establish evaluation indicators:
[0172] In order to verify the performance of the model, the present invention uses three evaluation indicators, namely precision, recall and average precision (mAP), as evaluation criteria. These indicators are calculated based on the confusion matrix. As shown in Table 3, TP indicates that the original data is a positive sample and is also a positive sample after the model prediction. FN indicates that the original data is a negative sample and is also a negative sample after the model prediction.
[0173] Table 3 Confusion matrix
[0174]
[0175] Precision (P) is used to measure the accuracy of the detection results, that is, the proportion of the results predicted as positive samples that are actually positive samples. The higher the precision value, the fewer false positive errors, indicating a higher detection accuracy. Recall (R) is used to measure the model's coverage of positive samples, that is, the proportion of actual positive samples that are correctly detected. A higher recall value describes the effectiveness of the model in capturing true instances, which means a higher sensitivity to the target object. The mean average precision (mAP) comprehensively considers the precision and recall of the model for each category at different IOU thresholds, and averages the average accuracy (AP) of all categories (there are C categories) to obtain mAP. A higher mAP value indicates excellent overall performance in the target detection task, with improved precision and recall for all categories.
[0176] Step 4: Get the experimental results:
[0177] In order to verify the effectiveness and superiority of the proposed method, we conducted ablation experiments and comparative experiments on the self-made Battery-Defects dataset and the public GC10-DET dataset. By adding the RepDSC_ASKA module, AMF module and LMFLoss loss function one by one, ablation experiments were performed to evaluate the contribution of each module to the model performance. The experimental results show that the RepDSC_ASKA module significantly enhances the model's ability to extract multi-scale features, can effectively deal with defects of different sizes and shapes, and improves the performance of the model in complex backgrounds; the AMF module further enhances the model's sensitivity to detail features by combining multi-scale feature extraction with a lightweight attention mechanism, significantly improving the detection performance, especially in complex backgrounds. More robust performance; the LMFLoss loss function effectively alleviates the problem of class imbalance, making the model perform well in the detection of rare class defects.
[0178] Finally, the model combining all modules achieved significant improvements in detection accuracy, recall rate and mean average precision (mAP), verifying the effectiveness and synergy of each module. In particular, in the task of dry cell surface defect detection, the proposed method not only surpassed the existing methods in terms of accuracy, but also significantly improved the robustness of the model, enabling it to adapt to the changing industrial background and ensuring efficient and reliable defect detection.
[0179] In the comparative experiments, the proposed method was comprehensively compared with the existing mainstream target detection models (such as YOLOv5s, YOLOv8s, YOLOv9s, YOLOv10s, YOLOv11s, etc.). The experimental results show that the proposed method is superior to the existing YOLO series models in key indicators such as precision, recall and mAP. Especially in complex background and multi-scale defect detection tasks, the proposed method shows stronger robustness and higher generalization ability, further proving its application potential in industrial surface defect detection tasks.
[0180] Verified by ablation experiments and comparative experiments, the method proposed in the present invention has outstanding performance in improving detection accuracy, adapting to complex backgrounds and handling category imbalance problems. It not only enhances the detection capability of surface defects of dry cell batteries, but also provides a more efficient and reliable solution for the field of industrial defect detection.
[0181] In the description of the present invention, it is necessary to understand that the orientation or positional relationship indicated by the terms "center", "thickness", "upper", "lower", "horizontal", "top", "bottom", "inner", "outer", "radial", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", and "third" are used only for descriptive purposes, and cannot be understood as indicating or implying the relative importance or the number of implicitly specified technical features. Therefore, the features defined by "first", "second", and "third" may explicitly or implicitly include one or more of the features.
Claims
1. A complex multi-scale adaptive battery casing defect detection method, characterized in that: The following steps are involved: S1. Obtain a data set of surface defects of dry cell batteries; S2, inputting the dry cell surface defect data set into the backbone network to obtain the first to third defect features; S3, inputting the first to third defect features into the bottleneck layer to obtain the first to sixth detection features; S4. Input the first to sixth detection features into the decoding prediction end to obtain the battery shell defect detection result.
2. The complex multi-scale adaptive battery casing defect detection method according to claim 1 is characterized in that: In S1, the dry cell surface defect dataset divides the dry cell surface defects into: crushing, scratches, pits, U-shaped, mouth wrinkles and mouth cracks.
3. The complex multi-scale adaptive battery casing defect detection method according to claim 1, characterized in that: In S2, the backbone network includes a first convolution module, a second convolution module, an ELAN1 module, a first Aconv module, a first RepDSC_ASKA module, a second Aconv module, a second RepDSC_ASKA module, a third Aconv module, and a third RepDSC_ASKA module, which are connected in sequence; The dry cell surface defect dataset is input into the backbone network, and the first to third defect features are output through the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module respectively.
4. The complex multi-scale adaptive battery casing defect detection method according to claim 3 is characterized in that: The structures of the first RepDSC_ASKA module, the second RepDSC_ASKA module and the third RepDSC_ASKA module are the same, and the specific working process of the structure is as follows: S21. Perform a convolution operation on the input feature map of the structure and divide the generated result into components along the channel dimension. and ; S22, will Enter the RepNCSP module through two Convolution gets the components and , the amount Pass it to the bottleneck layer for feature extraction to obtain components , and then the amount and Connect in the channel dimension and convolve the connected components to obtain components ; S23, the amount Input DSC_ASKA module for feature extraction and obtain components ; S24, the amount Input the RepNCSP module and the DSC_ASKA module in turn to obtain the components ; S25, the amount , , and After connection, a Conv operation is performed to obtain the output feature map of the structure.
5. The complex multi-scale adaptive battery casing defect detection method according to claim 3 is characterized in that: The DSC_ASKA module adjusts the convolution kernel through a learnable offset parameter, which is: Expand the convolution kernel K on the grid, starting from the center grid position to the grid position far away from the center, and increase the offset of each grid position by a random number. , ; The DSC_ASKA module includes a Conv submodule, a first DSConv submodule, a second DSConv submodule, an ASKA submodule, and a feature fusion submodule connected in sequence, the input of the ConvM submodule is also input into the first DSConv submodule and the second DSConv submodule, and the output of the ConvM submodule and the first DSConv submodule is also input into the ASKA submodule; The specific workflow of the ASKA submodule is as follows: A1. Obtain the input feature map of the ASKA submodule, extract features through several convolution branches of different sizes, and obtain a fused feature map; A2. Perform global average pooling on the fused feature map to generate a global descriptor; A3. Input the global descriptor into two fully connected layers in sequence to generate the weights of each convolution branch; A4. Perform weighted summation on the outputs of each convolution branch according to the weights to obtain the output feature map of the ASKA submodule.
6. The complex multi-scale adaptive battery casing defect detection method according to claim 1, characterized in that: In S3, the bottleneck layer includes the first AMF module, the second AMF module, the fourth RepDSC_ASKA module, the fifth RepDSC_ASKA module, the sixth RepDSC_ASKA module, the seventh RepDSC_ASKA module, the eighth RepDSC_ASKA module, the ninth RepDSC_ASKA module, the fourth Aconv module and the fifth Aconv module; The first AMF module, the fourth RepDSC_ASKA module, the fifth RepDSC_ASKA module, the fourth Aconv module, the sixth RepDSC_ASKA module, the fifth Aconv module and the seventh RepDSC_ASKA module are connected in sequence; The second AMF module, the eighth RepDSC_ASKA module and the ninth RepDSC_ASKA module are connected in sequence.
7. The complex multi-scale adaptive battery casing defect detection method according to claim 6, characterized in that: S3 is specifically: The third defect feature is input into the first AMF module, the feature output by the first AMF module is upsampled and then fused with the second defect feature, the fused feature is input into the fourth RepDSC_ASKA module, the feature output by the fourth RepDSC_ASKA module is upsampled and then fused with the first defect feature, the fused feature is input into the fifth RepDSC_ASKA module to obtain the first detection feature, the first detection feature is input into the fourth Aconv module, the feature output by the fourth Aconv module is fused with the feature output by the fourth RepDSC_ASKA module, the fused feature is input into the sixth RepDSC_ASKA module to obtain the second detection feature, the second detection feature is input into the fifth Aconv module, the feature output by the fifth Aconv module is fused, the fused feature is input into the seventh RepDSC_ASKA module to obtain the third detection feature; The third defect feature is input into the second AMF module to obtain the sixth detection feature. The sixth detection feature is upsampled and fused with the second defect feature. The fused feature is input into the eighth RepDSC_ASKA module to obtain the fifth detection feature. The fifth detection feature is upsampled and fused with the first defect feature. The fused feature is input into the ninth RepDSC_ASKA module to obtain the fourth detection feature.
8. The complex multi-scale adaptive battery casing defect detection method according to claim 6, characterized in that: The structure of the first AMF module is the same as that of the second AMF module. The specific workflow of the structure is as follows: B1. Input the input feature map of the structure into three parallel branches and one global branch respectively, fuse the output features of all branches, and input the fused features into the channel attention mechanism LSE module; Three parallel branches are set up , and The convolution kernel of B2. The channel attention mechanism LSE module outputs the attention weight of each channel in the input feature map, multiplies the attention weight of each channel with the input feature map channel by channel, and obtains the weighted feature map; B3. Input the weighted feature map into the first Convolutional layer, obtain the output feature map of the structure.
9. The complex multi-scale adaptive battery casing defect detection method according to claim 8, characterized in that: In B2, the workflow of the channel attention mechanism LSE module is as follows: The feature map input by the channel attention mechanism LSE module is sequentially input into the global average pooling layer, the second Convolutional layer, ReLU activation function layer, third The convolution layer and the Sigmoid activation function layer generate channel weights, which are element-wise multiplied with the feature map input by the channel attention mechanism LSE module to obtain the attention weight of each channel.
10. The complex multi-scale adaptive battery casing defect detection method according to claim 1, characterized in that: S4 is specifically: The first to sixth detection features are input into the decoding prediction end, and based on the preset Ciou loss function and LMFLoss loss function, a defect prediction result of each detection feature is generated to obtain a battery shell defect detection result; LMFLoss loss function The specific expression is: In the formula, is the first hyperparameter, is the second hyperparameter, is the LDAM loss, It is Focal Loss, and its specific expression is: In the formula, For battery shell defect detection category The predicted probability of is the adjustment factor, x is the sample, y is the label corresponding to x, It is a model composed of a backbone network, a bottleneck layer, and a prediction end. is the output of the model, is the index value after margin adjustment, where is the margin parameter, For a specific category, is the number of categories.
Citation Information
Patent Citations
Steel plate surface defect detection system
CN113160141A
Workpiece surface defect detection method and device based on attention mechanism
CN116777853A
Lithium battery surface defect detection and model construction method based on multi-task learning
CN118657754A
Improved YOLOv8 X-ray security check image dangerous goods detection system
CN119048878A
Method for detecting traffic signs in foggy weather
CN119181076A