Method and device for detecting surface defects of product

CN118696339AActive Publication Date: 2024-09-24CONTEMPORARY AMPEREX TECHNOLOGY CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202280091450.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2024-09-24
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

Existing technology is difficult to efficiently and accurately detect defects with small surface areas and unclear boundaries on products, especially in defect areas with high morphological complexity, and it is difficult to distinguish defect areas from other areas.

Method used

Using a regional segmentation model, sampling calculations are connected through multiple data processing layers to reduce the amount of calculation and improve detection efficiency. The output feature map has pixel labels to achieve high-precision segmentation. This model processes images through downsampling and upsampling calculations, increasing channels to reduce resolution, prevent overfitting, and improve segmentation accuracy.

Benefits of technology

It achieves high-precision segmentation of product surface defects, improves analysis speed and data processing efficiency, can accurately locate defect areas, and improves the accuracy of product quality control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118696339A
    Figure CN118696339A
Patent Text Reader

Abstract

The invention discloses a method and a device for detecting surface defects of a product, which can reduce the calculated amount and improve the detection efficiency while accurately segmenting a defect area on the surface of the product. The method for detecting surface defects of a product comprises: acquiring a first picture of a product (S210); according to the first picture and a region segmentation model, obtaining a defect region of the product (S220), the region segmentation model comprising a plurality of data processing layers, the plurality of data processing layers being connected by performing sampling calculation on data to be sampled, the to-be-sampled data of the at least one data processing layer is obtained by splicing first intermediate data generated by input data of the data processing layer and second intermediate data generated by the first intermediate data.
Need to check novelty before this filing date? Find Prior Art

Description

Method and device for detecting surface defects of products Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method and device for detecting surface defects of products. Background Art

[0002] In the field of modern industrial manufacturing, due to the reasons of technology, equipment and multiple production processes, industrial products may have one or more defects. Defect detection of industrial products is a key link in controlling the quality of industrial products.

[0003] However, currently used inspection methods can only identify relatively obvious defects and struggle to detect smaller defects with unclear boundaries. For defects with highly complex morphology, it is also difficult to accurately distinguish the defective area from other areas. Therefore, how to efficiently and accurately detect defects on product surfaces remains an urgent problem.

[0004] Summary of the Invention

[0005] The present application provides a method and apparatus for detecting surface defects of products, which can accurately segment defective areas on the surface of products while reducing the amount of calculation and improving detection efficiency.

[0006] In a first aspect, a method for detecting surface defects of a product is provided, comprising: obtaining a first image of the product; obtaining a defective area of ​​the product based on the first image and a region segmentation model, wherein the region segmentation model comprises a plurality of data processing layers, the plurality of data processing layers being connected by performing sampling calculations on the data to be sampled, and the data to be sampled of at least one data processing layer is obtained by splicing first intermediate data generated by input data of the data processing layer with second intermediate data generated by the first intermediate data.

[0007] By segmenting the defective regions in the first image using a region segmentation model, the speed of analyzing the defective regions can be increased. The output feature map has pixel labels, enabling high-precision segmentation. By performing data processing in the region segmentation model using the processing method provided in this application, the computational effort of the region segmentation model when analyzing the first image can be significantly reduced, further increasing the speed of segmenting the defective regions in the first image. Furthermore, the graphics memory usage of the model inference can be reduced, improving data processing efficiency.

[0008] In some embodiments, segmenting the defective area of ​​the product according to the first image and the region segmentation model includes: segmenting a continuous area of ​​the product according to the first image and the region segmentation model, wherein the continuous area includes the defective area and the non-defective area.

[0009] When there are many product features in the first image, the region segmentation model can separate different continuous regions with higher accuracy, avoiding analyzing non-defective regions as defective regions, which is conducive to accurately judging product quality based on defective regions.

[0010] In some embodiments, segmenting the defective area of ​​the product based on the first image and the region segmentation model includes: obtaining a second image based on the first image and the region segmentation model, wherein the defective area is marked on the second image.

[0011] By outputting a second image with defective areas marked, the defective areas can be matched with the first image, and the position of the defective areas on the first image as well as the shape and size of the defective areas can be seen more intuitively, which is conducive to analyzing the defective areas on the product.

[0012] In some embodiments, the multiple data processing layers include n data processing layers, where n is a positive integer greater than 1; obtaining the second image based on the first image and the region segmentation model includes: performing n-1 downsampling calculations on the first image to obtain input data of the nth layer; splicing the first intermediate data of the nth layer generated by the input data of the nth layer with the second intermediate data of the nth layer generated by the first intermediate data of the nth layer to obtain the data to be sampled of the nth layer; performing n-1 upsampling calculations on the data to be sampled of the nth layer to obtain the second image.

[0013] By processing the first image through upsampling and downsampling calculations, more information about the first image can be obtained, providing better small object and object edge segmentation effects, and facilitating accurate segmentation of different regions in the first image. This can also prevent overfitting and reduce the amount of computation.

[0014] In some embodiments, the downsampling calculation of the first image n-1 times includes: splicing the first intermediate data of the mth layer generated by the input data of the mth layer and the second intermediate data of the mth layer generated by the first intermediate data of the mth layer to obtain the data to be sampled of the mth layer, where m is a positive integer greater than 0 and less than n; performing downsampling calculation on the data to be sampled of the mth layer to obtain the input data of the m+1th layer.

[0015] By processing the input data of the data processing layer to obtain the data to be sampled, and performing downsampling calculations on the data to be sampled to obtain the input data of the next layer, the channels of the input data can be increased and the resolution can be reduced, thereby achieving full extraction of defect features in the first image or the feature image obtained by processing the first image, thereby effectively detecting complex defects in the first image and facilitating accurate segmentation of defective areas.

[0016] In some embodiments, the upsampling calculations on the data to be sampled of the nth layer are performed n-1 times, including: splicing the input data of the kth layer with the data to be sampled in the downsampling calculation of the kth layer to obtain the spliced ​​data of the kth layer, where k is a positive integer greater than 1 and less than n; splicing the first intermediate data of the kth layer generated by the spliced ​​data with the second intermediate data of the kth layer generated by the first intermediate data of the kth layer to obtain the data to be sampled of the kth layer; and performing upsampling calculations on the data to be sampled of the kth layer to obtain the input data of the k-1th layer.

[0017] Upsampling can restore a feature map with pixel labels, creating a second image with defective areas labeled, enabling pixel-level defect segmentation of the first image. The output second image has the same resolution as the input first image, allowing the labeled defect areas to be accurately located within the first image, facilitating product quality control and adjustment. Furthermore, the upsampling calculation incorporates data from the downsampling process, supplementing image details and improving segmentation accuracy.

[0018] In some embodiments, the region segmentation model is trained by sample images of the product and target images corresponding to the sample images.

[0019] By training the region segmentation model using sample images and target images corresponding to the sample images, the region segmentation model can more accurately detect surface defects of the product to be inspected, thereby obtaining accurately segmented defect areas.

[0020] In some embodiments, the method further includes: acquiring an original sample picture and an original target picture corresponding to the original sample picture; and performing the same elastic transformation on the original sample picture and the original target picture to obtain the sample picture and the target picture.

[0021] By performing the same elastic transformation on the original sample image and the original target image, the database used to train the region segmentation model can be expanded, thereby improving the accuracy of the trained region segmentation model and facilitating the efficient and accurate detection of product surface defects. It can also, to a certain extent, resist the imaging effects of lens distortion, improving the robustness of the algorithm.

[0022] In some embodiments, the region segmentation model is trained by the sample image, the target image, the original sample image, and the original target image.

[0023] This can ensure that there is a sufficiently large amount of data during the training process of the region segmentation model, so that a high-precision detection result can be output during the process of detecting the first image using the trained region segmentation model.

[0024] In some embodiments, the product is a battery, and the first picture is a surface of the battery to be inspected.

[0025] In this way, surface defects of batteries can be detected efficiently and accurately during the battery production process, so that the battery production process can be adjusted in time to ensure the production quality of the battery.

[0026] In a second aspect, a device for detecting surface defects of a product is provided, comprising: a processing module, the processing module being used to obtain a first image of the product; the processing module being used to obtain a defective area of ​​the product based on the first image and a region segmentation model; wherein the region segmentation model comprises a plurality of data processing layers, the plurality of data processing layers being connected by performing sampling calculations on the data to be sampled, and the data to be sampled of at least one of the data processing layers is obtained by splicing a first intermediate data generated by the input data of the data processing layer with a second intermediate data generated by the first intermediate data.

[0027] In some embodiments, the processing module is used to segment the continuous area of ​​the product according to the first image and the area segmentation model, where the continuous area includes the defect area and the non-defect area.

[0028] In some embodiments, the processing module is configured to obtain a second image based on the first image and the region segmentation model, wherein the defect region is marked on the second image.

[0029] In some embodiments, the multiple data processing layers include n data processing layers, where n is a positive integer greater than 1; the processing module is used to perform n-1 downsampling calculations on the first image to obtain the input data of the nth layer; the processing module is used to splice the first intermediate data of the nth layer generated by the input data of the nth layer with the second intermediate data of the nth layer generated by the first intermediate data of the nth layer to obtain the data to be sampled of the nth layer; the processing module is used to perform n-1 upsampling calculations on the data to be sampled of the nth layer to obtain the second image.

[0030] In some embodiments, the processing module is used to splice the first intermediate data of the mth layer generated by the input data of the mth layer with the second intermediate data of the mth layer generated by the first intermediate data of the mth layer to obtain the data to be sampled of the mth layer, where m is a positive integer greater than 0 and less than n; the processing module is used to perform downsampling calculation on the data to be sampled of the mth layer to obtain the input data of the m+1th layer.

[0031] In some embodiments, the processing module is used to splice the input data of the kth layer with the data to be sampled in the downsampling calculation of the kth layer to obtain the spliced ​​data of the kth layer, where k is a positive integer greater than 1 and less than n; the processing module is used to splice the first intermediate data of the kth layer generated by the spliced ​​data with the second intermediate data of the kth layer generated by the first intermediate data of the kth layer to obtain the data to be sampled of the kth layer; the processing module is used to perform upsampling calculation on the data to be sampled of the kth layer to obtain the input data of the k-1th layer.

[0032] In some embodiments, the region segmentation model is trained by sample images of the product and target images corresponding to the sample images.

[0033] In some embodiments, the processing module is used to obtain an original sample image and an original target image corresponding to the original sample image; perform the same elastic transformation on the original sample image and the original target image to obtain the sample image and the target image.

[0034] In some embodiments, the region segmentation model is trained by the sample image, the target image, the original sample image, and the original target image.

[0035] In some embodiments, the product is a battery, and the first picture is a surface of the battery to be inspected.

[0036] In a third aspect, a device for detecting surface defects of a product is provided, comprising: a processor and a memory, wherein the memory stores instructions, and when the instructions are executed by the processor, the device executes the method described in any embodiment of the first aspect.

[0037] In a fourth aspect, an electronic device is provided, comprising: a device for detecting surface defects of a product as described in any embodiment of the second aspect above.

[0038] In a fifth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the method described in any embodiment of the first aspect is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the drawings without creative work.

[0040] FIG1 is a schematic diagram of a system architecture according to an embodiment of the present application.

[0041] FIG2 is a schematic flow chart of a method for detecting surface defects of a product provided in an embodiment of the present application.

[0042] FIG3 is a schematic diagram of the structure of a region segmentation model provided in an embodiment of the present application;

[0043] FIG4 is a schematic diagram of a processing method provided in an embodiment of the present application;

[0044] FIG5 is an example diagram of a first picture and a second picture provided in an embodiment of the present application;

[0045] FIG6 is a schematic diagram of a device for detecting surface defects of a product provided in an embodiment of the present application.

[0046] In the drawings, the drawings are not drawn to scale. DETAILED DESCRIPTION

[0047] The following detailed description of the embodiments of the present application is provided in conjunction with the accompanying drawings and examples. The following detailed description of the embodiments and the accompanying drawings are used to illustrate the principles of the present application, but are not intended to limit the scope of the present application, that is, the present application is not limited to the described embodiments.

[0048] In the description of this application, it should be noted that, unless otherwise specified, "multiple" means more than two; the terms "upper", "lower", "left", "right", "inside", "outside", etc., indicating directions or positional relationships, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as a limitation on this application. In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. "Vertical" is not strictly perpendicular, but is within the allowable error range. "Parallel" is not strictly parallel, but is within the allowable error range.

[0049] The directional words appearing in the following description are all directions shown in the figures, and do not limit the specific structure of this application. In the description of this application, it should also be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to the specific circumstances.

[0050] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0051] During the manufacturing process of industrial products, defects inevitably occur, impacting product quality. Therefore, defect detection is an essential process. Current defect detection methods often struggle to identify tiny surface defects. Defects with unclear boundaries and irregular shapes are also difficult to describe and extract using human-designed operators. Highly accurate algorithms often require complex network structures and require significant computational effort, making them inadequate for the demands of high-speed production cycles.

[0052] In view of this, the present application provides a method for detecting surface defects of products, which can achieve high-precision regional segmentation by segmenting defective areas in products through a regional segmentation model. At the same time, in the regional segmentation model of the present application, multiple data processing layers are connected through sampling calculations, and the data to be sampled of at least one data processing layer is obtained by splicing the first intermediate data generated by the input data of the data processing layer with the second intermediate data generated by the first intermediate data, thereby replacing the currently commonly used convolution calculation. This can reduce the amount of calculation and the memory usage of the model inference, and can achieve better results in efficiently and accurately segmenting defective areas.

[0053] The embodiments of this application can be applied, for example, to defect detection during battery production. Specifically, they can detect defects in weld seams during welding, weld marks produced when welding connecting members between tabs and electrode terminals, and surface defects produced during die-cutting processes. Furthermore, they can effectively detect contaminated areas produced during battery production. The embodiments of this application are described in detail below with reference to the accompanying drawings.

[0054] FIG1 illustrates a schematic diagram of a system architecture applicable to embodiments of the present application. In FIG1 , data acquisition device 160 is used to collect training data. After collecting the training data, data acquisition device 160 stores the training data in database 130. Training device 120 then trains target model / rule 101 based on the training data maintained in database 130.

[0055] The target model / rule 101 described above can be used to implement the weld mark detection method of the embodiment of the present application, and specifically can be a neural network. It should be noted that, in actual applications, the training data maintained in the database 130 does not necessarily come from data acquisition device 160, but may also be received from other devices. It should also be noted that the training device 120 does not necessarily train the target model / rule 101 entirely based on the training data maintained in database 130, but may also obtain training data from the cloud or other locations for model training. The above description should not be construed as limiting the embodiments of the present application.

[0056] The target model / rule 101 obtained through training with the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG1 . The execution device 110 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, etc., or a server or cloud as a host computer. In FIG1 , the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with external devices. The user can input data to the I / O interface 112 through the industrial camera 140. The input data can include, in the embodiment of the present application, a video to be processed or an image to be processed input by the industrial camera 140.

[0057] In some implementations, the industrial camera 140 and the execution device 110 may be the same device. For example, the industrial camera 140 and the execution device 110 may both be terminal devices.

[0058] In other embodiments, the industrial camera 140 may be a different device from the above-mentioned execution device 110. For example, the industrial camera 140 is a terminal device, and the execution device 110 is a cloud, server, or other device. The industrial camera 140 can interact with the execution device 310 through a communication network with any communication mechanism / communication standard. The communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof.

[0059] The computing module 111 of the execution device 110 is configured to process input data (e.g., an image to be processed) received by the I / O interface 112. While the computing module 111 of the execution device 110 is performing calculations and other related processing, the execution device 110 may access data, code, etc. in the data storage system 150 for the corresponding processing, and may also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 150.

[0060] Finally, the I / O interface 112 returns the processing results, such as the classification results of the weld marks, to the industrial camera 140 for providing to the user.

[0061] It is worth noting that Figure 1 is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 1, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 can also be placed in the execution device 110.

[0062] As shown in Figure 1, the target model / rule 101 is obtained through training according to the training device 120. The target model / rule 101 can be a neural network in the embodiment of the present application. Specifically, the neural network in the embodiment of the present application can be a CNN, a regional convolutional neural network (region CNN, RCNN), an accelerated regional convolutional neural network (faster RCNN) or other types of neural networks, etc., and the present application does not make specific limitations on this.

[0063] The following describes in detail the weld mark detection method 200 provided in this application in conjunction with Figure 2, which is a schematic flowchart of a method for detecting product surface defects provided in an embodiment of this application. Method 200 can be performed by a weld mark detection device, which can be the execution device 110 in Figure 1. For ease of illustration, the product in this embodiment of the application is a battery, and the execution device 110 is a host computer. Method 200 may include at least some of the following contents.

[0064] S210: Acquire the first picture of the product.

[0065] S220: Obtain a defective area of ​​the product according to the first image and the region segmentation model.

[0066] Among them, the region segmentation model includes multiple data processing layers, and the multiple data processing layers are connected by sampling calculations on the data to be sampled. The data to be sampled of at least one data processing layer is obtained by splicing the first intermediate data generated by the input data of the data processing layer and the second intermediate data generated by the first intermediate data.

[0067] The first image can be obtained by capturing a product during actual production using an image acquisition device such as an industrial camera, and may include, but is not limited to, the surface of the product to be inspected. For example, if a specific surface of a product needs to be inspected during a certain process, an industrial camera can be positioned above the surface to be inspected and capture the product as it passes through the camera to obtain a first image of the product. The industrial camera then transmits the captured first image of the product to a host computer, which analyzes the first image.

[0068] To analyze the defective area in the first image, the defective area must first be segmented. In the embodiment provided in this application, the defective area in the first image can be segmented based on the first image and the region segmentation model. The defective area can include surface contamination of the product during the production process, or poor weld marks generated in the welding area, such as weld porosity, weld undercut, weld cracks, and other welding defects.

[0069] The defective area may refer to an area after removing other parts of the first image, or may refer to an area clearly marked on the basis of the first image. It is understandable that the defective area obtained by segmentation can be clearly distinguished from other areas of the first image.

[0070] A region segmentation model refers to a model that segments regions in the first image. This model can be, for example, a neural network. Specifically, this model can be, for example, a U-Net network. The structure of the region segmentation model can be shown in Figure 3, comprising multiple data processing layers connected by sampling calculations. Sampling calculations include downsampling calculations, namely processing method 302 shown in Figure 3, and upsampling calculations, namely processing method 303 shown in Figure 3. Downsampling calculations can reduce the resolution of feature maps by increasing the number of channels in the feature image to increase the receptive field of the first image. Upsampling calculations gradually restore the channels and resolution of the feature maps obtained in the last layer to be consistent with the original input image, ultimately obtaining a segmented image with the same resolution as the original image. In one possible embodiment, at least one of processing methods 302 and 303 can be a convolution calculation. In another possible embodiment, at least one of processing methods 302 and 303 can generate a portion of intermediate data based on the data to be sampled, generate another portion of intermediate data based on the portion of intermediate data, and concatenate the two portions of intermediate data as the input data for the next layer.

[0071] During the upsampling calculation process, the data processing layer can fuse the unsampled data output by the same layer in the lower calculation, that is, the processing method 304 shown in Figure 3, so that the channels and resolution of the feature map obtained in the data processing process are gradually restored to be consistent with the original input image.

[0072] The structure of the region segmentation model shown in Figure 3 uses the data processing layer of the input first image as the first layer L1. During the upsampling process, the input data of the first layer L1 is the data obtained by upsampling the to-be-sampled data of the second layer L2. After the input data of the first layer L1 is processed by processing method 301, a feature map with pixel labels is output. In other words, each pixel in the resulting feature map has a label, and defects in the feature map can be segmented based on the label.

[0073] In one possible implementation, the data that has undergone a downsampling calculation can also be used as the input data of the first layer. In the upsampling calculation process, the output data of the first layer needs to be upsampled again, and after being processed by processing method 301, a feature map with pixel labels is output. The feature map is the final output result, and no sampling calculation is required.

[0074] When the data processing layer processes the input data of a layer, the input data can be processed using the processing method 301 shown in Figure 3. In one possible embodiment, processing method 301 can be a convolution calculation. In another possible embodiment, processing method 301 can be generating first intermediate data based on the input data of the data processing layer, generating second intermediate data based on the first intermediate data, and concatenating the first intermediate data and the second intermediate data to obtain the data to be sampled for the layer. The input data can be generated into the first intermediate data through a convolution calculation, and the first intermediate data can also be generated into the second intermediate data through a convolution calculation. It should be understood that in the embodiments provided herein, the convolution calculation can be replaced by a calculation method that generates the first intermediate data from the input data, then generates the second intermediate data from the first intermediate data, and concatenates the first intermediate data and the second intermediate data to obtain the output data. Within the same layer, input data can be processed multiple times using processing method 301. For example, in the first layer L1, the first image is processed once using processing method 301 to obtain first processed data, and the first processed data is processed again using processing method 301 to obtain the data to be sampled for the first layer. Each data processing layer in the multiple data processing layers can process the input data of the layer according to the same processing method, and different data processing layers in the multiple data processing layers can also process the input data according to different processing methods.

[0075] Before the final output is obtained, the output data obtained by each data processing layer is the unsampled data. After the sampling calculation, the unsampled data enters the next layer or the previous layer. Specifically, the unsampled data enters the next layer after the downsampling calculation, and enters the previous layer after the upsampling calculation.

[0076] In each data processing layer, the input data can be processed as shown in Figure 4. Taking one of the multiple data processing layers as an example, images 1 to 32 are the input data for that layer, and each image represents a feature map for one channel. Therefore, the input data shown in Figure 4 includes feature maps for 32 channels. Alternatively, images 1 to 32 can also be intermediate feature maps obtained by processing the original input data, such as intermediate feature maps obtained by performing a convolution calculation on the first image, where each image also represents a feature map for one channel. In the same layer, if the input data and the output target data have the same number of channels, the first intermediate data generated from the input data can have half the number of channels of the target data to be output. The second intermediate data generated from the first intermediate data can have the same number of channels as the first intermediate data, that is, half the number of channels of the target data. The first intermediate data and the second intermediate data are concatenated to obtain target data with the same number of channels as the input data. When processing data in the same layer, the target data is the data to be sampled. Taking Figure 4 as an example, specifically, pictures 1 to 32 are input data, then pictures 1' to 16', that is, the first intermediate data, can be generated based on pictures 1 to 32; then pictures 17' to 32', that is, the second intermediate data, can be generated based on pictures 1' to 16'; pictures 1' to 16' and pictures 17' to 32' are spliced ​​together, and the resulting pictures 1' to 32' are the target data output by this layer, which can also be called data to be sampled.

[0077] In the sampling calculation process of different layers, the sampled data can also be processed according to the processing method shown in Figure 4. Specifically, taking downsampling as an example, downsampling is a process of increasing the number of channels. In the process of generating the first intermediate data based on the data to be sampled, the number of channels of the first intermediate data is half of the number of channels of the target data to be output. For example, if the data to be sampled is a 32-channel feature map and the target data to be output is a 64-channel feature map, the first intermediate data is 32-channel data generated based on the 32-channel data to be sampled, and the second intermediate data is 32-channel data generated based on the 32-channel first intermediate data. By splicing the first intermediate data and the second intermediate data, the 64-channel target data can be output. In this case, the output target data is the input data of the next layer.

[0078] It should be understood that the picture numbers 1 to 32 in Figure 4 are only used to distinguish different pictures and are not used to limit the order and position of the pictures, nor to limit the number of pictures. The data processing algorithm shown in Figure 4 can be, for example, the Ghost Module in Ghost Net.

[0079] Segmenting the defective regions in the first image using the region segmentation model can improve the speed of defective region analysis. The output feature map, with pixel labels, enables high-precision segmentation. Processing the input data in the region segmentation model to obtain the data to be sampled or the input data for the next layer significantly reduces the computational effort required by the region segmentation model to analyze the first image, further improving the speed of segmenting defective regions in the first image. It also reduces the memory usage of the model inference and improves data processing efficiency.

[0080] According to some embodiments of the present application, optionally, step S220 may include: segmenting continuous regions of the product according to the first image and the region segmentation model, where the continuous regions include defective regions and non-defective regions.

[0081] Considering that the first image can be an actual photograph, when photographing the surface of the product to be inspected, all features of the entire surface to be inspected are captured. In other words, the first image may include not only defective areas on the surface to be inspected, but also some structural features of the product itself. The areas where these structural features are located are considered non-defective areas.

[0082] Taking battery production as an example, in one possible implementation, the surface to be inspected is the end cap surface of a battery. The first image may include areas such as the electrode terminals, pressure relief mechanism, and battery label. These areas have defined boundaries in the first image and are continuous regions that can be distinguished from other areas. When the region segmentation model is used to process the first image, it can segment these continuous regions, resulting in distinct continuous regions on the surface to be inspected.

[0083] In another possible implementation, the surface to be inspected includes electrode terminals and weld marks on the electrode terminals. The electrode terminals and the weld marks on the electrode terminals can be segmented by setting different parameters or operators.

[0084] After processing the first image, the region segmentation model generates a feature map with pixel labels. This means that each pixel in the final feature map has a label, and defects in the feature map can be segmented based on the labels. In one possible implementation, pixel labels are used only to distinguish different regions, with manual judgment of whether the labeled regions are defective or non-defective. In another possible implementation, the region segmentation model can directly identify a continuous region as defective or non-defective. Defective regions can then be labeled with one label, while non-defective regions can be labeled with another label.

[0085] When there are many product features in the first image, the region segmentation model can separate different continuous regions with higher accuracy, avoiding analyzing non-defective regions as defective regions, which is conducive to accurately judging product quality based on defective regions.

[0086] According to some embodiments of the present application, optionally, step S220 may include: obtaining a second image according to the first image and the region segmentation model, wherein a defective region is marked on the second image.

[0087] Inputting the first image into the region segmentation model produces a second image, an image with defective areas marked. As shown in Figure 5, (a) is the first image, or a portion of it, and (b) is the second image obtained by inputting (a) into the region segmentation model. As can be seen in (b), the second image clearly marks the black spots in the first image, representing the defective areas.

[0088] Similarly, (c) in Figure 5 shows the first image, or a portion of it, and (d) is the second image obtained by inputting (c) into the region segmentation model. As can be seen in (d), the second image clearly marks the dark areas in the first image, representing the defect areas. Furthermore, Figure 5 shows that the region segmentation model can also effectively segment subtle defects and those with unclear boundaries.

[0089] By outputting a second image with defective areas marked, the defective areas can be matched with the first image, and the position of the defective areas on the first image as well as the shape and size of the defective areas can be seen more intuitively, which is conducive to analyzing the defective areas on the product.

[0090] According to some embodiments of the present application, the multiple data processing layers optionally include n data processing layers, where n is a positive integer. Downsampling calculations are performed on the first image n-1 times to obtain input data for the nth layer; first intermediate data of the nth layer generated from the input data of the nth layer are concatenated with second intermediate data of the nth layer generated from the first intermediate data of the nth layer to obtain data to be sampled for the nth layer; and upsampling calculations are performed on the data to be sampled for the nth layer n-1 times to obtain the second image.

[0091] Taking Figure 3 as an example, Figure 3 shows n data processing layers L1 to Ln. In the first layer L1, the input first image is processed using processing method 301. The resulting data to be sampled undergoes a downsampling calculation once and serves as the input data for the second layer L2. The input data of the second layer L2 is processed using processing method 301. The resulting data to be sampled undergoes a second downsampling calculation and serves as the input data for the third layer L3. Similarly, by performing n-1 downsampling calculations on the first image, the input data for the nth layer Ln can be obtained.

[0092] The nth layer Ln is the last layer of multiple data processing layers in the region segmentation model. The input data of the nth layer Ln is processed in the processing method 301 to obtain the data to be sampled of the nth layer Ln, and the upsampling calculation is started.

[0093] By performing upsampling calculation on the data to be sampled in the nth layer, the input data of the n-1th layer can be obtained. Similarly, after n-1 upsampling calculations, the input data of the first layer L1 in the upsampling process can be obtained. After processing the input data, the second image can be obtained.

[0094] In Figure 3, processing method 301 is the processing performed on the input data of the corresponding layer, that is, the first intermediate data of the layer is generated based on the input data of the layer, the second intermediate data of the layer is generated based on the first intermediate data of the layer, and the two are spliced ​​together to obtain the data to be sampled for the layer. Figure 3 only shows the structure of the region segmentation model using the data processing layer of the input first image as the first layer L1. In one possible embodiment, data that has undergone a single downsampling calculation can also be used as the input data for the first layer. In this case, the first image is downsampled n times to obtain the input data of the nth layer; similarly, the n-layer data to be sampled is upsampled n times to obtain the second image.

[0095] By processing the first image through upsampling and downsampling calculations, more information about the first image can be obtained, providing better small object and object edge segmentation effects, and facilitating accurate segmentation of different regions in the first image. This can also prevent overfitting and reduce the amount of computation.

[0096] According to some embodiments of the present application, optionally, downsampling calculations are performed on the first image n-1 times, including: splicing the first intermediate data of the mth layer generated by the input data of the mth layer with the second intermediate data of the mth layer generated by the first intermediate data of the mth layer to obtain the data to be sampled of the mth layer, where m is a positive integer greater than 0 and less than n; downsampling calculations are performed on the data to be sampled of the mth layer to obtain the input data of the m+1th layer.

[0097] Performing n-1 downsampling calculations on the first image includes performing downsampling calculations on the data to be sampled at the mth layer, where the mth layer is one of the n data processing layers. Specifically, the mth layer among the n data processing layers obtains input data and processes the input data at the mth layer. Specifically, first intermediate data at the mth layer is generated based on the input data at the mth layer, and second intermediate data at the mth layer is generated based on the first intermediate data at the mth layer. These two data are then concatenated to obtain the data to be sampled at the mth layer. Downsampling calculations are performed on the data to be sampled at the mth layer to obtain input data at the m+1th layer. When m = 1, the input data at the mth layer can be the first image; when m ≠ 1, the input data at the mth layer can be obtained by downsampling the data to be sampled at the m-1th layer. In other words, during the downsampling process, the input data at each layer can be obtained and processed using the above method.

[0098] By processing the input data of the data processing layer to obtain the data to be sampled, and performing downsampling calculations on the data to be sampled to obtain the input data of the next layer, the channels of the input data can be increased and the resolution can be reduced, thereby achieving full extraction of defect features in the first image or the feature image obtained by processing the first image, thereby effectively detecting complex defects in the first image and facilitating accurate segmentation of defective areas.

[0099] According to some embodiments of the present application, optionally, n-1 upsampling calculations are performed on the data to be sampled of the nth layer, including splicing the input data of the kth layer with the data to be sampled in the downsampling calculation of the kth layer to obtain the spliced ​​data of the kth layer, where k is a positive integer greater than 1 and less than n; splicing the first intermediate data of the kth layer generated by the spliced ​​data with the second intermediate data of the kth layer generated by the first intermediate data of the kth layer to obtain the data to be sampled of the kth layer; and performing upsampling calculations on the data to be sampled of the kth layer to obtain the input data of the k-1th layer.

[0100] Performing n-1 upsampling calculations on the data to be sampled at the nth layer includes performing upsampling calculations on the data to be sampled at the kth layer, where the kth layer is one of the n data processing layers. Specifically, the input data of the kth layer can be obtained by sampling and calculating the data to be sampled at the k+1th layer. In order to restore the channels and resolution of the multi-channel and low-resolution feature maps obtained during the downsampling calculation to be consistent with the channels and resolution of the original input image, it is necessary to splice the input data of the kth layer with another part of the data, wherein the data used for splicing with the input data of the kth layer can be the data to be sampled obtained by the kth layer during the downsampling calculation. Specifically, the data to be sampled obtained by the kth layer during the downsampling calculation is used for downsampling calculations to obtain the input data of the k+1th layer on the one hand, and is used for splicing with the input data in the upsampling calculation process on the other hand. In other words, compared with the input data, the spliced ​​data of the kth layer can obtain more details, thereby realizing pixel-level defect area segmentation.

[0101] During the upsampling process, the spliced ​​data is processed to obtain the data to be sampled at the kth layer. That is, the first intermediate data at the kth layer is generated based on the spliced ​​data at the kth layer, and the second intermediate data at the kth layer is generated based on the first intermediate data at the kth layer. The two are spliced ​​together to obtain the data to be sampled at the kth layer. The upsampling calculation is performed on the data to be sampled at the kth layer to obtain the input data for the k-1th layer.

[0102] Considering that the first layer is the last layer in the upsampling calculation process, the sampled data obtained in this layer is the output data of the region segmentation model, so there is no need to perform upsampling calculation on the output data.

[0103] Considering that the nth layer is the first layer in the upsampling calculation process and the last layer in the n data processing layers, the input data of the nth layer is both the input data in the downsampling process and the input data in the upsampling process. The data to be sampled obtained in the downsampling process is also the data to be sampled in the upsampling process. Therefore, the input data of the nth layer can be directly processed to obtain the data to be sampled, and the upsampling calculation can be performed on the data to be sampled without the need to splice the input data again.

[0104] Upsampling can restore a feature map with pixel labels, creating a second image with defective areas labeled, enabling pixel-level defect segmentation of the first image. The output second image has the same resolution as the input first image, allowing the labeled defect areas to be accurately located within the first image, facilitating product quality control and adjustment. Furthermore, the upsampling calculation incorporates data from the downsampling process, supplementing image details and improving segmentation accuracy.

[0105] According to some embodiments of the present application, optionally, the region segmentation model is trained by sample images of the product and target images corresponding to the sample images.

[0106] Training a region segmentation model requires using a large number of sample images and target images corresponding to each sample image to adjust the model's parameters. A sample image is the first image with known region segmentation results, while a target image is the corresponding image with the regions labeled on the sample image.

[0107] During the training of the region segmentation model, a sample image can be input into the region segmentation model, and the region segmentation model analyzes and processes the sample image to obtain a reference area. The reference area is compared with the area in the target image, and the region segmentation model is adjusted, for example, by adjusting the parameters or operators in the region segmentation model so that the reference area can match the area in the target image. In one possible embodiment, the region segmentation model outputs an image with defective areas marked in the image. During the training process, the region segmentation model analyzes and processes the sample image to obtain a reference image, and compares the reference image with the target image to adjust the region segmentation model.

[0108] Through training with a large number of sample images and target images, when a first image is input into the region segmentation model, the defect area output by the region segmentation model can match the defect area actually represented in the first image. That is, within a certain error range, the defect area output by the region segmentation model can be considered accurate.

[0109] By training the region segmentation model using sample images and target images corresponding to the sample images, the region segmentation model can more accurately detect surface defects of the product to be inspected, thereby obtaining accurately segmented defect areas.

[0110] According to some embodiments of the present application, optionally, method 200 further includes: obtaining an original sample image and an original target image corresponding to the original sample image; and performing the same elastic transformation on the original sample image and the original target image to obtain a sample image and a target image.

[0111] Considering that products with defective areas are extremely rare in industrial production, the sample and target images available for training the region segmentation model are also relatively few. To ensure the accuracy of the trained region segmentation model, the original sample and target images can be transformed to generate a variety of corresponding sample and target images for training the region segmentation model.

[0112] Specifically, the same elastic transformation can be performed on the original sample image and the original target image. Elastic transformation refers to applying a random change to each pixel in the image using a specific algorithm. For example, pixels can be moved in random directions and distances within a certain range. Another example is the use of convolution to generate the transformed image.

[0113] By performing the same elastic transformation on the original sample image and the original target image, the database used to train the region segmentation model can be expanded, thereby improving the accuracy of the trained region segmentation model, which is conducive to the efficient and accurate detection of defects on the product surface.

[0114] According to some embodiments of the present application, optionally, the region segmentation model is trained by sample images, target images, original sample images, and original target images.

[0115] To ensure sufficient samples for training the region segmentation model, the original sample image, the original target image, and the elastically transformed image of the two can all be used to train the region segmentation model. During the training process, the parameters of the region segmentation model can be adjusted based on the sample image, the target image, the original sample image, and the original target image.

[0116] This ensures a sufficiently large amount of data during the training process of the region segmentation model, allowing for highly accurate detection results when the trained region segmentation model is used to detect the first image. It also mitigates the effects of lens distortion to a certain extent, improving the robustness of the algorithm.

[0117] According to some embodiments of the present application, optionally, the product is a battery, and the first image is a surface of the battery to be inspected.

[0118] That is, the first image including the surface to be inspected of the battery is input into the region segmentation model, so that the defective region on the surface to be inspected of the battery can be segmented out.

[0119] In this way, surface defects of batteries can be detected efficiently and accurately during the battery production process, so that the battery production process can be adjusted in time to ensure the production quality of the battery.

[0120] The present application also provides a device for detecting surface defects of products, comprising a processing module, which may be a processor. The processing module is configured to obtain a first image of the product; the processing module is configured to obtain a defective region of the product based on the first image and a region segmentation model; wherein the region segmentation model includes multiple data processing layers, the multiple data processing layers being connected by performing sampling calculations on data to be sampled, and the data to be sampled of at least one data processing layer is obtained by concatenating first intermediate data generated by input data of the data processing layer with second intermediate data generated by the first intermediate data.

[0121] According to some embodiments of the present application, optionally, the processing module is used to segment continuous regions of the product based on the first image and the region segmentation model, where the continuous regions include defective regions and non-defective regions.

[0122] According to some embodiments of the present application, optionally, the processing module is used to obtain a second image based on the first image and the region segmentation model, and the defective region is marked on the second image.

[0123] According to some embodiments of the present application, optionally, the multiple data processing layers include n data processing layers, where n is a positive integer greater than 1; the processing module is used to perform n-1 downsampling calculations on the first image to obtain input data of the nth layer; the processing module is used to splice the first intermediate data of the nth layer generated by the input data of the nth layer with the second intermediate data of the nth layer generated by the first intermediate data of the nth layer to obtain data to be sampled of the nth layer; the processing module is used to perform n-1 upsampling calculations on the data to be sampled of the nth layer to obtain a second image.

[0124] According to some embodiments of the present application, optionally, the processing module is used to splice the first intermediate data of the mth layer generated by the input data of the mth layer with the second intermediate data of the mth layer generated by the first intermediate data of the mth layer to obtain the data to be sampled of the mth layer, where m is a positive integer greater than 0 and less than n; the processing module is used to perform downsampling calculation on the data to be sampled of the mth layer to obtain the input data of the m+1th layer.

[0125] According to some embodiments of the present application, optionally, the processing module is used to splice the input data of the kth layer with the data to be sampled in the downsampling calculation of the kth layer to obtain the spliced ​​data of the kth layer, where k is a positive integer greater than 1 and less than n; the processing module is used to splice the first intermediate data of the kth layer generated by the spliced ​​data with the second intermediate data of the kth layer generated by the first intermediate data of the kth layer to obtain the data to be sampled of the kth layer; the processing module is used to perform upsampling calculation on the data to be sampled of the kth layer to obtain the input data of the k-1th layer.

[0126] According to some embodiments of the present application, optionally, the region segmentation model is trained by sample images of the product and target images corresponding to the sample images.

[0127] According to some embodiments of the present application, optionally, the processing module is used to obtain an original sample image and an original target image corresponding to the original sample image; perform the same elastic transformation on the original sample image and the original target image to obtain a sample image and a target image.

[0128] According to some embodiments of the present application, optionally, the region segmentation model is trained by sample images, target images, original sample images, and original target images.

[0129] According to some embodiments of the present application, optionally, the product is a battery, and the first image is a surface of the battery to be inspected.

[0130] The present application also provides a device 600 for detecting surface defects of products, as shown in FIG6 , comprising a processor 601 and a memory 602 , wherein the memory 602 stores instructions, and when the instructions are executed by the processor 601 , the device 600 executes the method described in any of the above embodiments.

[0131] The present application also provides an electronic device comprising the device for detecting product surface defects as described in any of the above embodiments.

[0132] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any of the above embodiments is executed.

[0133] Although the present application has been described with reference to preferred embodiments, various modifications may be made thereto and components may be substituted with equivalents without departing from the scope of the present application. In particular, the various technical features described in the various embodiments may be combined in any manner as long as there are no structural conflicts. The present application is not limited to the specific embodiments disclosed herein, but encompasses all technical solutions within the scope of the claims.

Claims

1. A method for detecting surface defects of a product, characterized in that: include: Obtaining a first image of the product; Obtaining a defective area of ​​the product according to the first image and the region segmentation model; In which, the region segmentation model includes multiple data processing layers, and the multiple data processing layers are connected by sampling calculations on the data to be sampled. The data to be sampled of at least one data processing layer is obtained by splicing the first intermediate data generated by the input data of the data processing layer and the second intermediate data generated by the first intermediate data.

2. The method according to claim 1, characterized in that The step of segmenting the defective area of ​​the product according to the first image and the region segmentation model includes: The continuous regions of the product are segmented according to the first image and the region segmentation model, where the continuous regions include the defective region and the non-defective region.

3. The method according to claim 1 or 2, characterized in that The step of segmenting the defective area of ​​the product according to the first image and the region segmentation model includes: A second image is obtained according to the first image and the region segmentation model, and the defect region is marked on the second image.

4. The method according to claim 3, characterized in that The plurality of data processing layers include n data processing layers, where n is a positive integer greater than 1; The obtaining of the second picture according to the first picture and the region segmentation model includes: Perform n-1 downsampling calculations on the first image to obtain input data for the nth layer; splicing the first intermediate data of the nth layer generated by the input data of the nth layer and the second intermediate data of the nth layer generated by the first intermediate data of the nth layer to obtain the data to be sampled of the nth layer; Perform n-1 upsampling calculations on the data to be sampled in the n-th layer to obtain the second picture.

5. The method according to claim 4, characterized in that The performing downsampling calculations on the first image n-1 times includes: splicing the first intermediate data of the mth layer generated by the input data of the mth layer and the second intermediate data of the mth layer generated by the first intermediate data of the mth layer to obtain the data to be sampled of the mth layer, where m is a positive integer greater than 0 and less than n; Downsampling calculation is performed on the data to be sampled in the m-th layer to obtain input data in the m+1-th layer.

6. The method according to claim 4 or 5, characterized in that The performing n-1 upsampling calculations on the to-be-sampled data of the n-th layer includes: splicing the input data of the kth layer with the data to be sampled in the downsampling calculation of the kth layer to obtain the spliced ​​data of the kth layer, where k is a positive integer greater than 1 and less than n; Splicing the first intermediate data of the kth layer generated by the spliced ​​data with the second intermediate data of the kth layer generated by the first intermediate data of the kth layer to obtain the data to be sampled of the kth layer; Perform upsampling calculation on the data to be sampled in the kth layer to obtain the input data of the k-1th layer.

7. The method according to any one of claims 1 to 6, characterized in that The region segmentation model is trained by using sample images of the product and target images corresponding to the sample images.

8. The method according to claim 7, characterized in that The method further comprises: Obtaining an original sample image and an original target image corresponding to the original sample image; Performing the same elastic transformation on the original sample image and the original target image to obtain the sample image and the target image.

9. The method according to claim 8, characterized in that The region segmentation model is trained by the sample image, the target image, the original sample image, and the original target image.

10. The method according to any one of claims 1 to 9, characterized in that The product is a battery, and the first picture is a surface of the battery to be inspected.

11. A device for detecting surface defects of products, characterized in that: include: A processor and a memory, wherein the memory stores instructions, and when the instructions are executed by the processor, the device performs the method according to any one of claims 1 to 10.

12. An electronic device, characterized in that: include: The device for detecting surface defects of a product as claimed in claim 11. 13 . A computer-readable storage medium storing a computer program, wherein the computer program executes the method according to claim 1 when the computer program is executed.

Citation Information

Patent Citations

  • Bearing surface deformation and character mixed defect image detection method

    CN112001396A

  • Product surface defect detection method and system based on semantic segmentation

    CN112288741A

  • PCB surface defect detection device and method

    CN112819756A

  • Water-cooled wall surface defect video identification method based on fast segmentation convolutional neural network

    CN113192018A

  • Mobile phone screen defect visual detection method and system

    CN114549416A