A defect detection method and apparatus
Patent Information
- Application Number
- CN202310324012.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-03-29
AI Technical Summary
[0002]当前,相关技术中的缺陷检测方法只能够快速检测出产品表面较大的缺陷,但一直无法快速且准确的对产品表面的微小缺陷进行检测,尤其是对于锂电池等较为精细的产品
[0060]本申请实施例提供的缺陷检测方法及装置,对待检测对象对应的待检测图像进行特征提取,得到至少一个待测区域,确定每一待测区域为待检测对象缺陷的置信度,对置信度满足修正条件的待测区域对应的置信度进行修正,得到修正置信度,根据修正后的修正置信度和原始置信度在多个待测区域中确定目标缺陷区域,以确定待检测对象中存在的缺陷。如此,本申请实施例对待测区域中满足修正条件的置信度进行修正,通过修正后的置信度确定待检测对象中的缺陷,增强了对待检测对象表面低置信度的缺陷进行检测的能力,能够充分提取待检测对象表面的微小缺陷,提高了缺陷检测的精确度和准确度。
Smart Images

Figure CN116385387B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and to, but is not limited to, a defect detection method and apparatus. Background Technology
[0002] Currently, defect detection methods in related technologies can only quickly detect larger defects on the product surface, but they have not been able to quickly and accurately detect tiny defects on the product surface, especially for more delicate products such as lithium batteries.
[0003] Since surface defects in products such as lithium batteries are mostly small, rapid detection of minute manufacturing defects on product surfaces has always been a pressing issue in machine vision technology. Summary of the Invention
[0004] This application provides a defect detection method and apparatus.
[0005] The technical solution of this application embodiment is implemented as follows:
[0006] This application provides a defect detection method, the method comprising:
[0007] Acquire the image to be detected, which is the image corresponding to the object to be detected;
[0008] Feature extraction is performed on the image to be detected to obtain at least one region to be detected in the image to be detected;
[0009] The confidence level of each of the test regions is obtained, and the confidence level is used to characterize the probability that the test region is a defect of the object to be detected;
[0010] Based on the confidence level of each test region, the confidence levels of test regions that meet the correction conditions are corrected to obtain the corrected confidence levels.
[0011] Based on the corrected confidence level and the confidence level of each test region, a target defect region is determined in at least one test region of the image to be detected, so as to detect defects present in the object to be detected.
[0012] In some embodiments, the step of correcting the confidence levels of test regions that meet the correction conditions based on the confidence level of each test region to obtain the corrected confidence level includes:
[0013] Obtain the classification threshold;
[0014] In the at least one region to be tested, the region to be tested with a confidence level less than the classification threshold is determined as the first region to be tested;
[0015] The confidence level of the first test region is inverted to obtain the corrected confidence level of the first test region.
[0016] In some embodiments, determining the target defect region in the at least one region to be tested in the image to be detected based on the corrected confidence level and the confidence level of each region to be tested includes:
[0017] In the at least one test region, the test region with a confidence level greater than the classification threshold is determined as the second test region;
[0018] Based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence threshold, a target defect region is determined in at least one test region of the image to be detected.
[0019] In some embodiments, the confidence threshold includes a first confidence threshold and a second confidence threshold, wherein the first confidence threshold is less than the second confidence threshold;
[0020] The step of determining the target defect region in the at least one test region of the image to be detected based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence threshold includes:
[0021] The first test region with a corrected confidence level greater than the first confidence level threshold and less than the second confidence level threshold, and the second test region with a confidence level greater than the first confidence level threshold and less than the second confidence level threshold in the second test region are determined as the undetermined defect regions of the image to be detected.
[0022] The first test region with a corrected confidence level greater than the second confidence level threshold, and the second test region with a corrected confidence level greater than the second confidence level threshold, are determined as the target defect regions of the image to be detected.
[0023] In some embodiments, each region to be tested consists of at least one pixel.
[0024] Obtaining the confidence level of each of the regions to be tested includes:
[0025] Pixel features are extracted for each region to be tested to determine the number of pixels in each region and the pixel information of each pixel.
[0026] The pixel information of each pixel is normalized to obtain the pixel confidence score of each pixel;
[0027] The confidence level of each test region is determined based on the number of pixels in each test region and the pixel confidence level of each pixel.
[0028] In some embodiments, the method further includes:
[0029] The area of each region to be tested is determined based on the number of pixels in each region to be tested.
[0030] Correspondingly, determining the target defect region in the at least one region to be tested in the image to be detected further includes:
[0031] The area to be tested that is larger than the area threshold is identified as the target defect area.
[0032] In some embodiments, the step of extracting features from the image to be detected to obtain at least one region to be detected in the image to be detected includes:
[0033] Gray-scale features are extracted from each pixel of the image to be detected to obtain gray-scale feature information of each pixel.
[0034] Based on the grayscale feature information of each pixel, at least one region to be tested is determined on the image to be detected.
[0035] In some embodiments, the step of extracting features from the image to be detected to obtain at least one region to be detected in the image to be detected includes:
[0036] The image to be detected is subjected to feature compression to obtain a downsampled image;
[0037] The downsampled feature map is augmented to obtain the augmented feature map.
[0038] Based on channel attention and spatial attention mechanisms, feature sampling is performed on the downsampled feature map to obtain the sampled feature map;
[0039] The sampled feature map and the enhanced feature map are concatenated to obtain a concatenated feature map;
[0040] The spliced feature map is subjected to noise reduction processing to obtain a noise-reduced feature map;
[0041] Feature extraction is performed on the denoised feature map to obtain at least one region to be tested.
[0042] In some embodiments, the method is implemented using a defect detection model; wherein the defect detection model is trained in the following manner:
[0043] The acquired pre-trained images are preprocessed to obtain sample data, which includes the sample image to be detected corresponding to the sample object to be detected and the defect region corresponding to the sample image to be detected.
[0044] The sample image to be detected is input into the defect detection model;
[0045] The feature extraction layer of the defect detection model is used to extract features from the sample image to be detected, thereby obtaining at least one sample region to be detected in the sample image to be detected.
[0046] The confidence level of each sample region to be tested is obtained through the confidence calculation layer of the defect detection model.
[0047] Through the confidence correction layer of the defect detection model, based on the sample confidence of each sample test area, the sample confidence of the sample test area that meets the correction condition is corrected to obtain the sample corrected confidence.
[0048] The defect detection layer of the defect detection model determines the target defect region of the sample in the at least one sample test region of the sample test image based on the sample correction confidence and the sample confidence of each sample test region.
[0049] The sample target defect region and the defect region are input into a preset loss model to obtain the loss result;
[0050] Based on the loss result, the model parameters in the feature extraction layer, the confidence calculation layer, the confidence correction layer, and the defect detection layer are corrected to obtain the trained defect detection model.
[0051] This application provides a defect detection device, the device comprising:
[0052] The acquisition module is used to acquire the image to be detected, wherein the image to be detected is the image corresponding to the object to be detected;
[0053] The feature extraction module is used to extract features from the image to be detected to obtain at least one region to be detected in the image to be detected.
[0054] The module is used to obtain the confidence level of each of the regions to be tested, wherein the confidence level is used to characterize the probability that the region to be tested is a defect of the object to be detected;
[0055] The correction module is used to correct the confidence level of each test region based on the confidence level of the test region, and to obtain the corrected confidence level.
[0056] A determination module is configured to determine a target defect region in at least one test region of the image to be detected based on the corrected confidence level and the confidence level of each test region, so as to detect defects present in the object to be detected.
[0057] This application provides a defect detection device, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements the defect detection method provided in this application.
[0058] This application provides a computer-readable storage medium storing executable instructions thereon, which, when executed by a processor, implement the defect detection method provided in this application.
[0059] This application provides a computer program product, which includes executable instructions stored in a computer-readable storage medium. When the processor of a defect detection device reads the executable instructions from the computer-readable storage medium and executes the executable instructions, the defect detection method provided in this application is implemented.
[0060] The defect detection method and apparatus provided in this application extract features from the image to be inspected corresponding to the object to be inspected, obtaining at least one region to be inspected. The confidence level of each region to be inspected is determined as a defect in the object to be inspected. The confidence levels of regions to be inspected that meet correction conditions are corrected to obtain corrected confidence levels. Based on the corrected confidence levels and the original confidence levels, target defect regions are determined from multiple regions to be inspected, thereby identifying defects present in the object to be inspected. Thus, this application corrects the confidence levels in regions to be inspected that meet correction conditions, and determines defects in the object to be inspected based on the corrected confidence levels. This enhances the ability to detect low-confidence defects on the surface of the object to be inspected, fully extracts minute defects on the surface of the object to be inspected, and improves the accuracy and precision of defect detection. Attached Figure Description
[0061] Figure 1 This is a schematic diagram illustrating an application scenario of the defect detection method provided in the embodiments of this application;
[0062] Figure 2 This is an optional flowchart illustrating the defect detection method provided in the embodiments of this application;
[0063] Figure 3 This is a schematic diagram of the region to be tested on the image to be tested provided in the embodiments of this application;
[0064] Figure 4 This is a schematic diagram of the binarized image corresponding to the region to be detected on the image to be detected provided in the embodiments of this application;
[0065] Figure 5 This is a schematic diagram of the feature enhancement network structure provided in the embodiments of this application;
[0066] Figure 6This is an optional flowchart illustrating the defect detection method provided in the embodiments of this application;
[0067] Figure 7 This is a schematic diagram illustrating the implementation process of the training method for the defect detection model provided in this application embodiment;
[0068] Figure 8 This is an optional flowchart illustrating the defect detection method provided in the embodiments of this application;
[0069] Figure 9 This is a schematic diagram of the structure of the segmentation algorithm network provided in the embodiments of this application;
[0070] Figure 10 This is a schematic diagram of the network structure of the feature enhancement module provided in the embodiments of this application;
[0071] Figure 11 This is a schematic diagram of the network structure of the adaptive low-confidence enhancement module provided in the embodiments of this application;
[0072] Figure 12 This is a schematic diagram of the detected defects provided in the embodiments of this application;
[0073] Figure 13 This is a schematic diagram of the composition structure of the defect detection device provided in the embodiments of this application;
[0074] Figure 14 This is a schematic diagram of the composition structure of the defect detection equipment provided in the embodiments of this application. Detailed Implementation
[0075] To more clearly illustrate the purpose, technical solutions, and advantages of the embodiments of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be understood that the following description of the embodiments is intended to explain and illustrate the overall concept of the embodiments of this application, and should not be construed as a limitation of the embodiments of this application. In the specification and drawings, the same or similar reference numerals refer to the same or similar parts or components. For clarity, the drawings are not necessarily drawn to scale, and some well-known parts and structures may be omitted from the drawings.
[0076] In some embodiments, unless otherwise defined, the technical or scientific terms used in the embodiments of this application shall have the ordinary meaning understood by one of ordinary skill in the art to which the embodiments of this application pertain. The terms "first," "second," and similar terms used in the embodiments of this application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. The word "a" or "an" does not exclude multiple components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," "right," "top," or "bottom" are used only to indicate relative positional relationships, and these relative positional relationships may change accordingly when the absolute position of the described object changes. When an element such as a layer, film, region, or substrate is referred to as being "above" or "below" another element, the element may be "directly" located "above" or "below" the other element, or there may be intermediate elements present.
[0077] In related technologies, batteries are used in various electronic products, such as mobile phones, computers, and new energy vehicles. However, using batteries with surface defects in these products can lead to serious consequences, such as mobile phone explosions and spontaneous combustion of electric vehicle batteries. Therefore, screening the surface quality of batteries during the manufacturing process is crucial, as it concerns people's lives and property safety.
[0078] The methods for detecting surface defects in batteries typically involve using existing open-source segmentation algorithms. However, these algorithms only learn from high-confidence features, neglecting low-confidence features of small defects. This results in the inability to detect very subtle surface defects in lithium batteries, making them unsuitable for practical quality inspection. Alternatively, commercial software from various companies can be used for detection. However, commercial software is expensive, and each purchase can only be used on one testing device, preventing the "one-to-many" reuse of purchased software and hindering its large-scale application in practical projects. Another method involves manual visual inspection under a microscope. However, this mechanized screening process leads to worker fatigue, low efficiency, and subjective biases that can cause missed defects. Furthermore, prolonged periods of working with the head down can severely damage the worker's cervical spine.
[0079] To address the problems existing in related technologies, this application provides a defect detection method. The method involves extracting features from an image corresponding to an object to be detected, obtaining at least one test region, determining the confidence level of each test region as a defect in the object, correcting the confidence levels of test regions that meet correction conditions to obtain corrected confidence levels, and determining target defect regions among multiple test regions based on the corrected confidence levels and the original confidence levels to identify defects present in the object. Thus, this application corrects the confidence levels in test regions that meet correction conditions, and determines defects in the object using the corrected confidence levels. This enhances the ability to detect low-confidence defects on the surface of the object, fully extracts minute defects from the surface of the object, and improves the accuracy and precision of defect detection.
[0080] The defect detection method provided in this application can be executed by electronic devices such as defect detection equipment. These electronic devices can be various types of terminals, including laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or they can be implemented as servers. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0081] The following will describe an exemplary application of the defect detection equipment as a server. The technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings.
[0082] Figure 1This is a schematic diagram illustrating an application scenario of the defect detection method provided in this application embodiment. The defect detection system 10 provided in this application embodiment includes a terminal 100, a network 200, and a server 300. The network 200 can be a wide area network (WAN), a local area network (LAN), or a combination of both. The server 300 and the defect detection device can be physically separate or integrated. During defect detection, the server 300 can use the method provided in this application embodiment to acquire the image to be detected in the terminal 100 through the network 200. The image to be detected is the image corresponding to the object to be detected. Feature extraction is performed on the image to be detected to obtain at least one test region in the image to be detected. The confidence level of each test region is obtained, and based on the confidence level of each test region, the confidence level corresponding to the test region whose confidence level meets the correction condition is corrected. According to the corrected confidence level and the confidence level of each test region, a target defect region is determined in at least one test region of the image to be detected. The location and other information of the target defect region on the image are sent to the terminal 100 and displayed on the display interface 100-1 of the terminal 100 to determine the defects present in the object to be detected.
[0083] See Figure 2 , Figure 2 This is an optional flowchart illustrating the defect detection method provided in this application embodiment. The defect detection method provided in this application embodiment can be implemented through steps S201 to S205:
[0084] Step S201: Obtain the image to be detected, wherein the image to be detected is the image corresponding to the object to be detected.
[0085] Here, the object to be inspected refers to the object that needs to be inspected for defects, such as a lithium battery. The image to be inspected refers to the surface image of the lithium battery.
[0086] In some embodiments, obtaining a surface image may involve first acquiring an image of the lithium battery using an industrial camera, then using a localization algorithm to obtain the region of interest (ROI) of the lithium battery, and finally cropping the region corresponding to the ROI to obtain the image to be detected.
[0087] Step S202: Perform feature extraction on the image to be detected to obtain at least one region to be detected in the image to be detected.
[0088] In some embodiments, the region to be tested refers to an abnormal region obtained after feature extraction of the image to be detected, such as cracks, scratches, or other abnormal regions on the surface of the object to be detected. Figure 3 This is a schematic diagram of the region to be detected on the image to be detected provided in the embodiments of this application, such as... Figure 3As shown, the enlarged circled areas in the three sub-images a, b, and c in the figure represent the areas to be tested on the image to be detected.
[0089] In some embodiments, determining the region to be tested on the image to be detected can be done by extracting features from the image to be detected to obtain the surface texture of the object to be detected, and then determining the region whose texture is different from that of the object to be detected as the region to be tested based on the surface texture of the object to be detected; alternatively, it can be done by extracting grayscale features from the image to be detected and determining the region to be tested based on the grayscale features, as shown in steps S2021 to S2022:
[0090] Step S2021: Extract grayscale features from each pixel of the image to be detected to obtain grayscale feature information of each pixel.
[0091] In some embodiments, texture features are characteristics of the object's surface and sometimes cannot fully reflect the essential attributes. Therefore, in the feature extraction process of this application, in addition to extracting texture features, grayscale feature information of each pixel in the image to be detected can also be extracted. Here, grayscale feature information can be the grayscale value of each pixel.
[0092] Step S2022: Determine at least one region to be tested on the image to be detected based on the grayscale feature information of each pixel.
[0093] In this embodiment, after obtaining the grayscale value of each pixel in the image to be detected, the region to be tested can be determined based on the distribution of grayscale values of the pixels in the image. For example, based on the difference in grayscale values between adjacent pixels, a region with a large difference in grayscale value from its adjacent regions can be determined as the region to be tested. For example, if the average grayscale value of the image to be detected is 50, and there is a region where all grayscale values are above 200, that region can be determined as the region to be tested in the image.
[0094] In some embodiments, the image to be detected can also be converted into a binarized image, such as... Figure 4 As shown, Figure 4 This is a schematic diagram of the binarized image corresponding to the region to be tested on the image to be detected provided in the embodiments of this application. The image is a binarized image corresponding to the image to be detected, and the area in the circle is the magnified region to be tested.
[0095] In some embodiments, feature extraction can also be performed using a feature extraction network to obtain the region to be tested, as shown in steps S2023 to S2028:
[0096] Step S2023: Perform feature compression on the image to be detected to obtain a downsampled image.
[0097] In some embodiments, feature compression of the image to be detected may refer to downsampling the image to be detected, in order to reduce the amount of computation, prevent overfitting, and enable the convolution kernel to learn more global information in the subsequent convolution process.
[0098] Step S2024: Perform feature enhancement on the downsampled feature map to obtain the enhanced feature map.
[0099] In some embodiments, feature enhancement of the downsampled feature map can be achieved through a feature enhancement network. Figure 5 This is a schematic diagram of the feature enhancement network structure provided in the embodiments of this application, such as... Figure 5 As shown, the feature enhancement network includes at least a channel attention module 501, a spatial attention module 502, a first convolutional module 503, and a second convolutional module 504. The channel attention module 501 guides the feature enhancement network to learn the features of the foreground target (i.e., the region to be tested), the spatial attention module 502 learns the position of the foreground target, and multiple residual connections enrich the semantic features of the final output enhanced feature map, allowing the surface features of small targets (i.e., small-area regions to be tested) to be fully expressed.
[0100] In this embodiment, based on the channel attention mechanism of the channel attention module 501, the importance (weight) of each channel in the downsampled image can be calculated, i.e., which channels contain key information about whether a defect exists, thus obtaining a first image. The first image is multiplied by the downsampled image, and based on the spatial attention mechanism of the spatial attention module 502, the location where the key information is most concentrated in the multiplied image is determined, thus identifying the densely concentrated area as the location of the region to be tested, resulting in a second image. The second image is then multiplied by the previously multiplied image, and this multiplied image is added to the downsampled image. The added image is then convolved by the first convolution module 503, which can be a convolutional layer with a 1*1 kernel. The first convolution module 503 enables information interaction between different channels in the added image, resulting in a third image. Simultaneously, the downsampled image is convolved by the second convolution module 504, which can also be a convolutional layer with a 1*1 kernel, resulting in a fourth image. Finally, the third image and the fourth image are added to obtain a feature enhancement map.
[0101] Step S2025: Based on the channel attention mechanism and the spatial attention mechanism, perform feature sampling on the downsampled feature map to obtain the sampled feature map.
[0102] In some embodiments, the key information on whether the edges and representations of abnormal regions (i.e., regions to be tested) in the downsampled feature map can be extracted based on channel attention and spatial attention mechanisms to obtain the sampled feature map.
[0103] Step S2026: The sampled feature map and the enhanced feature map are spliced together to obtain a spliced feature map.
[0104] In some embodiments, the concatenation of the sampled feature map and the enhanced feature map can be performed by concatenating the number of channels, which increases the dimension of the image without increasing the feature information in each dimension, resulting in a concatenated feature map.
[0105] Step S2027: Perform noise reduction processing on the spliced feature map to obtain a noise-reduced feature map.
[0106] In some embodiments, noise suppression can be performed on the regions outside the detected abnormal regions in the stitched feature map through channel attention and spatial attention, that is, noise reduction processing is performed on the background regions outside the abnormal regions to obtain a noise-reduced feature map.
[0107] Step S2028: Extract features from the noise reduction feature map to obtain at least one region to be tested.
[0108] In some embodiments, features can be extracted from the denoised feature map using convolutional layers to obtain at least one region to be tested on the image to be detected. Here, the region to be tested can be obtained based on edge information obtained from feature extraction and key information representing whether it is a defect.
[0109] Step S203: Obtain the confidence level of each of the regions to be tested, wherein the confidence level is used to characterize the probability that the region to be tested is a defect of the object to be detected.
[0110] In some embodiments, the confidence level is used to characterize the probability that the test area is a defect of the object to be inspected, that is, the probability that the test area is a surface defect of the object to be inspected. Here, the confidence level of each test area can be determined based on the feature information of the test area. Based on the feature information of each test area, the probability weight of each test area being a defect is calculated, and the probability weight is normalized to obtain the confidence level of each test area. The value of the confidence level takes a range from 0 to 1.
[0111] In some embodiments, feature extraction can be performed on each pixel in the test area to obtain feature information such as texture, color and spatial relationship corresponding to each pixel. Based on this feature information, the probability weight of each pixel being a defect can be determined. The probability weights of all pixels are normalized to obtain the pixel confidence of each pixel. Then, the pixel confidence of all pixels in the test area is averaged to obtain the confidence of each test area.
[0112] Step S204: Based on the confidence level of each test region, correct the confidence level of the test regions whose confidence levels meet the correction conditions to obtain the corrected confidence level.
[0113] In some embodiments, during feature extraction, downsampling and other operations can reduce image resolution, causing smaller defects to lose more feature information and lowering the confidence level of minor defects. Therefore, after determining the confidence level of each test region, this embodiment can correct the confidence levels that meet the correction conditions. For example, it can correct the confidence levels that are less than a confidence threshold, or it can combine the area of each test region to correct the confidence levels that are less than a preset area and less than a confidence threshold, ultimately obtaining the corrected confidence level.
[0114] In some embodiments, correcting the confidence level can refer to inverting the confidence level, i.e., corrected confidence level = (1 - confidence level); or it can refer to multiplying the confidence level to be corrected by a correction weight (for example, the correction weight can be 2), so that the corrected confidence level is between 0 and 1, and the confidence level has been corrected. In this way, the embodiments of this application enhance the confidence level of the test area with low confidence, and can effectively detect small defects with low confidence.
[0115] Step S205: Based on the corrected confidence level and the confidence level of each test region, determine the target defect region in the at least one test region of the image to be detected, so as to detect the defects present in the object to be detected.
[0116] In some embodiments, after correcting the confidence of the test areas in the image to be inspected that meet the correction conditions, the target defect area can be determined in multiple test areas based on the corrected confidence, the uncorrected confidence, and a preset confidence threshold, so as to determine the defects present in the object to be inspected.
[0117] In some embodiments, the present application embodiments can also determine whether a test region is a defect of the object to be detected by the area of each test region. Therefore, the defect detection method provided by the present application embodiments further includes the following: First, when determining the confidence level of each test region, the number of pixels in each test region is determined, and the area of each test region is determined based on the number of pixels in each test region. Second, test regions with an area greater than an area threshold are determined as target defect regions. Here, the area threshold can be 1024 pixels, and test regions with an area greater than 1024 pixels are determined as target test regions of the image to be detected, i.e., defects of the object to be detected.
[0118] This application embodiment extracts features from the image to be inspected corresponding to the object to be inspected, obtaining at least one region to be inspected. The confidence level of each region to be inspected is determined as a defect in the object to be inspected. The confidence levels of regions to be inspected that meet the correction conditions are corrected to obtain corrected confidence levels. Based on the corrected confidence levels and the original confidence levels, target defect regions are determined among multiple regions to be inspected, thereby identifying defects present in the object to be inspected. Thus, this application embodiment corrects the confidence levels in regions to be inspected that meet the correction conditions, and determines defects in the object to be inspected based on the corrected confidence levels. This enhances the ability to detect low-confidence defects on the surface of the object to be inspected, fully extracting minute defects on the surface of the object to be inspected, and improving the accuracy and precision of defect detection.
[0119] In some embodiments, during the convolution process for feature extraction of an image, the image resolution decreases, resulting in a reduction in the feature information of minute defects and a lower confidence level for these defects. Embodiments of this application can correct the confidence level of the test area with low confidence to avoid missing defects. Figure 6 This is an optional flowchart of the defect detection method provided in this application embodiment. Step S204, which is to correct the confidence level of the test area that meets the correction condition, can be implemented through steps S601 to S603:
[0120] Step S601: Obtain the classification threshold.
[0121] In some embodiments, a classification threshold is used to determine the test areas that require confidence correction among multiple test areas. The specific value of the classification threshold can be determined by a technician based on the characteristics of the object to be inspected. For example, when the object to be inspected is a component such as a battery with a small surface area, the defects in the battery will also be small-area defects. Small defect area leads to low confidence of the defect. Therefore, the classification threshold can be 0.3. In this embodiment, confidence correction is performed on test areas with confidence less than 0.3, enabling the defect detection method provided in this embodiment to detect more minute defects in the object to be inspected.
[0122] Step S602: In the at least one test region, the test region with a confidence level less than the classification threshold is determined as the first test region.
[0123] Step S603: Invert the confidence level of the first test region to obtain the corrected confidence level of the first test region.
[0124] In some embodiments, the confidence inversion process can refer to the modified confidence of the first test region being equal to (1 - confidence), which ultimately yields the confidence of the first test region.
[0125] In some embodiments, after inverting the confidence level of the first test region to obtain the corrected confidence level of the first test region, step S205 can be implemented through steps S604 to S605:
[0126] Step S604: In the at least one test region, the test region with a confidence level greater than the classification threshold is determined as the second test region.
[0127] In this embodiment of the application, for the test region with a confidence level higher than the classification threshold, the confidence level may not be processed. Here, the test region with a confidence level higher than the classification threshold is determined as the second test region.
[0128] Step S605: Determine the target defect region in the at least one test region of the image to be detected based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence level threshold.
[0129] In some embodiments, the confidence threshold may include a first confidence threshold and a second confidence threshold, where the first confidence threshold is less than the second confidence threshold. Different confidence threshold ranges for the region to be tested result in different defect detection results. In some embodiments, step S605 can be implemented via steps S6051 to S6052:
[0130] Step S6051: The first test region with a corrected confidence level greater than the first confidence level threshold and less than the second confidence level threshold, and the second test region with a confidence level greater than the first confidence level threshold and less than the second confidence level threshold in the second test region are determined as the undetermined defect regions of the image to be detected.
[0131] In some embodiments, the values of the first confidence threshold and the second confidence threshold are set by a technician, wherein the first confidence threshold is less than the second confidence threshold. Here, the values of the first confidence threshold or the second confidence threshold may be the same as or different from the classification threshold, and are set according to the needs of the technician; for example, the first confidence threshold is 0.3 and the second confidence threshold is 0.5.
[0132] This application embodiment corrects the requirement that the confidence level of the test area in the second test area be between the first confidence level threshold and the second confidence level threshold as a defect to be determined in the test object. Here, a defect to be determined means that the area is highly likely to be a defect, but further information such as the texture, color, or spatial characteristics of the test area is needed to further determine whether the test area is the target test area, i.e., a determined defect.
[0133] Step S6052: The first test region with a corrected confidence level greater than the second confidence level threshold, and the second test region with a confidence level greater than the second confidence level threshold in the second test region are determined as the target defect region of the image to be detected.
[0134] In some embodiments, the regions to be tested in which the corrected confidence level and the confidence level in the second region to be tested are greater than the second confidence threshold are identified as the target regions to be tested in the image to be detected, that is, these regions to be tested are identified as defects in the image to be detected.
[0135] In some embodiments, after obtaining the defects of the object to be inspected, the number and area of the defects can be used to determine whether the object to be inspected is qualified. For example, when the object to be inspected is a lithium battery, the number and type of defects detected can be used to determine whether the lithium battery is a qualified product. When there are 20 defects on the surface of the lithium battery that exceed 2028 pixels, the lithium battery is considered to be a non-qualified product.
[0136] In some embodiments, after obtaining the regions to be tested, the confidence level of each region to be tested can be determined based on the feature information of all pixels in each region. Therefore, obtaining the confidence level of each region to be tested can be achieved in the following way:
[0137] First, pixel features are extracted for each region to be tested to determine the number of pixels in each region and the pixel information of each pixel.
[0138] Pixel feature extraction here refers to extracting features from each pixel in each test area to obtain the number of pixels in each test area and pixel information such as color, texture and spatial features of each pixel.
[0139] In some embodiments, obtaining the number of pixels in each region to be tested can be used to determine the area of each region to be tested, and to determine whether the region to be tested is a defect based on the area.
[0140] Secondly, the pixel information of each pixel is normalized to obtain the pixel confidence score of each pixel.
[0141] In this embodiment of the application, after determining the pixel information, the weight value of whether each pixel is a defect can be determined based on the feature information of the pixel. Then, the weight values of all pixels are normalized to obtain a value between 0 and 1, and this value is determined as the pixel confidence level of each pixel.
[0142] Finally, the confidence level of each test region is determined based on the number of pixels in each test region and the pixel confidence level of each pixel.
[0143] In some embodiments, after obtaining the pixel confidence score of each pixel, the pixel confidence scores of all pixels in the test area can be averaged to obtain the confidence score of each test area.
[0144] In some embodiments, the defect detection method provided in this application can be implemented by a defect detection model. The training process of the defect detection model is described below. Figure 7 This is a schematic diagram illustrating the implementation flow of the training method for the defect detection model provided in this application embodiment, as shown below. Figure 7 As shown, the method includes the following steps:
[0145] Step S701: Perform data preprocessing on the acquired pre-trained images to obtain sample data.
[0146] In some embodiments, the sample data includes a sample image to be detected corresponding to the sample object to be detected and a defect region corresponding to the sample image to be detected. The defect region may be a defect that has been identified in the sample object to be detected and marked manually or otherwise, for subsequent comparison with the defects detected by the model.
[0147] Step S702: Input the sample image to be detected into the defect detection model.
[0148] Step S703: Through the feature extraction layer of the defect detection model, feature extraction is performed on the sample image to be detected to obtain at least one sample region to be detected in the sample image to be detected.
[0149] Step S704: Obtain the sample confidence level of each sample test area through the confidence level calculation layer of the defect detection model.
[0150] Step S705: Through the confidence correction layer of the defect detection model, based on the sample confidence of each sample test area, the sample confidence corresponding to the sample test area whose sample confidence meets the correction condition is corrected to obtain the sample corrected confidence.
[0151] Step S706: Using the defect detection layer of the defect detection model, determine the target defect region of the sample in the at least one sample in the image to be detected based on the sample correction confidence and the sample confidence of each sample to be tested region.
[0152] Here, after the sample image to be detected is input into the defect detection model, the model performs defect detection on the image to be detected and obtains the target defect region of the sample.
[0153] Step S707: Input the sample target defect region and the defect region into the preset loss model to obtain the loss result.
[0154] In some embodiments, step S707 can be implemented by the following steps S7071 to S7073:
[0155] Step S7071: Input the sample target defect region and the defect region into the preset loss model.
[0156] Step S7072: Determine the similarity between the target defect region of the sample and the defect region by using the cross-entropy loss function in the preset loss model.
[0157] Step S7073: Determine the similarity as the loss result.
[0158] In this embodiment, the similarity between the sample target defect region and the defect region is calculated by the loss function in the preset loss model, thereby obtaining the loss result. This can accurately determine the difference between the defect detected by the defect detection model and the real defect under the current model parameters.
[0159] Step S708: Based on the loss result, the model parameters in the feature extraction layer, the confidence calculation layer, the confidence correction layer and the defect detection layer are corrected to obtain the trained defect detection model.
[0160] In this embodiment of the application, the defect detection model is corrected based on the loss result, thereby realizing the training of the defect detection model and obtaining a defect detection model that can accurately detect defects of the object to be detected.
[0161] In this embodiment, firstly, the confidence level of the test area that meets the correction conditions is inverted, so that this embodiment can further mine the feature information of small defects with low confidence, thereby enhancing the ability to detect small defects with low confidence; secondly, the defect detection model proposed in this embodiment is easy to use. It only requires simple annotation of the defects of the object to be detected, and model training and detection can be carried out without professional technicians. No additional detection software is required for defect detection, which reduces costs.
[0162] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.
[0163] Based on the problems existing in related technologies, this application provides a defect detection method that can be used for detecting surface defects in lithium batteries. For example... Figure 8 As shown, Figure 8 This is an optional flowchart of the defect detection method provided in this application embodiment. Defect detection can be achieved through steps S801 to S804:
[0164] Step S801: Obtain an image of the product to be tested.
[0165] In some embodiments, the product under test (i.e., the object to be inspected) may be a lithium battery. Images of the product under test can be acquired in real-time during the manufacturing process to remedy defective products, or images can be acquired of a completed product. Here, the images can be acquired using an industrial camera.
[0166] Step S802: Determine the image to be detected in the image using a localization algorithm.
[0167] In some embodiments, the localization algorithm is used to determine the areas in an image that need to be detected for defects. After determination, the image is cropped to obtain the image to be detected.
[0168] Step S803: Segment the region of the defect to be detected in the image using a segmentation algorithm, and determine the area and confidence level of the region of the defect to be detected.
[0169] Step S804: Determine whether the product to be tested is qualified based on the area, confidence level and corresponding threshold of the defect area to be determined.
[0170] In some embodiments, the area of the region to be determined (i.e. the region to be tested) can be the pixel area. A defect area of 1024 pixels or more is considered unqualified and thus a defect, while a defect area of less than 1024 pixels is considered qualified and can be considered not a defect.
[0171] In some embodiments, a confidence level of less than 0.3 for a region to be determined is considered acceptable, meaning it is not a defect; a confidence level of 0.3 to 0.5 is considered undetermined and requires further judgment based on the characteristics of the region to be determined; and a confidence level of more than 0.5 is considered unacceptable, meaning it is a defect in the product to be tested.
[0172] In some embodiments, the area of the defective region is the area of the pixels in the defective region, which can be obtained by directly calculating the number of pixels. The confidence score is the result inferred by the segmentation algorithm. The confidence score of each pixel in the defective region is obtained, and then the average confidence score of each pixel in the defective region is taken to obtain the overall confidence score value of the defective region. This overall confidence score value is used to screen whether the product under test is qualified or not.
[0173] In some embodiments, Figure 9 This is a schematic diagram of the structure of the segmentation algorithm network provided in the embodiments of this application, as shown below. Figure 9 As shown, the image to be detected is fed into a segmentation algorithm network, and the segmentation algorithm segments the defective regions in the image. Figure 9As shown, the segmentation algorithm network consists of a downsampling module, a low-level enhancement module, a spatial attention mechanism module, a channel attention mechanism module, an upsampling module, and an adaptive low-confidence enhancement module. Specifically, Res is the downsampling module; SA (spatial attention) is the spatial attention mechanism module; CA (channel attention) is the channel attention mechanism module; Cat performs image stitching; up is the upsampling module; LEM (Low stage enhancement module) is the low-level enhancement module; and ALCSM (Adaptive low confidence strengthening module) is the adaptive low-confidence enhancement module.
[0174] like Figure 9 As shown, there can be M downsampling modules Res. Figure 9 The three downsampling modules Res in this embodiment are merely examples. In this application, the i-th downsampling module Res performs downsampling processing on the image to be detected, obtaining M downsampling images; where, when i = 1, the input image is the image to be detected, and when i > 1, the input image is the feature map output by the (i-1)-th downsampling network, with i taking values from 1 to M. Then, each feature enhancement module LEM performs feature enhancement on one downsampling feature map, obtaining M enhanced feature maps. Finally, based on channel and spatial attention mechanisms, the spatial attention mechanism module SA and the channel attention mechanism module CA perform feature sampling on the M-th downsampling feature map, obtaining a sampled feature map.
[0175] In some embodiments, based on the upsampling module `up`, the sampled feature map is amplified, and the amplified sampled feature map is concatenated with the Mth enhanced feature map to obtain a first concatenated feature map. Based on the adaptive low-confidence enhancement module `ALCSM`, feature weights are calculated for each defect region in the first concatenated feature map to obtain the confidence level of each defect region. Confidence levels that meet the correction conditions are then corrected to obtain a first weighted map with the confidence level of each defect region. Based on the upsampling module, the first weighted map is amplified, and the amplified first weighted map is concatenated with the (M-1)th enhanced feature map to obtain a second concatenated feature map. Feature weights are then calculated and corrected on the second concatenated feature map to obtain a second weighted map. Based on the generation order of the M feature weight maps and the upsampling module, the j-th weight map after feature amplification is sequentially concatenated with the Mj-th enhanced feature map to obtain the (j+1)-th concatenated feature map. The feature weights of the (j+1)-th concatenated feature map are then calculated and corrected to obtain the (j+1)-th weight map, and so on, until the M weight maps are obtained; where j takes values from 1 to M-1. Finally, the M weight maps are concatenated to obtain the feature weight map, which includes the segmented undetermined defect region, the area of the undetermined defect region, and the confidence level.
[0176] In some embodiments, Figure 10 This is a schematic diagram of the network structure of the feature enhancement module provided in the embodiments of this application, such as... Figure 10 As shown, the Feature Enhancement Module (LEM) includes a channel attention module 11, a spatial attention module 12, a first convolutional module 13, and a second convolutional module 14. The feature enhancement module is used to extract the edges and key points of defects.
[0177] In this embodiment, the feature enhancement module is the same as the aforementioned feature enhancement network. Based on the channel attention mechanism of the channel attention module 11, it calculates the importance of each channel in the sampled feature map, i.e., which channels contain key information about whether it is a defect, thus improving the feature representation capability and obtaining a first image. The first image is multiplied with the downsampled image, and based on the spatial attention mechanism of the spatial attention module 12, it determines where the key information is most concentrated in the multiplied image, so that the densely concentrated area is determined as the location of the area to be tested, thus obtaining a second image. The second image is multiplied with the previously multiplied image, and the multiplied image is added to the downsampled image. The added image is then convolved by the first convolution module 13, which can be a convolutional layer with a 1*1 convolution kernel. The first convolution module 13 realizes the information interaction of different channels in the added image, thus obtaining a third image. At the same time, the downsampled image is convolved by the second convolution module 14, which can also be a convolutional layer with a 1*1 convolution kernel, thus obtaining a fourth image. Finally, the third image is added to the fourth image to obtain the feature enhancement map.
[0178] In some embodiments, Figure 11 This is a schematic diagram of the network structure of the adaptive low-confidence enhancement module provided in the embodiments of this application, as shown below. Figure 11 As shown, the Adaptive Low Confidence Enhancement Module (ALCSM) includes a channel attention module 111, a spatial attention module 112, a third convolution module 113, a normalization module 114, and a fourth convolution module 115. The ALCSM calculates the confidence and area of each undetermined defect region and corrects the confidence levels that meet the correction conditions, ultimately obtaining a weight map. The weight map includes the segmented undetermined defect regions and their areas and confidence levels.
[0179] In this embodiment, after multiple downsampling convolutions, the resolution of the image to be detected decreases due to small defects in the product under test, and the feature information of small defects also decreases. The confidence of small defects is also lower than that of large defects, so the probability of detecting small defects in lithium batteries is low. The Adaptive Low Confidence Enhancement Module (ALCSM) provided in this embodiment is used to solve the problem that low-confidence defects cannot be detected. This module first suppresses a portion of the background noise that is not important in the image to be detected through the channel attention module 111 and the spatial attention module 112. Then, the feature map after suppressing the background noise is passed through a 1*1 convolution (i.e., the third convolution module 113) to obtain a feature map with one channel. Then, it is passed through the normalization module 114 to obtain the feature weight (i.e., confidence) of each defect region to be determined, thus obtaining a feature weight map.
[0180] In this embodiment, the feature weight map can be divided into two parts: the first part is to invert the feature weights in the feature weight map that are less than the inversion threshold (i.e., the confidence threshold) (i.e., 1 - feature weight) to obtain the inverse attention map. The inverse attention map reflects the low-confidence regions corresponding to some ignored small defects. This inverse enhancement operation can guide the network to further mine the saliency information of the foreground from the low-confidence background regions. The second part is to not process the feature weights in the feature weight map that are greater than the inversion threshold (i.e., the confidence threshold) to obtain the attention map. Then, the inverse attention map and the attention map are multiplied with the feature map after suppressing background noise, respectively. Finally, the two multiplied feature maps are convolved by the fourth convolution module 115, and the two convolved feature maps are added together to obtain the weight map. The weight map includes the undetermined defect region segmented by the segmentation algorithm, the area of the undetermined defect region, and the confidence.
[0181] In some embodiments, edge information of defects in the image to be detected can be obtained through a segmentation algorithm, and the area of the defects in the image to be detected can be determined based on the edge information. Figure 12 This is a schematic diagram of the detected defects provided in the embodiments of this application, such as... Figure 12 As shown, Figure a is the edge image of the detected defect, and Figure b is the overall image of the detected defect.
[0182] The segmentation algorithm provided in this application has a detection speed much greater than that of existing commercial software, enabling it to replace commercial software without the need to purchase expensive commercial software. Secondly, the segmentation algorithm provided in this application is easy to use, requiring only simple labeling of defects in the product under test. Training and detection can be performed without the need for professional technicians, giving it an end-to-end advantage. This allows the defect detection method provided in this application to quickly detect defect information in the product under test.
[0183] Based on the above defect detection methods Figure 13 This is a schematic diagram of the structural composition of the defect detection device provided in the embodiments of this application, as shown below. Figure 13As shown, the defect detection device 130 includes an acquisition module 131, a feature extraction module 132, an acquisition module 133, a correction module 134, and a determination module 135. The acquisition module 131 acquires an image to be detected, which is an image corresponding to an object to be detected. The feature extraction module 132 extracts features from the image to be detected to obtain at least one test region in the image. The acquisition module 133 obtains the confidence level of each test region, which characterizes the probability that the object to be detected has a defect. The correction module 133 corrects the confidence level of test regions that meet correction conditions based on the confidence level of each test region, obtaining a corrected confidence level. The determination module 134 determines a target defect region in the at least one test region of the image to be detected based on the corrected confidence level and the confidence level of each test region, thereby detecting defects in the object to be detected.
[0184] In some embodiments, the correction module 134 is further configured to obtain a classification threshold; in the at least one test region, determine the test region with a confidence level less than the classification threshold as a first test region; and invert the confidence level of the first test region to obtain a corrected confidence level of the first test region.
[0185] In some embodiments, the determining module 135 is further configured to determine, in the at least one test region, a test region with a confidence level greater than the classification threshold as a second test region; and to determine a target defect region in the at least one test region of the image to be detected based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence threshold.
[0186] In some embodiments, the confidence threshold includes a first confidence threshold and a second confidence threshold, wherein the first confidence threshold is less than the second confidence threshold; the determining module 135 is further configured to determine the first test region with a corrected confidence level greater than the first confidence threshold and less than the second confidence threshold, and the second test region with a corrected confidence level greater than the first confidence threshold and less than the second confidence threshold in the second test region as the undetermined defect region of the image to be detected; and to determine the first test region with a corrected confidence level greater than the second confidence threshold, and the second test region with a corrected confidence level greater than the second confidence threshold in the second test region as the target defect region of the image to be detected.
[0187] In some embodiments, each test region consists of at least one pixel; the obtaining module 133 is further configured to extract pixel features from each test region, determine the number of pixels in each test region and the pixel information of each pixel; normalize the pixel information of each pixel to obtain the pixel confidence of each pixel; and determine the confidence of each test region based on the number of pixels in each test region and the pixel confidence of each pixel.
[0188] In some embodiments, the apparatus further includes: a first determining module, configured to determine the area of each region to be tested based on the number of pixels in each region to be tested; correspondingly, the determining module is further configured to determine the regions to be tested with an area greater than an area threshold as target defect regions.
[0189] In some embodiments, the feature extraction module 132 is further configured to extract grayscale features from each pixel of the image to be detected, and obtain grayscale feature information of each pixel; and determine at least one region to be tested on the image to be detected based on the grayscale feature information of each pixel.
[0190] In some embodiments, the feature extraction module 132 is further configured to: compress the features of the image to be detected to obtain a downsampled image; enhance the features of the downsampled feature map to obtain an enhanced feature map; sample the features of the downsampled feature map based on channel attention mechanism and spatial attention mechanism to obtain a sampled feature map; concatenate the sampled feature map and the enhanced feature map to obtain a concatenated feature map; denoise the concatenated feature map to obtain a denoised feature map; and extract features from the denoised feature map to obtain at least one region to be tested.
[0191] In some embodiments, the method is implemented using a defect detection model; the apparatus further includes a model training module, which preprocesses the acquired pre-training images to obtain sample data, the sample data including a sample image to be detected corresponding to a sample object to be detected and a defect region corresponding to the sample image to be detected; the sample image to be detected is input into the defect detection model; features are extracted from the sample image to be detected through the feature extraction layer of the defect detection model to obtain at least one sample region to be tested in the sample image to be detected; the confidence level of each sample region to be tested is obtained through the confidence level calculation layer of the defect detection model; and the confidence level of the sample region to be tested is calculated using the confidence level calculation layer of the defect detection model. The correction layer, based on the sample confidence of each sample test region, corrects the sample confidence corresponding to the sample test region whose sample confidence meets the correction condition, to obtain the sample corrected confidence. Through the defect detection layer of the defect detection model, based on the sample corrected confidence and the sample confidence of each sample test region, the sample target defect region is determined in at least one sample test region of the sample test image. The sample target defect region and the defect region are input into a preset loss model to obtain a loss result. Based on the loss result, the model parameters in the feature extraction layer, the confidence calculation layer, the confidence correction layer, and the defect detection layer are corrected to obtain the trained defect detection model.
[0192] It should be noted that the description of the apparatus in this application embodiment is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment; therefore, it will not be repeated. For technical details not disclosed in this apparatus embodiment, please refer to the description of the method embodiment of this application for understanding.
[0193] It should be noted that, in the embodiments of this application, if the above-described defect detection method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a terminal to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0194] This application provides a defect detection device. Figure 14 This is a schematic diagram of the composition structure of the defect detection equipment provided in the embodiments of this application, as shown below. Figure 14 As shown, the defect detection device 14 includes at least a processor 141 and a computer-readable storage medium 142 configured to store executable instructions, wherein the processor 141 generally controls the overall operation of the defect detection device. The computer-readable storage medium 142 is configured to store instructions and applications executable by the processor 141, and may also cache data to be processed or processed by various modules in the processor 141 and the defect detection device 140, and may be implemented using flash memory or random access memory (RAM).
[0195] This application provides a storage medium storing executable instructions. When these executable instructions are executed by a processor, they cause the processor to execute the defect detection method provided in this application. For example, ... Figure 2 The method shown.
[0196] In some embodiments, the storage medium may be a computer-readable storage medium, such as a ferromagnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEROM), flash memory, magnetic surface memory, optical disk, or a compact disk-read-only memory (CD-ROM); or it may be a device that includes one or any combination of the above-mentioned memories.
[0197] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0198] As an example, executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file containing other programs or data, for example, in one or more scripts within a Hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files storing one or more modules, subroutines, or code sections). As an example, executable instructions may be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0199] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application. It should be understood that "an embodiment" or "one embodiment" mentioned throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence number of the above-described processes does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments of this application are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments.
[0200] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not performed.
[0201] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A defect detection method, the method comprising: Acquire the image to be detected, which is the image corresponding to the object to be detected; The image to be detected is downsampled to obtain a downsampled feature map; The downsampled feature map is enhanced with features and processed using channel attention and spatial attention mechanisms to obtain at least one region to be detected in the image to be detected; the channel attention mechanism and the spatial attention mechanism are used at least to suppress background noise in the image to be detected; The confidence level of each of the test regions is obtained, and the confidence level is used to characterize the probability that the test region is a defect of the object to be detected; A classification threshold is obtained. In the at least one test region, the test region with a confidence level less than the classification threshold is determined as the first test region. The confidence level of the first test region is inverted to obtain the corrected confidence level of the first test region. Based on the corrected confidence level and the confidence level of each test region, a target defect region is determined in at least one test region of the image to be detected, so as to detect defects present in the object to be detected.
2. The method according to claim 1, wherein determining the target defect region in the at least one region to be tested in the image to be detected based on the corrected confidence level and the confidence level of each region to be tested comprises: In the at least one test region, the test region with a confidence level greater than the classification threshold is determined as the second test region; Based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence threshold, a target defect region is determined in at least one test region of the image to be detected.
3. The method according to claim 2, wherein the confidence threshold includes a first confidence threshold and a second confidence threshold, wherein the first confidence threshold is less than the second confidence threshold; The step of determining the target defect region in the at least one test region of the image to be detected based on the corrected confidence level, the confidence level corresponding to the second test region, and the confidence threshold includes: The first test region with a corrected confidence level greater than the first confidence level threshold and less than the second confidence level threshold, and the second test region with a confidence level greater than the first confidence level threshold and less than the second confidence level threshold in the second test region are determined as the undetermined defect regions of the image to be detected. The first test region with a corrected confidence level greater than the second confidence level threshold, and the second test region with a corrected confidence level greater than the second confidence level threshold, are determined as the target defect regions of the image to be detected.
4. The method according to claim 1, wherein each region to be tested consists of at least one pixel; Obtaining the confidence level of each of the regions to be tested includes: Pixel features are extracted for each region to be tested to determine the number of pixels in each region and the pixel information of each pixel. The pixel information of each pixel is normalized to obtain the pixel confidence score of each pixel; The confidence level of each test region is determined based on the number of pixels in each test region and the pixel confidence level of each pixel.
5. The method according to claim 4, further comprising: The area of each region to be tested is determined based on the number of pixels in each region to be tested. Correspondingly, determining the target defect region in the at least one region to be tested in the image to be detected further includes: The area to be tested that is larger than the area threshold is identified as the target defect area.
6. The method according to any one of claims 1 to 5, wherein downsampling the image to be detected to obtain a downsampled feature map comprises: The image to be detected is subjected to feature compression to obtain a downsampled feature map; The downsampled feature map is subjected to feature enhancement and feature processing based on channel attention and spatial attention mechanisms to obtain at least one detection region in the image to be detected, including: The downsampled feature map is augmented to obtain the augmented feature map. Based on channel attention and spatial attention mechanisms, feature sampling is performed on the downsampled feature map to obtain the sampled feature map; The sampled feature map and the enhanced feature map are concatenated to obtain a concatenated feature map; The spliced feature map is subjected to noise reduction processing to obtain a noise-reduced feature map; Feature extraction is performed on the denoised feature map to obtain at least one region to be tested.
7. The method according to claim 1, wherein the method is implemented through a defect detection model; wherein, The defect detection model is trained in the following way: The acquired pre-trained images are preprocessed to obtain sample data, which includes the sample image to be detected corresponding to the sample object to be detected and the defect region corresponding to the sample image to be detected. The sample image to be detected is input into the defect detection model; The feature extraction layer of the defect detection model is used to extract features from the sample image to be detected, thereby obtaining at least one sample region to be detected in the sample image to be detected. The confidence level of each sample region to be tested is obtained through the confidence calculation layer of the defect detection model. Through the confidence correction layer of the defect detection model, based on the sample confidence of each sample test area, the sample confidence of the sample test area that meets the correction condition is corrected to obtain the sample corrected confidence. The defect detection layer of the defect detection model determines the target defect region of the sample in the at least one sample test region of the sample test image based on the sample correction confidence and the sample confidence of each sample test region. The sample target defect region and the defect region are input into a preset loss model to obtain the loss result; Based on the loss result, the model parameters in the feature extraction layer, the confidence calculation layer, the confidence correction layer, and the defect detection layer are corrected to obtain the trained defect detection model.
8. A defect detection device, the device comprising: The acquisition module is used to acquire the image to be detected, wherein the image to be detected is the image corresponding to the object to be detected; The feature extraction module is used to downsample the image to be detected to obtain a downsampled feature map, perform feature enhancement on the downsampled feature map, and perform feature processing based on channel attention mechanism and spatial attention mechanism to obtain at least one region to be detected in the image to be detected; the channel attention mechanism and the spatial attention mechanism are at least used to suppress background noise in the image to be detected; The module is used to obtain the confidence level of each of the regions to be tested, wherein the confidence level is used to characterize the probability that the region to be tested is a defect of the object to be detected; The correction module is used to obtain a classification threshold, and in the at least one test region, the test region with a confidence level less than the classification threshold is determined as the first test region, and the confidence level of the first test region is inverted to obtain the corrected confidence level of the first test region. A determination module is configured to determine a target defect region in at least one test region of the image to be detected based on the corrected confidence level and the confidence level of each test region, so as to detect defects present in the object to be detected.
Citation Information
Patent Citations
Defect detection model training method, defect detection method and related device
CN111814867A
Method and device for training semiconductor wafer defect detection model
CN114998324A