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

Through the pixel contrast learning method, the accuracy and robustness of battery surface defect detection are improved, the problem of low accuracy of traditional detection methods is solved, and more efficient battery surface defect detection is achieved.

CN118570144AActive Publication Date: 2024-08-30WUYI UNIV
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Traditional battery surface defect detection methods rely on manual visual inspection or infrared sensors, which have low accuracy and are easily affected by human subjective factors. It is difficult to detect small seams or dents, resulting in low detection accuracy.

Method used

The battery surface defect detection method based on pixel contrast learning is used to obtain images marked with defective types and normal images, and perform feature extraction, fusion and contrast learning, construct positive and negative sample pairs, calculate similarity, adjust detection model parameters, and improve detection. Accuracy.

Benefits of technology

It effectively improves the accuracy and robustness of battery surface defect detection, reduces the missed detection rate and false detection rate, improves the detection accuracy and efficiency of battery industrial production lines, and ensures product quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570144A
    Figure CN118570144A
Patent Text Reader

Abstract

The invention provides a battery surface defect detection method and device based on pixel contrast learning and a medium. The method comprises the following steps: acquiring a first image and a second image; obtaining a feature difference chart according to the features of the first image and the features of the second image; obtaining a mask image according to the feature difference image, wherein the mask image comprises a prediction category of each pixel point; performing comparative learning on the feature difference chart, constructing positive and negative sample pairs according to prediction categories, and calculating the similarity between the positive and negative sample pairs; adjusting parameters of the detection model according to the label, the mask pattern and the similarity to obtain a trained detection model; similarities and differences between battery surface features are enhanced, and 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, and the omission ratio and false detection ratio of product quality are reduced, so that the quality of battery products is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing, and in particular to a battery surface defect detection method, device and medium based on pixel contrast learning. Background Art

[0002] Lithium-ion batteries are widely used due to their high energy density, light weight, low production cost, high average output voltage, and long life. Battery surface defects can cause temperature deviations, and there are potential risks of leakage and explosion. Therefore, it is necessary to detect surface defects on batteries to prevent batteries with surface defects from entering the market.

[0003] Defect detection is mainly to find out the type and location of surface defects of objects. Traditional detection methods are mostly completed through manual visual inspection, that is, it is necessary to train specific workers to identify complex surface defects. However, this method not only consumes a lot of manpower, but also has low accuracy and is easily affected by human subjective factors. Alternatively, infrared sensors are used to detect based on distance, but this method is difficult to detect smaller seams or dents and has low detection accuracy. Summary of the invention

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

[0005] The purpose of the present application is to solve at least one of the technical problems existing in the related art to a certain extent. The embodiments of the present application provide a battery surface defect detection method, device and medium based on pixel contrast learning to improve the accuracy of automated battery surface defect detection.

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

[0007] Acquire the image to be detected;

[0008] Inputting the image to be detected into a trained detection model to perform battery surface defect detection to obtain a detection result;

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

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

[0011] Obtaining a feature difference map according to features of the first image and features of the second image;

[0012] Predicting according to the feature difference map to obtain a mask map, wherein the mask map includes a predicted category of each pixel point;

[0013] Performing comparative learning on the feature difference map, constructing positive and negative sample pairs according to the predicted categories, and calculating the similarity between the positive and negative sample pairs;

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

[0015] According to some embodiments of the first aspect of the present application, acquiring the first image includes:

[0016] Performing supervised learning on the annotation model through the annotated images, and adjusting the parameters of the annotation model;

[0017] Input the unlabeled image into the parameter-adjusted labeling model to obtain the labeled image;

[0018] Cleaning the labeled image to obtain an image with incorrect labels;

[0019] Inputting the cleaned annotated image into the annotation model for training, adjusting the parameters of the annotation model according to the incorrectly annotated image, and obtaining a target annotation model;

[0020] The image to be annotated is input into the target annotation model to obtain a first image.

[0021] According to certain embodiments of the first aspect of the present application, before obtaining a feature difference map according to features of the first image and 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 to obtain features of the first image and features of the second image; wherein the weights of the two feature extraction networks are shared.

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

[0024] Convolving and upsampling the input image through multiple convolutional layers of the feature extraction network to obtain multiple first feature maps, and performing residual connection on the multiple first feature maps through residual blocks to obtain output features;

[0025] The residual block obtains an offset domain of the first feature map, determines a convolution sampling area according to the offset domain, and performs convolution according to the convolution sampling area.

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

[0027] Performing feature fusion according to the features of the first image and the features of the second image to obtain a fusion feature;

[0028] A feature difference map is obtained according to the fused features.

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

[0030] Merging the features of the first image and the features of the second image on the channel to obtain a merged feature;

[0031] Encoding the merged features through an embedding layer to obtain embedded features, and mapping the embedded features to obtain keys, queries, and values;

[0032] Get attention features based on key, query and value based on attention mechanism;

[0033] Performing a residual connection between the embedding feature and the attention feature to obtain a first residual feature;

[0034] Normalizing the first residual feature through a first normalization layer to obtain a first normalized feature;

[0035] Passing the first normalized features through a feedforward neural network and a second normalized layer in sequence to obtain a second normalized feature;

[0036] Performing a residual connection on the first normalized feature and the second normalized feature to obtain a second residual feature;

[0037] The second residual feature is decoded to obtain a fusion feature.

[0038] According to certain embodiments of the first aspect of the present application, the step of predicting according to the feature difference map to obtain a mask map includes:

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

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

[0041] An embodiment of the second aspect of the present application is an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the battery surface defect detection method based on pixel contrast learning as described above is implemented.

[0042] An embodiment of the third aspect of the present application is a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute 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: by acquiring a first image and a second image, the first image is annotated with a label of the battery surface defect type, and the second image is a normal battery surface image; a feature difference map is obtained according to the features of the first image and the features of the second image; a mask map is obtained by prediction based on the feature difference map, and the mask map includes the predicted category of each pixel point; comparative learning is performed on the feature difference map, positive and negative sample pairs are constructed according to the predicted category, and the similarity between the positive and negative sample pairs is calculated; a loss function value is obtained according to the label, mask map and similarity, and the parameters of the detection model are adjusted according to the loss function value to obtain a trained detection model; the similarities and differences between battery surface features are enhanced, and the accuracy and robustness of battery surface defect detection are effectively improved; the detection accuracy and efficiency on the battery industrial production line are effectively improved, and the missed detection rate and false detection rate of product quality are reduced, thereby ensuring the quality of battery products. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.

[0045] Figure 1 It is a step diagram of a battery surface defect detection method;

[0046] Figure 2 It is a diagram of the steps for training the detection model;

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

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

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

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

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

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

[0053] Fig. 9 It is a schematic diagram of the principle of feature map decoder module. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] It should be noted that, although the functional modules are divided in the device schematic diagram and the 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 above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0056] The embodiments of the present application are further described below in conjunction with the accompanying drawings.

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

[0058] Reference Figure 1 , a battery surface defect detection method comprises the following steps:

[0059] Step S110, obtaining an image to be detected;

[0060] Step S120, inputting the image to be inspected into the trained inspection model to perform battery surface defect inspection to obtain the inspection result.

[0061] Reference Figure 2 , training the detection model, including the following steps:

[0062] Step S200, acquiring a first image and a second image;

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

[0064] Step S400, performing feature fusion according to the features of the first image and the features of the second image to obtain a fusion feature;

[0065] Step S500, obtaining a feature difference map according to the fusion features;

[0066] Step S600, predicting according to the feature difference map to obtain a mask map;

[0067] Step S700, performing comparative learning on the feature difference graph, constructing positive and negative sample pairs according to the predicted categories, and calculating the similarity between the positive and negative sample pairs;

[0068] Step S800, obtaining a loss function value according to the label, mask image and similarity, adjusting the parameters of the detection model according to the loss function value, and obtaining a trained detection model.

[0069] For step S200, the battery surface image is a picture taken by the AOI camera, which contains the defect target to be detected and a large area and complex background. In order to avoid interference from data outside the battery area and improve the detection speed and detection accuracy of the algorithm, the picture needs to be cropped. In order to reduce the error caused by the angle offset of the picture, the picture also needs to be corrected.

[0070] The detection model is a supervised learning network. Before training the model, a large amount of labeled data is required, that is, it needs to learn from labeled training data. The shapes of battery surface defects are small and varied, mostly scratches, creases, dents, etc. Manually labeling all the data requires a lot of manpower and material resources. Semi-automatic labeling technology reduces the cost of manual labeling and improves the speed of labeling work.

[0071] Reference Figure 3 , obtaining a first image by a semi-automatic annotation technique, comprising the following steps:

[0072] The labeled model is supervised through labeled images, and the parameters of the labeling model are adjusted; the unlabeled image is input into the adjusted labeling model, and the labeled image is inferred; the labeled image is cleaned to obtain the wrongly labeled image; the cleaned labeled image is input into the labeling model for training, and the parameters of the labeling model are adjusted according to the wrongly labeled image; the above steps are repeated until the model can output relatively high-quality labeled data to obtain the target labeling model; the image to be labeled is input into the target labeling model to obtain the first image. The first image is labeled with the correct type of battery surface defect label, and the first image is used to train the detection model.

[0073] The labeling model may adopt the FastSAM model, which is a general pre-trained segmentation model that can adapt to various downstream tasks through efficient parameter fine-tuning of a small amount of data. Of course, in other embodiments, other types of models may also be adopted.

[0074] In addition, a second image is manually or automatically screened out from the battery surface image taken by an automated optical inspection (AOI) camera, and the second image is a normal battery surface image.

[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 features of the first image and features of the second image; wherein the two feature extraction networks share weights and are twin networks; the two feature extraction networks constitute the backbone network N.

[0076] The process of feature extraction network extracting features from input images is as follows.

[0077] Reference Figure 5 The feature extraction network is a U-shaped network. The shortcut of residual connection can effectively solve the problem that the gradient of the traditional deep network may become smaller due to multiplication during the back propagation process, resulting in the disappearance of the gradient of the network.

[0078] The feature extraction network includes a ResNet50 network composed of multiple convolutional layers such as Conv1, Conv2_x, Conv3_x, Conv4_x, and Conv5_x, with the ResNet50 network as the benchmark. The input image is passed through multiple convolutional layers such as Conv1, Conv2_x, Conv3_x, Conv4_x, and Conv5_x to gradually extract deep features and obtain the first feature map; among them, Conv2_x passes through 1x1 convolution, and Conv3_x, Conv4_x, and Conv5_x all pass through 1x1 convolution and upsampling operations. 1x1 convolution is to ensure that the number of channels between the output feature maps is the same, and upsampling is to ensure that the output feature maps are consistent with the feature maps. Figure 4 The sizes are the same. Then each convolution layer is connected to the other side of the U-shaped network through a residual network composed of several residual blocks for feature fusion to obtain the output features. This can effectively fuse shallow and deep features and achieve high-precision segmentation. The features of the deep convolution layer have accurate semantic information, but are insensitive to the defect location; the features of the shallow convolution layer contain rich location details but lack corresponding semantic information. Multi-scale feature fusion can effectively combine shallow and deep features, and output features with rich semantic information and rich defect location details, in order to extract both rich location information in the shallow network and accurate semantic information in the deep network.

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

[0080] The convolution kernel of conventional convolution is of fixed size and shape, which may have better effects for objects with regular shapes, but defects on the surface of batteries usually include some irregular shapes such as dents, scratches, and wrinkles. The use of deformable convolution can make the sampling position more consistent with the shape and size of the object itself, can better extract the irregular defect features of the battery surface, and can be easily trained end-to-end through standard back propagation. For deformable convolution, the input feature map is first input into the convolution layer L, and the offset domain of the input feature map is obtained through the convolution layer L. The pixel size of the offset domain is the same as the size of the input feature map, and the number of channels is twice that of the input feature map, which means that the convolution kernel learns the offset in the x-direction and y-direction respectively. Under the effect of the offset, the convolution sampling area corresponding to the deformable convolution is offset.

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

[0082] Reference Figure 7 , merge the features of the first image and the features of the second image on the channel to obtain a merged feature; encode the merged feature through an embedding layer to obtain an embedded feature, and obtain the key, query and value from the embedded feature map; obtain the attention feature according to the key, query and value based on the attention mechanism; perform residual connection on the embedded feature and the attention feature to obtain the first residual feature; normalize the first residual feature through a first normalization layer to obtain the first normalized feature; pass the first normalized feature through a feedforward neural network and a second normalization layer in sequence to obtain the second normalized feature; perform residual connection on the first normalized feature and the second normalized feature to obtain the second residual feature; decode the second residual feature to obtain the fusion feature.

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

[0084] For step S500, a feature difference map is obtained according to the fusion features, and 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, predicting a mask image based on the feature difference image includes the following steps:

[0086] Reference Fig. 9 , the feature difference map is sequentially processed by upsampling, convolution, normalization, activation function, convolution and activation function to obtain the mask map through the feature map decoder J module.

[0087] Among them, the feature map decoder J is a deep learning network composed 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 with the same size as the template map and the image to be detected. The mask map contains the defect category information and precise location information in the image to be detected.

[0088] For step S700, a loss function value is obtained according to the label, the mask image and the similarity.

[0089] On the one hand, the cross entropy function L is calculated based on the predicted defect category information of the mask image and the correct battery surface defect type marked in the label. CE ,have Among them, H represents the height of the image, W represents the width of the image, M represents the number of categories, and y ijc The true category of the pixel with coordinates (i, j) is 1 if it is c, otherwise it is 0. is the probability that the pixel with coordinates (i, j) is of category c.

[0090] On the other hand, the cross entropy function only constrains the prediction of each pixel independently, while ignoring the relationship between pixels. In order to improve the detection algorithm's ability to detect the difference between the background class and defect category features of battery surface defects, the idea of ​​contrastive learning is used to classify the pixels at the corresponding positions in the feature map into multiple categories of "background" and "defects". According to the principle that pixels of the same category are positive samples for each other and pixels of different categories are negative samples for each other, positive and negative sample pairs are constructed to calculate the similarity between samples, minimize the distance between positive sample pairs, and maximize the distance between negative sample pairs, so as 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: Among them, H represents the height of the image, W represents the width of the image, and P ij represents the set of positive sample pairs corresponding to the pixel coordinates (i, j), |P ij | represents the set P ij The number of elements, N ij Represents the set of negative sample pairs of pixels corresponding to coordinates (i, j), v ij The feature representation of the pixel with coordinates (i, j), v + Indicates v ij The positive sample feature representation, v - Indicates v ij Negative sample feature representation.

[0091] The combination of cross entropy loss and pixel contrast learning loss is selected as the minimization target, and the total loss function value is: L = L CE +λL NCE . Among them, λ controls the relative importance of the two losses and can be set to 1.

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

[0093] The trained detection model is used in the online application stage. The two groups of images, the template image and the image to be detected, are preprocessed and then input into the detection algorithm. The defect mask image is then output. The post-processing algorithm is used to determine and identify whether there are defects in the image. If defects are found, the battery defect management platform will immediately integrate the relevant information, including the original image of the battery, the mask image, the corresponding production line and the model, and feedback to the staff's display terminal module. The relevant staff will further inspect and confirm the specific battery production line, effectively reducing the probability of defective batteries in subsequent production and ensuring product quality.

[0094] The use of pixel contrast learning improves the detection model for batteries, improves the network's ability to distinguish between positive and negative samples of pixels, enhances the similarities and differences between battery surface features, and effectively improves the accuracy and robustness of battery surface defect detection; effectively improves the detection accuracy and efficiency on the battery industrial production line, reduces the missed detection rate and false detection rate of product quality, thereby ensuring the quality of battery products.

[0095] An embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the battery surface defect detection method based on pixel contrast learning as described above when executing the computer program.

[0096] The electronic device may be any intelligent terminal including a computer.

[0097] In general, for the hardware structure of the electronic device, the processor can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., to execute related programs to implement the technical solutions provided in the embodiments of the present application.

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

[0099] The input / output interface is used to realize information input and output.

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

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

[0102] An embodiment of the present application provides a computer storage medium storing computer executable instructions for executing the battery surface defect detection method based on pixel contrast learning as described above.

[0103] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium 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 include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. In addition, it is well known to those of ordinary skill 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 above description of this specification, the description of reference terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" and the like means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

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

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

[0106] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0107] If the integrated unit is implemented in the form of 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 the present application, 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, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0108] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above-mentioned units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. Although the embodiments of the present application have been shown and described, it can be understood by those of ordinary skill in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and purposes of the present application, and the scope of the present application is defined by the claims and their equivalents.

[0109] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the embodiments. Technical personnel familiar with the field can make various equivalent modifications or substitutions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.

Claims

1. A battery surface defect detection method based on pixel contrast learning, characterized in that: include: Acquire the image to be detected; Inputting the image to be detected into a trained detection model to perform battery surface defect detection to obtain a detection result; Training the detection model comprises the following steps: Acquire a first image and a second image, wherein the first image is annotated with a label of a battery surface defect type, and the second image is an image of a normal battery surface; Obtaining a feature difference map according to features of the first image and features of the second image; Predicting according to the feature difference map to obtain a mask map, wherein the mask map includes a predicted category of each pixel point; Performing comparative learning on the feature difference map, constructing positive and negative sample pairs according to the predicted categories, and calculating the similarity between the positive and negative sample pairs; A loss function value is obtained according to the label, the mask image and the similarity, and the parameters of the detection model are adjusted according to 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 is characterized in that: Acquiring the first image includes: Performing supervised learning on the annotation model through the annotated images, and adjusting the parameters of the annotation model; Input the unlabeled image into the parameter-adjusted labeling model to obtain the labeled image; Cleaning the labeled image to obtain an image with incorrect labels; Inputting the cleaned annotated image into the annotation model for training, adjusting the parameters of the annotation model according to the incorrectly annotated image, and obtaining a target annotation model; The image to be annotated is input into the target annotation model to obtain a first image.

3. The battery surface defect detection method based on pixel contrast learning according to claim 1 is characterized in that: Before obtaining a feature difference map according to 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 to obtain features of the first image and features of the second image; wherein the weights of the two feature extraction networks are shared.

4. The battery surface defect detection method based on pixel contrast learning according to claim 3 is characterized in that: The feature extraction network extracts features from the input image, including: Convolving and upsampling the input image through multiple convolutional layers of the feature extraction network to obtain multiple first feature maps, and performing residual connection on the multiple first feature maps through residual blocks to obtain output features; The residual block obtains an offset domain of the first feature map, determines a convolution sampling area according to the offset domain, and performs convolution according to the convolution sampling area.

5. The battery surface defect detection method based on pixel contrast learning according to claim 1 is characterized in that: The obtaining a feature difference map according to the features of the first image and the features of the second image includes: Performing feature fusion according to the features of the first image and the features of the second image to obtain a fusion feature; A feature difference map is obtained according to the fused 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 according to the features of the first image and the features of the second image to obtain fused features includes: Merging the features of the first image and the features of the second image on the channel to obtain a merged feature; Encoding the merged features through an embedding layer to obtain embedded features, and mapping the embedded features to obtain keys, queries, and values; Get attention features based on key, query and value based on attention mechanism; Performing a residual connection between the embedding feature and the attention feature to obtain a first residual feature; Normalizing the first residual feature through a first normalization layer to obtain a first normalized feature; Passing the first normalized features through a feedforward neural network and a second normalized layer in sequence to obtain a second normalized feature; Performing a residual connection on the first normalized feature and the second normalized feature to obtain a second residual feature; The second residual feature is decoded to obtain a fusion feature.

7. The battery surface defect detection method based on pixel contrast learning according to claim 1, characterized in that: The step of predicting according to the feature difference map to obtain a mask map includes: The feature difference map is sequentially subjected to upsampling processing, convolution processing, normalization processing, activation function processing, convolution processing and activation function processing 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 a loss value of contrastive learning, and the loss value of contrastive learning is expressed as: Among them, H represents the height of the image, W represents the width of the image, and P ij represents the set of positive sample pairs corresponding to the pixel coordinates (i, j), |P ij | represents the set P ij The number of elements, N ij Represents the set of negative sample pairs corresponding to the pixel coordinates (i, j), v ij The feature representation of the pixel with coordinates (i, j), v + Indicates v ij The positive sample feature representation, v - Indicates v ij 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 when the processor executes the computer program, the battery surface defect detection method based on pixel contrast learning as described in any one of claims 1 to 8 is implemented.

10. A computer storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute 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

  • Defect detection model training method, defect detection method and related device

    CN111814867A

  • Surface defect detection method based on feature reconstruction

    CN114419014A

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

    CN115937596A