Product surface defect detection method and system, computer equipment and storage medium

By using the good product feature library to detect product surface defects, the problem that deep learning methods are difficult to effectively detect in small batch production is solved, the sensitivity and efficiency of detection are improved, and the probability of misjudgment is reduced.

CN118735849APending Publication Date: 2024-10-01DONGGUAN GOSUNM MACHINERY EQUIP CO LTD

Patent Information

Application Number
CN202410429960.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-10
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing deep learning methods are difficult to effectively detect product surface defects in small batch production, mainly due to the lack of sufficient defective product samples for training, resulting in low detection sensitivity and efficiency.

Method used

The good product feature library is used for detection, and the image to be detected is obtained, image correction and feature extraction are performed, and the feature distance is calculated. If the distance exceeds the threshold, it is determined to be a defective product, otherwise it is a good product.

Benefits of technology

It improves the sensitivity and work efficiency of product surface defect detection, reduces the probability of misjudgment, and is suitable for small batch production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118735849A_ABST
    Figure CN118735849A_ABST
Patent Text Reader

Abstract

The invention relates to a product surface defect detection method and system, computer equipment and a storage medium. The method comprises the following steps: acquiring a to-be-detected image corresponding to a to-be-detected target; converting the format of a to-be-detected image into a preset input format, and inputting the format into the image correction and alignment model to obtain a target image; inputting the target image into a trained deep neural network feature extraction model, and extracting a target feature map corresponding to the target image; calculating a feature distance between the target feature map and the same position in each non-defective product feature map in a preset non-defective product feature library; the minimum feature distance in the feature distances of all the positions is obtained and serves as the final distance of the position, and a feature distance map corresponding to the target feature map is generated; if any final distance in the feature distance map exceeds a preset feature distance threshold, determining that the target to be detected is a defective product, otherwise, determining that the target to be detected is a good product; the method has the advantages that the good product feature library is adopted for detection, use is convenient, and the defect detection sensitivity is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine vision and image processing, and in particular to a product surface defect detection method, system, computer equipment and storage medium. Background Art

[0002] In the industrial production process, some products with regular textures (such as cloth, clothing, roll film, and other products with patterns) may have texture defects such as deformation, incompleteness, or redundancy during the production process. Deep learning methods are usually used to detect them. If such a production process is repeated and mass-produced, the deep learning method will collect a large number of good and defective products for training and subsequent testing. This method can be used normally in most cases. However, for the production of small batches of products, since it is impossible to collect enough defective products for training in small batches, this method is not very suitable for small batch production. Summary of the invention

[0003] Based on this, the purpose of the present invention is to provide a product surface defect detection method, system, computer equipment and storage medium, which have the advantages of using a good product feature library for detection, being easy to use, and improving the sensitivity and work efficiency of product surface defect detection.

[0004] A method for detecting surface defects of a product comprises the following steps:

[0005] Obtaining an image to be detected corresponding to the target to be detected;

[0006] Convert the format of the image to be detected into a preset input format, and input it into an image correction and alignment model to obtain a target image, wherein the target image is an image obtained by correcting and aligning the image to be detected;

[0007] Inputting the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image;

[0008] Calculating the characteristic distance between the target characteristic graph and the same position in each good product characteristic graph in a preset good product characteristic library, wherein the good product characteristic library includes a plurality of good product characteristic graphs corresponding to the product to be inspected;

[0009] Obtaining the minimum feature distance among the feature distances of each position as the final distance of the position, and generating a feature distance map corresponding to the target feature map;

[0010] If any final distance in the feature distance map exceeds a preset feature distance threshold, the target to be detected is a defective product; otherwise, the target to be detected is a good product.

[0011] A product surface defect detection system, comprising:

[0012] An image acquisition module is used to acquire an image to be detected corresponding to the target to be detected;

[0013] An image alignment module, used to convert the image to be detected into a preset input format and input it into an image correction and alignment model to obtain a target image, wherein the target image is an image obtained by correcting and aligning the image to be detected;

[0014] A feature map acquisition module is used to input the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image;

[0015] A distance calculation module, used to calculate the characteristic distance between the target characteristic map and the same position in each good product characteristic map in a preset good product characteristic library, wherein the good product characteristic library includes a plurality of good product characteristic maps corresponding to the product to be detected;

[0016] A distance map generation module is used to obtain the minimum feature distance among the feature distances of each position as the final distance of the position, and generate a feature distance map corresponding to the target feature map;

[0017] The judgment module is used to judge that if any final distance in the characteristic distance map exceeds a preset characteristic distance threshold, the target to be detected is a defective product; otherwise, the target to be detected is a good product.

[0018] A computer device comprises: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the product surface defect detection method as described above when executing the computer program.

[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the product surface defect detection method as described above are implemented.

[0020] This solution provides a defect recognition method, which obtains the image to be detected corresponding to the target to be detected, sets the image to be detected to a preset format, obtains the target image through correction and alignment, inputs the target image into a trained deep neural network feature extraction model, obtains the target feature map corresponding to the target image, divides the target feature map into a number of regions of the same size according to preset specifications, and obtains the region feature vector corresponding to each region by merging the target features in each region; by obtaining the position information of each region, calculates the distance information between the region feature vector and the sample vector at the same position in the preset good product feature library, and if the distance information exceeds the preset feature distance threshold, the target to be detected is a defective product, otherwise the target to be detected is a good product. The defect recognition method in this solution uses a good product feature library for detection, which is easy to use, improves the sensitivity and work efficiency of product surface defect detection, and reduces the probability of misjudgment during product surface defect detection.

[0021] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a flowchart of the steps of a defect identification method in one embodiment of the present application;

[0023] Figure 2 A flowchart of the steps of acquiring a target image in one embodiment of the present application;

[0024] Figure 3 A flowchart of the steps of training the deep neural network feature extraction model in one embodiment of the present application;

[0025] Figure 4 A flowchart of the steps of calculating feature distance in one embodiment of the present application;

[0026] Figure 5 A flowchart of the steps of constructing a good product feature library in one embodiment of the present application;

[0027] Figure 6 This is a schematic diagram of the structure of a product surface defect detection system in one embodiment of the present application;

[0028] Figure 7 A schematic diagram of a computer device for a product surface defect detection method in one embodiment of the present application. DETAILED DESCRIPTION

[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0030] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0031] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" / "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".

[0032] See also Figure 1 , Figure 1 The following is a flowchart of a defect identification method in one embodiment of the present application. A defect identification method comprises the following steps:

[0033] S101, obtaining an image to be detected corresponding to the target to be detected;

[0034] S102, converting the format of the image to be detected into a preset input format, and inputting it into an image correction and alignment model to obtain a target image;

[0035] S103, inputting the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image;

[0036] S104, dividing the target feature map into a number of regions of the same size according to preset specifications, and merging the target features of each region to obtain a regional feature vector;

[0037] S105, obtaining the position information of each region, and calculating the distance information between the regional feature vector of each region and the sample vector of the corresponding position in the preset good product feature library according to the position information;

[0038] S106, if the distance information exceeds a preset characteristic distance threshold, the target to be detected is a defective product, otherwise the target to be detected is a good product.

[0039] This solution provides a defect recognition method, which obtains the image to be detected corresponding to the target to be detected, sets the image to be detected to a preset format, obtains the target image through correction and alignment, inputs the target image into a trained deep neural network feature extraction model, obtains the target feature map corresponding to the target image, divides the target feature map into a number of regions of the same size according to preset specifications, and obtains the region feature vector corresponding to each region by merging the target features in each region; by obtaining the position information of each region, calculates the distance information between the region feature vector and the sample vector at the same position in the preset good product feature library, and if the distance information exceeds the preset feature distance threshold, the target to be detected is a defective product, otherwise the target to be detected is a good product. The defect recognition method in this solution uses a good product feature library for detection, which is easy to use, improves the sensitivity and work efficiency of product surface defect detection, and reduces the probability of misjudgment during product surface defect detection.

[0040] In step S101, an image to be detected corresponding to the target to be detected is obtained;

[0041] The target to be detected is a target for which surface defects of a product need to be detected. In one embodiment, the target to be detected includes a target with a uniform pattern or style, such as cloth, clothing, roll film, etc. The image to be detected is an image obtained by photographing the target to be detected.

[0042] In this embodiment, the image to be detected corresponding to the target to be detected is obtained for detecting product surface defects of the target to be detected, thereby ensuring the accuracy of product surface defect detection.

[0043] In step S102, the format of the image to be detected is converted into a preset input format, and input into an image correction and alignment model to obtain a target image;

[0044] The preset input format is a format of an image set in advance for inputting into a deep neural network feature extraction model. In one embodiment, the preset input format is set to H*W*3, where H is the image height, W is the image width, and 3 represents the number of image channels. In other embodiments, the preset input format may also be a grayscale image or a multi-channel image.

[0045] The image correction and alignment model is a model used to correct and align the image to be detected, and the target image is an image obtained after the detection image is converted into a preset input format and corrected and aligned by the image correction and alignment model.

[0046] In this embodiment, by converting the format of the image to be detected into the preset input format and using the image correction and alignment model to correct and align it, the image format and shape used for product surface defect detection are ensured to be the same, thereby reducing the amount of calculation and improving the efficiency of product surface defect detection.

[0047] See also Figure 2 , Figure 2 This is a flowchart of the steps of obtaining a target image in one embodiment of the present application. In one embodiment, the format of the image to be detected is converted into a preset input format and input into the image correction and alignment model to obtain the target image, including the following steps:

[0048] S201, converting the format of the image to be detected into a preset input format;

[0049] S202, comparing the image to be detected with a preset template image to generate an image transformation matrix;

[0050] S203: Using the image transformation matrix, perform image transformation on the image to be detected to obtain the target image.

[0051] For steps S201 to S203, the template image is set in advance to ensure the consistency of the image input into the deep neural network feature extraction model, and the image transformation matrix is ​​a matrix used to perform image transformation on the image to be detected. In this embodiment, the image to be detected is graphically transformed through the image transformation matrix, for example, the image to be detected is rotated, translated, etc. according to the image transformation matrix.

[0052] In this embodiment, first, the image to be detected is converted into a preset format, for example, the input format of the image to be detected is converted into H*W*3.

[0053] Then, the image to be detected is compared with the template image to obtain an image transformation matrix. In one embodiment, the image to be detected and the template image are detected with a feature detection algorithm (for example, SIFT, SURF, ORB) to detect image key points, the image descriptors to be detected and the template image descriptors corresponding to the image key points are extracted, the image descriptors to be detected and the template image descriptors are matched with the template image descriptors by a feature matching algorithm, and the image transformation matrix corresponding to the image to be detected is estimated. In another embodiment, the difference between the image to be detected and the template image is calculated to obtain each pixel or pixel block in the image to be detected and the most similar pixel or pixel block in the template image, to obtain the pixel correspondence relationship between the image to be detected and the template image, and to generate the image transformation matrix according to the pixel correspondence relationship.

[0054] Finally, the image to be detected is transformed through the image transformation matrix to obtain the target image, so that the format and shape of the image input into the deep neural network feature extraction model are the same, reducing the calculation amount of feature comparison and improving the accuracy and efficiency of product surface defect detection.

[0055] It should be noted that the method described in the embodiment of the present application of converting the format of the image to be detected into a preset input format and inputting it into the image correction and alignment model to obtain the target image includes the above steps, but is not limited to the above steps. In other embodiments, technicians in this field may also use the automatic alignment network in deep learning as the image correction and alignment model to align the image to be detected converted into the preset input format to obtain the target image. For example, the spatial transformer network (Spatial Transformer Network, STN) in deep learning is used as the image correction and alignment model to align the image to be detected to obtain the target image.

[0056] In step S103, the target image is input into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image;

[0057] Among them, the deep neural network feature extraction model is a neural network model used to adjust and extract the target image. In one embodiment, the deep neural network feature extraction model includes a convolutional neural network model.

[0058] See also Figure 3 , Figure 3 This is a flowchart of the steps of training the deep neural network feature extraction model in one embodiment of the present application. In one embodiment, it also includes training the deep neural network feature extraction model, including the following steps:

[0059] S301, obtaining a number of good product images and defective product images corresponding to the target to be detected, and generating a model training data set;

[0060] S302, converting the model training data set into triple data, wherein the triple data includes anchor data, positive sample data, and negative sample data;

[0061] S303, inputting the triplet data into the deep neural network feature extraction model to obtain a vector representation of the triplet data;

[0062] S304, calculating a first distance between the anchor point data and the positive sample data and a second distance between the anchor point data and the negative sample data according to the vector representation, and calculating a model loss value according to a triplet loss function, the first distance, and the second distance;

[0063] S305, updating the model parameters of the deep neural network feature extraction model according to the model loss value;

[0064] S306, executing the above steps in a loop. If the number of loops exceeds the preset number, the training of the deep neural network feature extraction model is completed.

[0065] For step S301, wherein the good product image is an image corresponding to a good product among the products corresponding to the target to be detected, the defective product image is an image corresponding to a defective product among the products corresponding to the target to be detected, and the model training data set is a data set obtained based on the several good product images and defective product images for training the deep neural network feature extraction model.

[0066] In this embodiment, by acquiring images of good products and defective products corresponding to the target to be inspected, a model training data set is generated for training the deep neural network feature extraction model, thereby ensuring the accuracy of image feature extraction by the deep neural network feature extraction model, thereby improving the accuracy of product surface defect detection.

[0067] In one embodiment, obtaining a plurality of images of good products and images of bad products corresponding to the target to be detected includes the following steps:

[0068] Based on prior knowledge, PS is used to synthesize the good product image and the defective product image corresponding to the target to be detected;

[0069] Or, the defective product image is synthesized by using an algorithm, for example, an irregular shape region is generated in a good product image by using an algorithm, wherein the size of the irregular shape region is within a preset range, and the number of the irregular shape regions does not exceed the preset number of regions; the defective product image is obtained by filling the irregular shape region with a material texture of a third-party image library or a texture different from the material of the irregular shape region;

[0070] Or, the good product image and the defective product image are generated by using a generation model, for example, the good product image and the defective product image are generated by using a stable diffusion model.

[0071] For step S302, the triplet data includes an anchor point, a positive sample and a negative sample, the anchor point is a reference sample obtained from the sample data set, the anchor point is used to compare with the positive sample and the negative sample, the positive sample is a sample belonging to the same type as the anchor point, and the negative sample is a sample belonging to a different category from the anchor point. In this embodiment, one good product image in the sample data set is selected as the anchor point, the remaining good product images are used as the positive samples, and the defective product image is a negative sample to obtain the triplet data.

[0072] For steps S303 to S305, the vector representation is a vector obtained by inputting the triplet data into the deep neural network feature extraction model, the first distance is the distance between the anchor point data and the positive sample data, and the second distance is the distance between the anchor point data and the negative sample.

[0073] The triplet loss function is a supervised learning loss function that allows the network to achieve multi-category classification.

[0074] In this embodiment, the triplet data is input into the deep neural network feature extraction model, the vector representation corresponding to the triplet data is obtained, and the first distance and the second distance are calculated respectively according to the vector representation. Finally, the model loss value of the deep neural network feature extraction model is calculated by combining the first distance and the second distance using the triplet loss function, which is used to update the model parameters of the deep neural network feature extraction model.

[0075] For step S306, the preset number is the number of cycles set in advance. In this embodiment, the deep neural network feature extraction model is trained by iterating steps S301 to S305. When the number of cycles reaches the preset number, the cycle ends to obtain the trained deep neural network feature extraction model, thereby ensuring the accuracy of feature extraction by the deep neural network feature extraction model and improving the accuracy and efficiency of defect identification.

[0076] It should be clear that the training of the deep neural network feature extraction model in the present application includes the above steps, but is not limited to the above steps. In other embodiments, those skilled in the art may also adopt other model training methods to train the deep neural network feature extraction model, for example, using a SimSiam network in combination with a training data set including good product images to train the deep neural network feature extraction model.

[0077] For step S104, the characteristic distance between the target characteristic map and the same position in each characteristic map of good products in the preset good product characteristic library is calculated;

[0078] The good product feature library is a pre-built database for feature comparison of the target feature map corresponding to the target to be detected, and the good product feature library includes several good product feature maps corresponding to the target to be detected. The good product feature map is a feature map obtained by operating the good product image corresponding to the target to be detected in steps S102 to S103.

[0079] The feature distance is the distance between features at the same position in the target feature map and the good product feature map. The feature distance is calculated to determine the similarity between the target feature map and the good product feature image.

[0080] In one embodiment, calculating the characteristic distance between the target characteristic map and the same position in each good product characteristic map in a preset good product characteristic library comprises the following steps:

[0081] Dividing the target feature map into a number of regions of equal size according to preset specifications, and merging the image features of each region into a regional feature vector;

[0082] Obtaining the position information of each region, and calculating the characteristic distance between each regional feature vector and a regional feature vector sample at a corresponding position in a preset good product feature library according to the position information;

[0083] Among them, the preset specification is a division scheme set in advance. In one embodiment, the preset specification is set to H / 8*W / 8*C, wherein H is the height of the target feature map, W is the width of the target feature map, and C is the number of channels of the target feature map.

[0084] In this embodiment, the target feature map is divided into a number of regions of the same size according to the preset specifications, and the image features in each region are merged into a regional feature vector. By obtaining the position information of each region, the feature distance between each regional feature vector and the regional feature vector sample at the corresponding position in the preset good product feature library is calculated based on the position information.

[0085] See also Figure 4 , Figure 4 The flowchart of the steps of calculating the feature distance in one embodiment of the present application. In another embodiment, calculating the feature distance between the target feature map and the same position in each good product feature map in the preset good product feature library includes the following steps:

[0086] S401, converting the target feature map into a feature vector of shape [1, C, H, W], where C is the number of channels, H is the image height, and W is the image width;

[0087] S402, obtaining a plurality of good product feature maps in the good product feature library, and merging the plurality of good product feature maps into a tensor of shape [N, C, H, W], where N is the batch size, C is the number of channels, H is the image height, and W is the image width;

[0088] S403, using a parallel processing method to calculate the distance between the feature vector and the same position of the tensor to obtain the feature distance.

[0089] For steps S401 to S403, the feature vector is a vector used to represent the image features corresponding to the target feature map, and the feature vector shape is [1, C, H, W], where C is the number of channels, H is the image height, and W is the image width. In this embodiment, the target feature image is converted into the feature vector according to the width, height, and number of channels of the image, so as to facilitate comparison with the good feature map in the good feature library.

[0090] The tensor is composed of several feature vectors. In the present embodiment, the tensor is composed of feature vectors corresponding to several good feature maps. The shape of the tensor is [N, C, H, W], wherein N is the batch size, which is the number of good feature maps in the present embodiment, C is the number of channels, H is the image height, and W is the image width.

[0091] In this embodiment, the target feature map is converted into a feature vector with a shape of [1, C, H, W], and several good feature maps in the good feature library are merged to generate a tensor with a shape of [N, C, H, W]. A parallel processing method is adopted to simultaneously calculate the distance between the feature vector and the same position of the tensor to obtain the feature distance, wherein the distance calculation method includes Euclidean distance, cosine similarity or Mahalanobis distance of distribution. Those skilled in the art can select the corresponding distance calculation method according to the actual scenario, which is not limited here.

[0092] For step S105, the minimum characteristic distance among the characteristic distances of each position is obtained as the final distance of the position, and a characteristic distance map corresponding to the target characteristic map is generated;

[0093] The final distance is the distance between the target feature map and the same position in the good product feature library. In this embodiment, by comparing the feature distances corresponding to each position, the minimum feature distance is obtained as the final distance of the position.

[0094] The feature distance map is a map used to represent the distance between the target feature map and the good product feature library. In this embodiment, the distance is composed of the final distance corresponding to each position.

[0095] In this embodiment, the minimum characteristic distance among the characteristic distances corresponding to each position is obtained as the final distance, and the characteristic distance map is constructed, so as to facilitate the judgment of the target characteristic map and accurately identify the location of defective products.

[0096] For step S106, if any final distance in the characteristic distance map exceeds a preset characteristic distance threshold, the object to be detected is a defective product; otherwise, the object to be detected is a good product;

[0097] The preset feature distance threshold is a value set in advance for comparison with the final distance.

[0098] In this embodiment, by comparing the final distance with the preset characteristic distance threshold, when the final distance exceeds the preset characteristic distance threshold, the object to be detected is a defective product, otherwise, the object to be detected is a good product.

[0099] See also Figure 5 , Figure 5 This is a flowchart of the steps of constructing a good product feature library in one embodiment of the present application. In one embodiment, the product surface defect detection method further includes constructing a good product feature library, including the following steps:

[0100] S501, obtaining a plurality of images of good products corresponding to the target to be detected;

[0101] S502, converting the plurality of good product images into the preset input format respectively, and inputting the images into the image correction and alignment model to obtain a plurality of good product sample images;

[0102] S503, inputting the plurality of good product sample images into the trained deep neural network feature extraction model respectively, and extracting good product feature maps corresponding to the good product sample images;

[0103] S504: Generate the good product feature library according to the good product feature images corresponding to the plurality of good product sample images.

[0104] With respect to step S501, the plurality of images of good products are images corresponding to good products among the products that are the same as the target to be inspected.

[0105] For steps S502 to S503, the remaining steps S102 to S103 are the same, please refer to the description of steps S102 to S103, which will not be repeated here.

[0106] For step S504, the good product feature library is obtained by obtaining good product feature maps corresponding to the plurality of good product sample images and saving them in a database.

[0107] In this embodiment, the good product feature library is generated by acquiring a plurality of good product images corresponding to the image to be detected, thereby improving the convenience of generating the feature library.

[0108] In one embodiment, if any final distance in the characteristic distance map exceeds a preset characteristic distance threshold, then after the target to be detected is a defective product, the following steps are further included:

[0109] Manually checking the defective product to determine whether the defective product is a good product;

[0110] If the defective product is a good product, the target feature map corresponding to the defective product is saved in the good product feature library.

[0111] In this embodiment, by manually checking the defective product, if the defective product is mistakenly judged as a defective product, that is, the defective product should actually be a good product, the target feature map corresponding to the defective product is saved in the good product feature library, the data in the good product feature library is increased, the accuracy of defect identification is improved, and the occurrence of misjudgment is reduced.

[0112] This solution provides a defect recognition method, which obtains the image to be detected corresponding to the target to be detected, sets the image to be detected to a preset format, obtains the target image through correction and alignment, inputs the target image into a trained deep neural network feature extraction model, obtains the target feature map corresponding to the target image, divides the target feature map into a number of regions of the same size according to preset specifications, and obtains the region feature vector corresponding to each region by merging the target features in each region; by obtaining the position information of each region, calculates the distance information between the region feature vector and the sample vector at the same position in the preset good product feature library, and if the distance information exceeds the preset feature distance threshold, the target to be detected is a defective product, otherwise the target to be detected is a good product. The defect recognition method in this solution uses a good product feature library for detection, which is easy to use, improves the sensitivity and work efficiency of product surface defect detection, and reduces the probability of misjudgment during product surface defect detection.

[0113] See also Figure 6 , Figure 6 This is a schematic diagram of the structure of a product surface defect detection system in one embodiment of the present application. A product surface defect detection system includes:

[0114] The image acquisition module 11 is used to acquire the image to be detected corresponding to the target to be detected;

[0115] An image alignment module 12 is used to convert the image to be detected into a preset input format and input it into an image correction and alignment model to obtain a target image, wherein the target image is an image obtained by correcting and aligning the image to be detected;

[0116] A feature map acquisition module 13 is used to input the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image;

[0117] A distance calculation module 14 is used to calculate the characteristic distance between the target characteristic graph and the same position in each good product characteristic graph in a preset good product characteristic library, wherein the good product characteristic library includes a plurality of good product characteristic graphs corresponding to the product to be detected;

[0118] A distance map generating module 15 is used to obtain the minimum characteristic distance among the characteristic distances of each position as the final distance of the position, and generate a characteristic distance map corresponding to the target characteristic map;

[0119] The judgment module 16 is used to judge that if any final distance in the characteristic distance map exceeds a preset characteristic distance threshold, the target to be detected is a defective product; otherwise, the target to be detected is a good product.

[0120] It should be noted that when the product surface defect detection system provided in the above embodiment executes the defect identification method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The product surface defect detection system provided in the above embodiment is used to execute the product surface defect detection method described in the above embodiment, and its operation method and principle are the same as the product surface defect detection method recorded above, that is, the product surface defect detection system provided in the above embodiment and the product surface defect detection method belong to the same concept, and its implementation process is detailed in the above method embodiment, which will not be repeated here.

[0121] See also Figure 7 , Figure 7 Schematic diagram of a computer device for the product surface defect detection method in the embodiment of the present application. The computer device 21 includes: a control device 211, a memory 212, and a computer program 213 stored in the memory 212 and executable on the control device 211, such as a product surface defect detection program; the control device 211 executes the computer program 213 to implement the product surface defect detection method described in the above embodiment.

[0122] Among them, the control device 211 includes a processor, and the processor may include one or more processing cores. The processor uses various interfaces and lines to connect various parts in the computer device 21, and executes various functions and processes data of the computer device 21 by running or executing instructions, programs, code sets or instruction sets stored in the memory 212, and calling the data in the memory 212. Optionally, the processor can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the touch display; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor, but implemented by a single chip.

[0123] Among them, the memory 212 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 212 includes a non-transitory computer-readable storage medium. The memory 212 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 212 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 212 may also be optionally at least one storage device located away from the aforementioned processor.

[0124] An embodiment of the present application also provides a computer-readable storage medium, which can store multiple instructions. The instructions are suitable for loading and executing the method steps of the above embodiment by a control device. The specific execution process can be found in the specific description of the above embodiment, which will not be repeated here.

[0125] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A method for detecting surface defects of a product, characterized in that: The following steps are involved: Obtaining an image to be detected corresponding to the target to be detected; Convert the format of the image to be detected into a preset input format, and input it into an image correction and alignment model to obtain a target image, wherein the target image is an image obtained by correcting and aligning the image to be detected; Inputting the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image; Calculating the characteristic distance between the target characteristic graph and the same position in each characteristic graph of a preset good product characteristic library, wherein the good product characteristic library includes a plurality of good product characteristic graphs corresponding to the product to be inspected; Obtaining the minimum feature distance among the feature distances of each position as the final distance of the position, and generating a feature distance map corresponding to the target feature map; If any final distance in the feature distance map exceeds a preset feature distance threshold, the target to be detected is a defective product; otherwise, the target to be detected is a good product.

2. The product surface defect detection method according to claim 1, characterized in that: Calculating the characteristic distance between the target characteristic map and the same position in each good product characteristic map in a preset good product characteristic library comprises the following steps: Dividing the target feature map into a number of regions of equal size according to preset specifications, and merging the image features of each region into a regional feature vector; The position information of each region is obtained, and based on the position information, the characteristic distance between each regional feature vector and the regional feature vector sample at the corresponding position in the preset good product feature library is calculated.

3. The product surface defect detection method according to claim 1, characterized in that: Calculating the characteristic distance between the target characteristic map and the same position in each good product characteristic map in a preset good product characteristic library comprises the following steps: Convert the target feature map into a feature vector of shape [1, C, H, W], where C is the number of channels, H is the image height, and W is the image width; Obtain several good product feature maps in the good product feature library, and merge the several good product feature maps into a tensor with a shape of [N, C, H, W], where N is the batch size, C is the number of channels, H is the image height, and W is the image width; The distance between the feature vector and the same position of the tensor is calculated by parallel processing to obtain the feature distance.

4. The product surface defect detection method according to claim 1, characterized in that: The format of the image to be detected is converted into a preset input format and input into the image correction and alignment model to obtain the target image, including the following steps: Converting the format of the image to be detected into a preset input format; Comparing the image to be detected with a preset template image to generate an image transformation matrix; The image transformation matrix is ​​used to perform image transformation on the image to be detected to obtain the target image.

5. The product surface defect detection method according to claim 1, characterized in that: It also includes training the deep neural network feature extraction model, including the following steps: Acquire a number of good product images and defective product images corresponding to the target to be detected, and generate a model training data set; Converting the model training data set into triple data, wherein the triple data includes anchor data, positive sample data, and negative sample data; Inputting the triplet data into the deep neural network feature extraction model to obtain a vector representation of the triplet data; According to the vector representation, calculate a first distance between the anchor point data and the positive sample data and a second distance between the anchor point data and the negative sample data, and calculate a model loss value according to a triplet loss function, the first distance and the second distance; According to the model loss value, updating the model parameters of the deep neural network feature extraction model; The above steps are executed repeatedly. If the number of cycles exceeds the preset number, the training of the deep neural network feature extraction model is completed.

6. The product surface defect detection method according to claim 1, characterized in that: It also includes building a good product feature library, including the following steps: Acquire a number of good product images corresponding to the target to be detected; Convert the plurality of good product images into the preset input format respectively, and input them into the image correction and alignment model to obtain a plurality of good sample images; Inputting the plurality of good product sample images into the trained deep neural network feature extraction model respectively, and extracting good product feature maps corresponding to the good product sample images; The good product feature library is generated according to the good product feature images corresponding to the plurality of good product sample images.

7. The product surface defect detection method according to claim 1, characterized in that: When the target to be detected is a defective product, the following steps are also included: Manually checking the defective product to determine whether the defective product is a good product; If the defective product is a good product, the target feature map corresponding to the defective product is saved in the good product feature library.

8. A product surface defect detection system, characterized in that: include: An image acquisition module is used to acquire an image to be detected corresponding to the target to be detected; An image alignment module, used to convert the image to be detected into a preset input format and input it into an image correction and alignment model to obtain a target image, wherein the target image is an image obtained by correcting and aligning the image to be detected; A feature map acquisition module is used to input the target image into a trained deep neural network feature extraction model to extract a target feature map corresponding to the target image; A distance calculation module, used to calculate the characteristic distance between the target characteristic map and the same position in each good product characteristic map in a preset good product characteristic library, wherein the good product characteristic library includes a plurality of good product characteristic maps corresponding to the product to be detected; A distance map generation module is used to obtain the minimum feature distance among the feature distances of each position as the final distance of the position, and generate a feature distance map corresponding to the target feature map; The judgment module is used to judge that if any final distance in the characteristic distance map exceeds a preset characteristic distance threshold, the target to be detected is a defective product; otherwise, the target to be detected is a good product.

9. A computer device comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the product surface defect detection method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the product surface defect detection method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Face recognition method and device and storage medium

    CN112232117A

  • Printed matter defect detection method based on feature registration and gradient shape matching fusion

    CN112508826A

  • Image scene change detection method and system and electronic equipment

    CN113449690A

Cited By

  • Method for generating Few-Shot defect image employing surface analysis of steel and textile

    KR103054388B1

  • Defect detection method and apparatus, and electronic device and storage medium

    WO2026157324A1