Battery surface defect detection method and device based on pixel contrast learning, and medium

CN118570144BActive Publication Date: 2026-10-20WUYI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410623168.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2026-10-20
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

电池表面缺陷会导致温度偏移,存在潜在的漏液和爆炸风险,因此需要对电池进行表面缺陷检测,避免存在表面缺陷的电池流入市场使用

Benefits of technology

[0043]上述方案至少具有以下的有益效果:通过获取第一图像和第二图像,第一图像标注有电池表面缺陷类型的标签,第二图像为正常电池表面图像;根据第一图像的特征和第二图像的特征得到特征差异图;根据特征差异图进行预测得到掩码图,掩码图包括各个像素点的预测类别;对特征差异图进行对比学习,根据预测类别构建正负样本对,计算正负样本对间的相似度;根据标签、掩码图和相似度得到损失函数值,根据损失函数值调整检测模型的参数,得到训练好的检测模型;增强了电池表面特征之间的异同,有效提升电池表面缺陷检测的准确性和鲁棒性;有效地提高电池工业产线上检测准确性和效率,降低产品质量的漏检率和误检率,从而保障电池产品的质量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570144B_ABST
    Figure CN118570144B_ABST
Patent Text Reader

Abstract

The application provides a battery surface defect detection method and device based on pixel contrast learning, a medium, and the like. The method comprises the following steps: acquiring a first image and a second image; obtaining a feature difference map according to features of the first image and features of the second image; obtaining a mask map according to the feature difference map, wherein the mask map comprises predicted categories of each pixel point; performing contrast learning on the feature difference map, constructing positive and negative sample pairs according to the predicted categories, and calculating similarities between the positive and negative sample pairs; adjusting parameters of a detection model according to labels, the mask map, and the similarities, and obtaining a trained detection model; the similarities and differences between battery surface features are enhanced, the accuracy and robustness of battery surface defect detection are effectively improved, the detection accuracy and efficiency on a battery industrial production line are effectively improved, the missed detection rate and the false detection rate of product quality are reduced, and thus the quality of battery products is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing, and more particularly to a method, device, and medium for detecting surface defects in batteries based on pixel contrast learning. Background Technology

[0002] Lithium-ion batteries are widely used due to their advantages such as high energy density, light weight, low production cost, high average output voltage, and long lifespan. However, surface defects in batteries can cause temperature deviations and pose potential risks of leakage and explosion. Therefore, surface defect detection is necessary to prevent batteries with surface defects from entering the market.

[0003] Defect detection primarily involves identifying the type and location of surface defects. Traditional detection methods mostly rely on manual visual inspection, requiring trained workers to identify complex surface defects. However, this method is not only labor-intensive but also has low accuracy and is susceptible to subjective human factors. Alternatively, infrared sensors can be used for distance-based detection, but this method struggles to detect small cracks or dents, resulting in low precision. Summary of the Invention

[0004] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.

[0005] The purpose of this application is to at least partially solve one of the technical problems existing in the related technologies. The embodiments of this application provide a battery surface defect detection method, device and medium based on pixel contrast learning, thereby improving the accuracy of automated battery surface defect detection.

[0006] An embodiment of the first aspect of this application provides a battery surface defect detection method based on pixel contrast learning, comprising:

[0007] Acquire the image to be detected;

[0008] The image to be detected is input into the trained detection model to detect surface defects in the battery, and the detection result is obtained.

[0009] Training the detection model includes the following steps:

[0010] Acquire a first image and a second image, wherein the first image is labeled with a tag indicating the type of battery surface defect, and the second image is an image of a normal battery surface;

[0011] A feature difference map is obtained based on the features of the first image and the features of the second image;

[0012] A mask image is obtained by predicting based on the feature difference map, and the mask image includes the predicted category of each pixel;

[0013] The feature difference map is subjected to comparative learning, positive and negative sample pairs are constructed according to the predicted category, and the similarity between the positive and negative sample pairs is calculated.

[0014] The loss function value is obtained based on the label, the mask image, and the similarity. The parameters of the detection model are adjusted based on the loss function value to obtain a trained detection model.

[0015] According to certain embodiments of the first aspect of this application, obtaining the first image includes:

[0016] Supervised learning of the annotation model is performed using labeled images to adjust the parameters of the annotation model;

[0017] Inputting the unlabeled image into the parameter-tuned labeling model yields a labeled image;

[0018] The labeled image is cleaned to obtain an image with incorrect labeling;

[0019] The cleaned and labeled images are input into the labeling model for training. The parameters of the labeling model are adjusted based on the images with incorrect labels to obtain the target labeling model.

[0020] The image to be labeled is input into the target labeling model to obtain the first image.

[0021] According to certain embodiments of the first aspect of this application, before obtaining a feature difference map based on the features of the first image and the features of the second image, the method includes:

[0022] The first image and the second image are respectively input into two feature extraction networks to extract features from the first image and the second image; wherein the two feature extraction networks share weights.

[0023] According to certain embodiments of the first aspect of this application, the feature extraction network extracts features from the input image, including:

[0024] The input image is convolved and upsampled by multiple convolutional layers of the feature extraction network to obtain multiple first feature maps. The multiple first feature maps are then residually connected through residual blocks to obtain output features.

[0025] Specifically, the residual block obtains the offset domain of the first feature map, determines the convolution sampling region based on the offset domain, and performs convolution based on the convolution sampling region.

[0026] According to certain embodiments of the first aspect of this application, obtaining a feature difference map based on features of the first image and features of the second image includes:

[0027] The fused features are obtained by fusing features from the first image and the second image.

[0028] A feature difference map is obtained based on the fusion features.

[0029] According to certain embodiments of the first aspect of this application, the step of fusing features based on features of the first image and features of the second image to obtain fused features includes:

[0030] The features of the first image and the features of the second image are merged on the channel to obtain the merged features;

[0031] The merged features are encoded through an embedding layer to obtain embedded features, and the keys, queries, and values ​​are mapped from the embedded features.

[0032] Attention features are derived from keys, queries, and values ​​based on an attention mechanism.

[0033] The first residual feature is obtained by performing a residual connection between the embedded feature and the attention feature;

[0034] The first residual feature is normalized through the first normalization layer to obtain the first normalized feature;

[0035] The first normalized feature is passed sequentially through a feedforward neural network and a second normalization layer to obtain the second normalized feature;

[0036] The second residual feature is obtained by performing a residual concatenation between the first normalized feature and the second normalized feature;

[0037] The second residual feature is decoded to obtain the fused feature.

[0038] According to certain embodiments of the first aspect of this application, the step of predicting the mask map based on the feature difference map includes:

[0039] The feature difference map is subjected to upsampling, convolution, normalization, activation function processing, convolution, and activation function processing in sequence to obtain a mask map.

[0040] According to certain embodiments of the first aspect of this application, the loss function value includes a contrastive learning loss value, which is expressed as: Where H represents the height of the image, W represents the width of the image, and P... ij |P represents the set of positive sample pairs corresponding to the pixel at coordinates (i,j). ij | represents set P ij The number of elements, N ij v represents the set of negative sample pairs of pixels corresponding to coordinates (i,j).ij The feature representation of the pixel with coordinates (i,j), v + Indicates v ij Positive sample feature representation, v - Indicates v ij The negative sample feature representation.

[0041] According to a second aspect of this application, an electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the battery surface defect detection method based on pixel contrast learning as described above.

[0042] According to a third aspect of this application, a computer storage medium stores computer-executable instructions for performing the battery surface defect detection method based on pixel contrast learning as described above.

[0043] The above scheme has at least the following beneficial effects: It acquires a first image and a second image, where the first image is labeled with the type of battery surface defect, and the second image is a normal battery surface image; a feature difference map is obtained based on the features of the first and second images; a mask image is obtained by prediction based on the feature difference map, and the mask image includes the predicted category of each pixel; comparative learning is performed on the feature difference map, positive and negative sample pairs are constructed based on the predicted categories, and the similarity between the positive and negative sample pairs is calculated; a loss function value is obtained based on the label, the mask image, and the similarity; the parameters of the detection model are adjusted based on the loss function value to obtain a trained detection model; it enhances the similarities and differences between battery surface features, effectively improving the accuracy and robustness of battery surface defect detection; it effectively improves the accuracy and efficiency of detection on battery industrial production lines, reduces the false negative and false positive rates of product quality, thereby ensuring the quality of battery products. Attached Figure Description

[0044] The accompanying drawings are used to provide a further understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.

[0045] Figure 1 This is a flowchart illustrating the steps of a battery surface defect detection method.

[0046] Figure 2 This is a flowchart illustrating the steps involved in training the detection model;

[0047] Figure 3 This is a schematic diagram illustrating the principle of obtaining the first image through semi-automatic annotation technology;

[0048] Figure 4 This is a framework diagram of the detection network;

[0049] Figure 5 This is a schematic diagram illustrating the principle of a feature extraction network;

[0050] Figure 6 This is a schematic diagram of the deformable convolution module.

[0051] Figure 7 This is a schematic diagram illustrating the principle of the feature attention fusion module;

[0052] Figure 8 This is a schematic diagram illustrating the principle of the attention mechanism module;

[0053] Figure 9 This is a schematic diagram of the feature mapping decoder module. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0055] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, or the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0056] The embodiments of this application will be further described below with reference to the accompanying drawings.

[0057] An embodiment of this application provides a battery surface defect detection method based on pixel contrast learning.

[0058] Reference Figure 1 A method for detecting surface defects in batteries includes the following steps:

[0059] Step S110: Obtain the image to be detected;

[0060] Step S120: Input the image to be detected into the trained detection model to detect surface defects of the battery and obtain the detection result.

[0061] Reference Figure 2 Training the detection model includes the following steps:

[0062] Step S200: Obtain the first image and the second image;

[0063] Step S300: Extract features from the first image and the second image to obtain the features of the first image and the features of the second image;

[0064] Step S400: Perform feature fusion based on the features of the first image and the features of the second image to obtain fused features;

[0065] Step S500: Obtain the feature difference map based on the fusion features;

[0066] Step S600: Predict the mask image based on the feature difference map;

[0067] Step S700: Perform comparative learning on the feature difference map, construct positive and negative sample pairs according to the predicted category, and calculate the similarity between positive and negative sample pairs;

[0068] In step S800, the loss function value is obtained based on the label, mask image, and similarity. The parameters of the detection model are adjusted based on the loss function value to obtain the trained detection model.

[0069] In step S200, the battery surface image is an image captured by an AOI camera. The image contains the defect target to be detected, as well as a large and complex background. To avoid interference from data outside the battery and to improve the algorithm's detection speed and accuracy, the image needs to be cropped. Furthermore, to reduce errors caused by image angular shifts, the image also needs to be corrected.

[0070] The detection model is a supervised learning network, requiring a large amount of labeled data before training; that is, it needs to learn from labeled training data. Battery surface defects are small and varied in shape, often including scratches, creases, and dents. Manually labeling all the data would be extremely time-consuming and resource-intensive. Semi-automated labeling technology reduces the cost of manual labeling and increases the speed of the labeling process.

[0071] Reference Figure 3 The first image is obtained through semi-automatic annotation technology, including the following steps:

[0072] Supervised learning of the annotation model is performed using labeled images, and the parameters of the annotation model are adjusted. Unlabeled images are input into the parameter-tuned annotation model to infer labeled images. The labeled images are cleaned to obtain images with incorrect labels. The cleaned labeled images are input into the annotation model for training, and the parameters of the annotation model are adjusted based on the images with incorrect labels. The above steps are repeated until the model can output relatively high-quality labeled data, resulting in the target annotation model. The images to be labeled are input into the target annotation model to obtain the first image. The first image is labeled with the correct battery surface defect type and is used to train the detection model.

[0073] The annotation model can be the FastSAM model, a general-purpose pre-trained segmentation model that can be efficiently fine-tuned with a small amount of data to adapt to various downstream tasks. Of course, other types of models can also be used in other embodiments.

[0074] In addition, a second image, which is a normal battery surface image, is selected from battery surface images taken by an Automated Optical Inspection (AOI) camera through manual or automatic screening.

[0075] Reference Figure 4 For step S300, the first image and the second image are respectively input into two feature extraction networks for feature extraction to obtain the features of the first image and the features of the second image; wherein, the two feature extraction networks share weights and are Siamese networks; the two feature extraction networks constitute the backbone network N.

[0076] The process by which a feature extraction network extracts features from an input image is as follows.

[0077] Reference Figure 5 The feature extraction network is a U-shaped network. By using residual connections as a shortcut, it can effectively solve the problem of gradient vanishing in traditional deep networks, which may be caused by the gradient decreasing due to multiplication during backpropagation.

[0078] The feature extraction network comprises a ResNet50 network consisting of multiple convolutional layers such as Conv1, Conv2_x, Conv3_x, Conv4_x, and Conv5_x, using the ResNet50 network as a baseline. The input image is sequentially passed through multiple convolutional layers such as Conv1, Conv2_x, Conv3_x, Conv4_x, and Conv5_x to gradually extract deep features, resulting in the first feature map. Specifically, Conv2_x uses 1x1 convolutions, while Conv3_x, Conv4_x, and Conv5_x all use 1x1 convolutions combined with upsampling. The 1x1 convolutions ensure that the number of channels is the same across the output feature maps, while the upsampling ensures that the output feature maps are consistent with the features of the previous generation. Figure 4 The features are of the same size. Each convolutional layer is then connected to the other side of the U-shaped network via a residual network composed of several residual blocks for feature fusion, yielding the output features. This effectively fuses shallow and deep features and achieves high-precision segmentation. Deep convolutional layers contain accurate semantic information but are insensitive to defect locations; shallow convolutional layers contain rich location details but lack corresponding semantic information. Multi-scale feature fusion can effectively combine shallow and deep features, outputting features rich in semantic information and rich in defect location details, thus extracting both the rich location information from shallow networks and the accurate semantic information from deep networks.

[0079] Reference Figure 6 The residual block is composed of 1x1 convolution and deformable convolution modules. The 1x1 convolution is used to modify the number of channels in the feature map to facilitate residual linking, while the deformable convolution module is used to extract image features.

[0080] Conventional convolution kernels have a fixed size and shape, which may work better for regularly shaped objects. However, battery surface defects typically include irregular shapes such as dents, scratches, and wrinkles. Deformable convolution allows sampling locations to better match the shape and size of the object itself, enabling better extraction of irregular defect features from the battery surface. Furthermore, it can be easily trained end-to-end using standard backpropagation. For deformable convolution, the input feature map is first fed into convolutional layer L. Layer L then obtains an offset region from the input feature map. The pixel size of the offset region is the same as the input feature map, but the number of channels is twice that of the input feature map, representing the offsets learned by the convolution kernel in the x and y directions. Under the influence of these offsets, the convolution sampling region corresponding to the deformable convolution is shifted.

[0081] For step S400, the feature attention fusion module A performs feature fusion based on the features of the first image and the features of the second image to obtain fused features, including the following steps:

[0082] Reference Figure 7 The features of the first image and the features of the second image are merged on the channel to obtain merged features; the merged features are encoded through an embedding layer to obtain embedded features, and keys, queries, and values ​​are mapped from the embedded features; attention features are obtained based on the keys, queries, and values ​​using an attention mechanism; the embedded features and attention features are residually connected to obtain first residual features; the first residual features are normalized through a first normalization layer to obtain first normalized features; the first normalized features are sequentially passed through a feedforward neural network and a second normalization layer to obtain second normalized features; the first normalized features and the second normalized features are residually connected to obtain second residual features; and the second residual features are decoded to obtain fused features.

[0083] Reference Figure 8 The attention mechanism module is a core component of the Tansformer encoder. Q, K, and V are obtained by mapping the input feature map through an embedding layer, representing the query, key, and value, respectively. Assume there is a database with many key-value pairs. For a query, we need to find the best element in the database. This can be achieved by calculating the similarity between the query and all keys in the database. The attention mechanism calculates the similarity between different elements based on this idea. The attention feature map A is represented as: Let d represent the feature dimensions of q, k, and v, σ represent the softmax activation function, and the attention feature map A be a square matrix. A[i,j] represents the similarity between the i-th k and the j-th q. The attention feature Y is represented as: Y = VA.

[0084] For step S500, a feature difference map is obtained based on the fusion features. The feature difference map C is the absolute value of the difference between the two semantic feature maps corresponding to the first image and the second image, respectively.

[0085] For step S600, the mask image is obtained by prediction based on the feature difference map, including the following steps:

[0086] Reference Figure 9 The feature map is obtained by performing upsampling, convolution, normalization, activation function processing, and activation function processing on the feature difference map in sequence through the feature map decoder J module.

[0087] The feature map decoder J is a deep learning network consisting of an upsampling layer, two convolutional layers, a normalization layer, and an activation function. Its input is the absolute value of the difference between two semantic feature maps, and its output is a mask map of the same size as the template map and the image to be detected. The mask map contains information about the defect category and precise location in the image to be detected.

[0088] For step S700, the loss function value is obtained based on the label, mask image, and similarity.

[0089] On one hand, the cross-entropy function L is calculated based on the predicted defect category information from the mask image and the correct battery surface defect type indicated in the label. CE ,have Where H represents the height of the image, W represents the width of the image, M represents the number of categories, and y ijc The pixel at coordinates (i,j) is assigned a value of 1 if its true class is c, and 0 otherwise. It is the probability that the pixel with coordinates (i,j) belongs to category c.

[0090] On the other hand, the cross-entropy function only constrains the prediction of each pixel independently, ignoring the relationships between pixels. To improve the detection algorithm's ability to detect the difference between background and defect category features on the battery surface, a contrastive learning approach is adopted. The pixel location information in the label is used to classify pixels at corresponding positions in the feature map into multiple categories such as "background" and "defect." Positive and negative sample pairs are constructed according to the principle that pixels of the same category are positive samples to each other, and pixels of different categories are negative samples to each other. The similarity between samples is calculated, minimizing the distance between positive sample pairs and maximizing the distance between negative sample pairs to effectively learn the similarities and differences between battery surface features. The loss value of contrastive learning is calculated based on the similarity, and the loss value of contrastive learning is expressed as: Where H represents the height of the image, W represents the width of the image, and P... ij |P represents the set of positive sample pairs corresponding to the pixel at coordinates (i,j). ij | represents set P ij The number of elements, N ij v represents the set of negative sample pairs of pixels corresponding to coordinates (i,j). ij The feature representation of the pixel with coordinates (i,j), v + Indicates v ij Positive sample feature representation, v - Indicates v ij The negative sample feature representation.

[0091] Choosing a combination of cross-entropy loss and pixel contrastive learning loss as the minimization objective, the total loss function value is: L = L CE +λL NCE Here, λ controls the relative importance of the two losses and can be set to 1.

[0092] The parameters of the detection model are adjusted based on the loss function value to obtain a trained detection model.

[0093] The trained detection model is then used in the online application phase. Two sets of images, the template image and the image to be detected, are preprocessed and then input into the detection algorithm. The algorithm outputs a defect mask image, and the post-processing algorithm determines and identifies whether defects exist in the image. If a defect is found, the battery defect management platform immediately integrates relevant information, including the original battery image, mask image, corresponding production line, and model number, and feeds it back to the staff's display terminal module. Relevant staff then conduct further inspections and confirmations on the specific battery production line, effectively reducing the probability of defective batteries appearing in subsequent production and ensuring product quality.

[0094] By utilizing pixel contrast learning, the detection model's ability to distinguish between positive and negative samples of pixels has been improved, enhancing the similarities and differences between surface features of the battery and effectively improving the accuracy and robustness of battery surface defect detection. This effectively improves the accuracy and efficiency of detection on battery industrial production lines, reduces the false negative and false positive rates of product quality, and thus ensures the quality of battery products.

[0095] An embodiment of this application provides an electronic device. The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the battery surface defect detection method based on pixel contrast learning as described above.

[0096] This electronic device can be any smart terminal, including computers.

[0097] In general, for the hardware structure of electronic devices, the processor can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, to execute relevant programs and implement the technical solutions provided in the embodiments of this application.

[0098] The memory can be implemented in the form of read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory and is called and executed by the processor.

[0099] Input / output interfaces are used to implement information input and output.

[0100] The communication interface is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0101] The bus transmits information between various components of a device, such as the processor, memory, input / output interfaces, and communication interfaces. The processor, memory, input / output interfaces, and communication interfaces communicate with each other within the device via the bus.

[0102] An embodiment of this application provides a computer storage medium. The computer storage medium stores computer-executable instructions for performing the pixel-contrast learning-based battery surface defect detection method described above.

[0103] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium. In the foregoing description of this specification, references to terms such as "one embodiment," "another embodiment," or "some embodiments" indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0104] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0105] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0106] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0107] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0108] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed between each other may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms. Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.

[0109] The above is a detailed description of the preferred embodiments of this application, but this application is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.

Claims

1. A method for detecting surface defects in batteries based on pixel contrast learning, characterized in that, include: Acquire the image to be detected; The image to be detected is input into a trained detection model to detect surface defects in the battery, and the detection result is obtained. Training the detection model includes the following steps: Acquire a first image and a second image, wherein the first image is labeled with the type of battery surface defect, and the second image is a normal battery surface image; A feature difference map is obtained based on the features of the first image and the features of the second image. The feature difference map is the absolute value of the difference between the two semantic feature maps corresponding to the first image and the second image, respectively. A mask image is obtained by predicting based on the feature difference map, and the mask image includes the predicted category of each pixel; The feature difference map is subjected to comparative learning, positive and negative sample pairs are constructed according to the predicted category, and the similarity between the positive and negative sample pairs is calculated. The loss function value is obtained based on the label, the mask image, and the similarity. The parameters of the detection model are adjusted based on the loss function value to obtain a trained detection model.

2. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, Acquiring the first image includes: Supervised learning of the annotation model is performed using labeled images to adjust the parameters of the annotation model; Inputting the unlabeled image into the parameter-tuned labeling model yields a labeled image; The labeled image is cleaned to obtain an image with incorrect labeling; The cleaned and labeled images are input into the labeling model for training. The parameters of the labeling model are adjusted based on the images with incorrect labels to obtain the target labeling model. The image to be labeled is input into the target labeling model to obtain the first image.

3. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, Before obtaining the feature difference map based on the features of the first image and the features of the second image, the method includes: The first image and the second image are respectively input into two feature extraction networks to extract features from the first image and the second image; wherein the two feature extraction networks share weights.

4. The battery surface defect detection method based on pixel contrast learning according to claim 3, characterized in that, The feature extraction network extracts features from the input image, including: The input image is convolved and upsampled by multiple convolutional layers of the feature extraction network to obtain multiple first feature maps. The multiple first feature maps are then residually connected through residual blocks to obtain output features. Specifically, the residual block obtains the offset domain of the first feature map, determines the convolution sampling region based on the offset domain, and performs convolution based on the convolution sampling region.

5. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, The step of obtaining a feature difference map based on the features of the first image and the features of the second image includes: The fused features are obtained by fusing features from the first image and the second image. A feature difference map is obtained based on the fusion features.

6. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, The step of fusing features based on the features of the first image and the features of the second image to obtain fused features includes: The features of the first image and the features of the second image are merged on the channel to obtain the merged features; The merged features are encoded through an embedding layer to obtain embedded features, and the keys, queries, and values ​​are mapped from the embedded features. Attention features are derived from keys, queries, and values ​​based on an attention mechanism. The first residual feature is obtained by performing a residual connection between the embedded feature and the attention feature; The first residual feature is normalized through the first normalization layer to obtain the first normalized feature; The first normalized feature is passed sequentially through a feedforward neural network and a second normalization layer to obtain the second normalized feature; The second residual feature is obtained by performing a residual concatenation between the first normalized feature and the second normalized feature; The second residual feature is decoded to obtain the fused feature.

7. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, The step of predicting the mask image based on the feature difference map includes: The feature difference map is subjected to upsampling, convolution, normalization, activation function processing, convolution, and activation function processing in sequence to obtain a mask map.

8. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that, The loss function value includes the contrastive learning loss value, which is expressed as: in, Indicates the height of the image. Indicates the width of the image. Indicates the corresponding coordinates as The set of positive sample pairs of pixels, Indicates the set The number of elements, Represents the corresponding coordinates The set of negative sample pairs of pixels, Coordinates are The feature representation of the pixels, express Positive sample feature representation, express The negative sample feature representation.

9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the battery surface defect detection method based on pixel contrast learning as described in any one of claims 1 to 8.

10. A computer storage medium, characterized in that, The device stores computer-executable instructions for performing the battery surface defect detection method based on pixel contrast learning as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Product surface defect segmentation method, defect segmentation model learning method and device

    CN111754513A

  • Target detection method, training method of target detection model, equipment and storage medium

    CN115937596A