A defect pattern recognition method, device, electronic device and storage medium

Through unsupervised learning and data enhancement technology, we build an unsupervised pre-training model and a classification fine-tuning model, which solves the problem of low accuracy and low efficiency of defect pattern recognition in industrial production, and achieves efficient identification and low-cost defect pattern recognition, which is suitable for Suitable for high yield and multi-model low-volume production scenarios.

CN113591948BActive Publication Date: 2024-09-27TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110808135.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-16
Publication Date
2024-09-27
Estimated Expiration
2041-07-16

AI Technical Summary

Technical Problem

Existing defect pattern recognition methods have problems in industrial production such as low recognition accuracy, low efficiency, poor model generalization ability, and the need for a large number of manually annotated images as training data. They are especially difficult to be effective in high yield and multi-model small batch production scenarios. Identify defects.

Method used

Using an unsupervised learning method, by building an unsupervised pre-training model and a classification fine-tuning model, using unlabeled data sets for pre-training, we can obtain rich product feature representations, and perform defect pattern recognition with minimal manual supervision cost, using K nearest neighbor recursion Transfer algorithms and data augmentation techniques to improve model robustness and generalization capabilities.

Benefits of technology

It significantly improves the accuracy and efficiency of defect pattern recognition, reduces labor costs, and can effectively identify product defects in industrial production. It is suitable for high yield and multi-model small batch production scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113591948B
    Figure CN113591948B
Patent Text Reader

Abstract

The present disclosure proposes a defect pattern recognition method, device, electronic device and storage medium, which belong to the fields of defect detection technology and unsupervised learning technology. The method includes: collecting product images in the production process; identifying the defect pattern of the product in the product image according to a preset defect pattern recognition model; the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product. The present disclosure effectively improves the recognition accuracy and efficiency of defect patterns and can greatly reduce labor costs, and has great application prospects in industrial production.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the technical field of defect detection and the technical field of unsupervised learning, and in particular relates to a defect pattern recognition method, device, electronic device and storage medium.

[0002] Background Field

[0003] In industrial manufacturing, since the production process is a complex process with multiple coupled factors and is easily affected by external environment and human factors, various defect modes often appear in the products on the production line, which not only affects the appearance of the products, but also has a great impact on the quality and life of the products. Any abnormality in the production process will lead to product defects, and the generation of some typical defect modes can often be associated with the source of production line failure. Therefore, accurate identification of various defect modes of products can assist in monitoring the source of failure on the production line, so as to timely adjust and improve the corresponding production parameters and avoid huge losses caused by the appearance of large quantities of defective products. Timely identification of defect modes of abnormal products is an effective way to improve production quality and production efficiency, so the defect mode recognition method has very important research significance.

[0004] Early product defect pattern recognition was mainly carried out through machine learning methods, such as support vector machines and back propagation networks. Compared with directly identifying product defects with the naked eye, these methods greatly reduce the workload. However, these early methods have the following shortcomings: low recognition accuracy and require a large amount of labeled data to train the model. In recent years, with the development of deep learning, a large number of algorithms based on convolutional neural networks have shined in visual tasks. Because convolutional neural networks have very powerful feature extraction capabilities, they have achieved remarkable results in the field of image recognition. At the same time, convolutional neural networks have also been widely used in defect detection tasks.

[0005] Compared with traditional machine learning methods, deep learning methods based on convolutional neural networks have higher recognition accuracy and work efficiency in the field of defect recognition. However, this method has the same disadvantages as machine learning methods. Model training requires a large amount of labeled data, and images with defect pattern labels are not easy to obtain, because obtaining images with product defect pattern labels requires manual supervision, that is, a large number of experienced professionals are required to perform manual annotation, which is very expensive and time-consuming. In addition, when manually annotating a large number of product defect patterns, it is easy to be affected by subjective factors, resulting in the model being trained under the wrong labels, affecting the accuracy of the model in identifying product defect patterns. In addition to the difficulty in obtaining a large number of annotations, in some highly automated production scenarios, the yield of products is particularly high, and it is very time-consuming to collect defect samples. Most of the current deep learning methods for defect detection are based on defect samples to establish models. The lack of defect samples makes it difficult for the model to go online. In addition to the difficulty in collecting defect samples due to the high product yield, for some industries such as the automotive industry, where small-batch production scenarios with multiple models (each model is only produced for a few days), a certain model of product is no longer produced before the defect sample collection is completed. In this scenario, the technical route based on defect sample modeling cannot be used. In addition, since defects are caused by uncontrolled factors in the production process, the forms of defects are diverse, and it is difficult to collect complete samples of various forms. This also makes it difficult to control the missed detection of defects to zero using methods based on defect sample model building. Summary of the invention

[0006] The purpose of the present invention is to solve the problems of low efficiency and accuracy of existing defect pattern recognition methods, poor model generalization ability, and the need for a large number of time-consuming and labor-intensive manually labeled images as training data, and propose a defect pattern recognition method, device, electronic device and storage medium. The present invention effectively improves the recognition accuracy and efficiency of defect patterns and can greatly reduce labor costs, and has great application prospects in industrial production.

[0007] The first embodiment of the present disclosure provides a defect pattern recognition method, including:

[0008] Collect images of products during production;

[0009] According to a preset defect pattern recognition model, the defect pattern of the product in the product image is identified; wherein the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product.

[0010] In one embodiment of the present disclosure,

[0011] Before identifying the defect pattern of the product in the product image according to the preset defect pattern recognition model, the method further includes:

[0012] Training the defect pattern recognition model;

[0013] Wherein, the training of the defect pattern recognition model comprises:

[0014] Acquire a dataset of images of the product during the production process, wherein the images include defective images and normal images of the product;

[0015] Dividing the data set into an unlabeled data set and a labeled data set; wherein the labeled data set includes an image and a defect pattern of the product in the image;

[0016] Constructing an unsupervised pre-training model, and using the unlabeled data set to train the unsupervised pre-training model to obtain parameters of the unsupervised pre-training model;

[0017] A classification fine-tuning model is constructed, the parameters of the unsupervised pre-training model are used as initialization parameters of the classification fine-tuning model, the classification fine-tuning model is trained using the label data set, and the trained classification fine-tuning model is used as a defect pattern recognition model.

[0018] In one embodiment of the present disclosure, the step of training the classification fine-tuning model using the label data set includes:

[0019] Divide the labeled data set into a training set, a validation set, and a test set according to a set ratio;

[0020] Setting the loss function of the classification fine-tuning model;

[0021] According to the loss function, the classification fine-tuning model is trained using the training set in the label data set until a set number of iterations is reached to obtain a trained classification fine-tuning model;

[0022] The verification set is used to detect the accuracy of the trained classification fine-tuning model, and the classification fine-tuning model with the highest recognition accuracy on the verification set is selected as the defect pattern recognition model.

[0023] In one embodiment of the present disclosure, before using the unlabeled data set to train the unsupervised pre-training model, it also includes performing image enhancement on the images in the unlabeled data set;

[0024] Before using the training set in the label data set to train the classification fine-tuning model, the method further includes performing image enhancement on the images in the training set in the label data set;

[0025] The image enhancement includes: one or more of translation, flipping, random noise addition, rotation and cropping.

[0026] In one embodiment of the present disclosure, the step of training the unsupervised pre-training model using the unlabeled dataset includes:

[0027] Taking each image in the unlabeled dataset as a target sample;

[0028] According to the K-nearest neighbor recursive transfer algorithm, the unlabeled data set is mapped to a low dimension to obtain a corresponding low-dimensional data set, and samples belonging to the same defect mode as the target sample are found from the low-dimensional data set to form a positive sample set of the target sample;

[0029] Using the positive sample set of the target sample, a difficult positive sample set and a difficult negative sample set of the target sample are obtained from the low-dimensional data set by sampling;

[0030] Constructing a loss function for each image in the unlabeled dataset according to the difficult positive sample set and the difficult negative sample set;

[0031] According to the loss function, the unlabeled data set is input into the classification fine-tuning model for training, and a set number of iterations is reached to obtain a trained unsupervised pre-training model.

[0032] In one embodiment of the present disclosure, the K nearest neighbor recursive propagation algorithm includes:

[0033] The unlabeled dataset is denoted as A = {a i}, map the unlabeled dataset to a low-dimensional set B = {b i}, i = {1, 2, ..., n}, where n is the total number of images in the unlabeled dataset;

[0034] Any image a in the unlabeled dataset i The probability of being identified as the rth type of defect mode is:

[0035]

[0036] in, is the characteristic of the rth defect mode, b i is the i-th image a in the unlabeled dataset i After mapping to low-dimensional data, is the defect feature of the current batch of images, τ is the temperature coefficient of the unsupervised model;

[0037] The a iAs the target sample, according to the calculated probability, a sample composition a having the same defect mode category as the target sample is obtained from the low-dimensional set B. i The positive sample set H(i);

[0038] The specific method of the sampling is:

[0039] Select the sample a from the positive sample set H(i) that matches the target sample a i The Q samples with the lowest similarity under the same defect mode constitute a i The difficult positive sample set H p (i) Selecting samples with similar characteristics to the target sample in other defect modes from the low-dimensional set B to form a i The difficult negative sample set H n (i); Select b from the low-dimensional set B i The Z adjacent samples constitute the target sample a i The adjacent sample set H z (i) wherein the H z (i) including the H n (i) Some negative samples; then the target sample a i The difficult negative sample set is expressed as: H n (i) = H z (i)-H(i).

[0040] In one embodiment of the present disclosure, the loss function of each image in the unlabeled dataset is:

[0041]

[0042] in, For the set H p (i) Sample image features, is the set H n (i)∪H p Sample image features in (i).

[0043] A second aspect of the present disclosure provides a defect pattern recognition device, including:

[0044] A collection module, used to collect product images during the production process;

[0045] An identification module is used to identify the defect pattern of the product in the product image according to a preset defect pattern recognition model; wherein the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product.

[0046] A third aspect of the present disclosure provides an electronic device, including:

[0047] at least one processor; and a memory communicatively coupled to the at least one processor;

[0048] The memory stores instructions executable by the at least one processor, and the instructions are configured to execute the above-mentioned defect pattern recognition method.

[0049] The fourth aspect of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the above-mentioned defect pattern recognition method.

[0050] The characteristics and beneficial effects of the present disclosure are:

[0051] The present disclosure is based on unsupervised learning, and an unsupervised pre-training model and a defect classification fine-tuning model are established in the learning process. By using unlabeled images to pre-train the unsupervised pre-training model, a rich product feature representation can be obtained to make full use of the easily accessible unlabeled images. The parameters of the unsupervised pre-trained model can be used as the initialization parameters of the defect classification fine-tuning model, so that the product features learned by the unsupervised pre-training model can be widely transferred to the downstream defect classification fine-tuning model. This is a new strategy for defect pattern recognition with minimal manual supervision cost.

[0052] The present disclosure uses an unsupervised pre-training model based on the invariance propagation method, which does not require professionals to annotate a large number of images, and can significantly reduce the human impact and labor costs caused by manual supervision. In addition, the use of an unsupervised model for pre-training can better extract image features and effectively improve the accuracy of defect pattern recognition.

[0053] This paper uses a variety of data enhancement methods to avoid the problem that the model has insufficient generalization ability for defect categories with a small proportion and overfitting for defect categories with a large proportion due to category imbalance in the data set. This improves the universality of the model and enhances the robustness of the model.

[0054] The present invention provides a defect pattern recognition method and device based on unsupervised learning that can be actually applied to industrial sites, effectively improving recognition accuracy and efficiency and greatly reducing labor costs, and has great application prospects in industrial production. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 The figure is an overall flow chart of a defect pattern recognition method according to an embodiment of the present disclosure.

[0056] Figure 2This is a graph of an 18-layer residual neural network in the disclosed embodiment.

[0057] Figure 3 It is a visualization process diagram of the recursive transmission of the K nearest neighbor algorithm in the embodiment of the present disclosure. DETAILED DESCRIPTION

[0058] The present disclosure provides a defect pattern recognition method, device, electronic device and storage medium, which are further described in detail below with reference to the accompanying drawings and specific embodiments.

[0059] The first embodiment of the present disclosure proposes a defect pattern recognition method, the overall process is as follows Figure 1 As shown, the following steps are included:

[0060] Step 1. Obtaining a data set: Collect image data of any product on an actual production line, including various defective images and normal images of the product that appear during the production process (the normal image means that the product has no defects).

[0061] Step 2. Divide the data set obtained in step 1: divide the product images in the data set into an unlabeled data set and a labeled data set according to a set ratio (in one embodiment of the present disclosure, the ratio is set to 8:2, and the unlabeled data should be more than the labeled data), wherein the labeled data set is manually annotated with the defect mode (including various defects and no defects) corresponding to each product image. The unlabeled data set is used as the training set of the pre-trained model. The labeled data set is used for training, verification and testing of the classification fine-tuning model, wherein the labeled data set is divided into a training set, a verification set and a test set according to a set ratio (in one embodiment of the present disclosure, the ratio is set to 8:1:1);

[0062] The different probabilities of occurrence of various defect modes in the actual production process lead to a large difference in the number of images of various defect modes in the collected data set. The serious imbalance problem in the data set leads to insufficient generalization ability of the model for small-proportion image categories and overfitting for large-proportion image categories. In response to this problem, data enhancement is performed on the two training set images in step 2 to balance the large difference in the number of images of each type of defect mode in the data set and improve the robustness of the model. The data enhancement algorithm expands the images of specific defect modes while retaining the high-level semantic features of the images. In order to avoid the model from being too dependent on similar data, an embodiment of the present disclosure uses five data enhancement methods: translation, flipping, random noise addition, rotation and cropping. Image translation is moving in the vertical or horizontal direction (or in both directions at the same time). Flipping is different from 180-degree rotation and is a spatial flip similar to a mirror. Since the model is prone to overfitting when learning high-frequency features, noise is randomly added to the data set to eliminate the overfitting problem caused by high-frequency features. Rotation is to randomly rotate the image clockwise or counterclockwise. Cropping is to randomly select a part of the image and cut it off, and then adjust it to the size of the original image.

[0063] Step 3. Build an unsupervised pre-training model based on the invariance propagation method and set the loss function of the model;

[0064] The constructed unsupervised pre-training model structure mainly includes:

[0065] by Figure 2 The 18-layer residual neural network shown is the backbone network. The convolution kernel size of the first convolution layer is 3*3, the number of channels is 3, and the step length is 1. The input of this convolution layer is the image in the unlabeled dataset in step 2. A maximum pooling layer is set after the first convolution layer, and the convolution kernel size is 3*3 and the step length is 2. A residual module is set for every two convolution layers in the 2nd to 17th convolution layers, and every two residual modules constitute a convolution group, with a total of 4 convolution groups. The convolution kernel size of the first convolution group is 3*3, the number of channels is 64, and the step length is 1; the convolution kernel size of the second convolution group is 3*3, the number of channels is 128, and the step length is 2; the convolution kernel size of the third convolution group is 3*3, the number of channels is 256, and the step length is 2; the convolution kernel size of the fourth convolution group is 3*3, the number of channels is 521, and the step length is 2. An average pooling layer and a fully connected layer are set in sequence after the 17th convolutional layer.

[0066] The unsupervised pre-training model obtains image features through the K nearest neighbor recursive transfer algorithm during the learning process. In the feature space of the unlabeled dataset image samples input by the model, any image sample is taken as the target sample. If the K nearest image samples of the target sample all belong to the same type of defect mode, then the target sample can also be considered as an image sample belonging to this type of defect mode. Through this process, the feature representation of this type of defect mode in different image samples can be widely found. The specific implementation process is as follows: Define an unlabeled dataset A = {a i}, and then map the unlabeled dataset to a low-dimensional set B = {b i} (2-dimensional in this embodiment), i = {1, 2, ..., n}, where n is the total number of images in the unlabeled dataset; after dimensionality reduction, image samples with the same semantic features of defect patterns are clustered, and image samples with different semantic features are separated. The probability of any image in the unlabeled dataset being identified as the rth type of defect pattern is defined as:

[0067]

[0068] Here is the characteristic of the rth defect mode, b i is the i-th image a in the unlabeled dataset i After mapping to low-dimensional data, is the defect feature of the current batch of images, and τ is the temperature coefficient of the unsupervised model.

[0069] Any a i As the target sample, the defect pattern probability is calculated for the low-dimensional mapping set B of the data set A through the above method, and the samples with the same defect pattern category as the target sample are obtained from the low-dimensional set B. The images with the same defect pattern category as the target sample in the data set A can be found. i Samples under the same defect mode constitute target sample a i The K nearest neighbor algorithm finds more positive samples belonging to H(i) in the feature space, and sets a very small K value in the model to ensure high image semantic consistency. Different instances of the same defect pattern can be found in the continuous recursive transmission process of the K nearest neighbor algorithm. More different image samples can enable the pre-trained model to better learn defect representation features, and the learned intra-class semantics are richer and not affected by intra-class image changes.

[0070] Figure 3 It is a visualization process diagram of the recursive transmission of the K nearest neighbor algorithm in the embodiment of the present disclosure. Figure 3 The whole process is visually demonstrated. Figure 3The points in represent all samples in the low-dimensional mapping set B, where the black points are target samples and the gray points are samples with the same defect pattern as the target samples. Figure 3 As shown in (a), firstly, a target sample is randomly selected from set B; Figure 3 As shown in (b), after the K-nearest neighbor algorithm, samples with the same defect pattern as the target sample begin to be discovered; Figure 3 As shown in (c), the K-nearest neighbor algorithm finds more samples with the same defect pattern as the target sample. In each step of the K-nearest neighbor recursive transfer, the image samples found to have the same defect pattern (i.e., the defect pattern of the target sample) are added to the positive sample set H(i) of the target sample. Product images with the same defect pattern stay in the same high-density area, and samples with the same defect pattern will be more consistent.

[0071] In view of the defect image data features, the present disclosure uses a new sampling method. The sampling process regards samples of the same defect pattern with a low degree of similarity to the target sample image as difficult positive samples, and makes the target sample more consistent with the difficult positive samples of the same defect pattern. Through the hard sampling process, the model can fully obtain the consistent representation features between different images within the same defect pattern.

[0072] The K-nearest neighbor algorithm can be used to find images belonging to the same type of defect pattern in the unlabeled data set;

[0073] After obtaining H(i) of each target sample through the K nearest neighbor algorithm, further sampling is performed in the low-dimensional set to obtain the difficult positive sample set and the difficult negative sample set corresponding to the target sample; in the embodiment of the present disclosure, the specific implementation process of this sampling method is as follows:

[0074] Construct a difficult positive sample set H corresponding to the target sample p (i) (the difficult positive sample set H p (i) belongs to the positive sample set H(i)), which includes Q samples with the lowest similarity to the target sample in the same defect mode. The samples in the difficult positive sample set are very different from the target sample features, so they can provide more different representation features in the same defect mode, which is helpful for the learning of the pre-trained model. Accordingly, samples with similar features to the target sample in other defect modes are selected from the low-dimensional set B to form the target sample a. i The difficult negative sample set H n (i). Put the low-dimensional b i The Z adjacent samples of the target sample a i The adjacent sample set H z (i), where Z is set large enough so that H z (i) Includes some negative samples. So the target sample a iThe difficult negative sample set can be expressed as: H n (i) = H z (i)-H(i). Under this sampling method, each image a in the unlabeled dataset can be defined i The loss function of (the loss function is the loss function of the unsupervised pre-training model):

[0075]

[0076] Here τ is the temperature coefficient, is the set H p (i) Sample image features, is the set H n (i)∪H p Sample image features in (i).

[0077] Step 4. Input the unlabeled data set into the constructed unsupervised pre-training model for training until the set number of iterations is reached (all training set samples are trained by the model in each iteration). After the training is completed, the trained unsupervised pre-training model and the parameters of the unsupervised pre-training model are obtained.

[0078] Step 5. Construct a classification fine-tuning model, the initialization parameters of which are the parameters of the unsupervised pre-training model, and then set the loss function of the classification fine-tuning model. Use the training set in the label data set to train the classification fine-tuning model, and after a fixed number of training times, input the validation set to detect the accuracy of the classification fine-tuning model, and select the classification fine-tuning model with the highest recognition accuracy on the validation set as the defect pattern recognition model;

[0079] The backbone network of the classification fine-tuning model uses an 18-layer residual neural network. The specific structure of the network is as follows: the convolution kernel size of the first convolution layer is 3*3, the number of channels is 3, and the step size is 1. The input of this convolution layer is the label image in step 2; a maximum pooling layer is set after the first convolution layer, the convolution kernel size is 3*3, and the step size is 2; a residual module is set for every two convolution layers in the 2nd to 17th convolution layers, and every two residual modules constitute a convolution group, with a total of 4 convolution groups. The convolution kernel size of the first convolution group is 3*3, the number of channels is 64, and the step size is 1; the convolution kernel size of the second convolution group is 3*3, the number of channels is 128, and the step size is 2; the convolution kernel size of the third convolution group is 3*3, the number of channels is 256, and the step size is 2; the convolution kernel size of the fourth convolution group is 3*3, the number of channels is 521, and the step size is 2. An average pooling layer and a fully connected layer are set after the 17th convolutional layer; a softmax layer is set after the fully connected layer. The main function of the softmax layer is to map the outputs of multiple neurons to the interval (0, 1), that is, the probability of each type of defect mode corresponding to the input image. The softmax function is:

[0080]

[0081] Here w i Represents the i-th image in the label dataset.

[0082] Then define the loss function of the classification fine-tuning model. Given a training set with m different defect mode labels, use the multi-classification cross entropy loss function as the loss function L of the classification fine-tuning model:

[0083]

[0084] Here p represents the distribution of true labels, and q is the distribution of labels predicted by the model.

[0085] In order to prevent the model from overfitting, dropout is set in the fully connected layer of the classification fine-tuning model with a fixed probability of 0.5. Generally speaking, the known training data set is small. When training artificial neural networks with limited training data sets, the neural network model will have overfitting problems. Dropout is an effective technique to help reduce model overfitting;

[0086] Input the training set in the label data set into the constructed classification fine-tuning model for training until the set number of iterations is reached (all training set samples are trained by the model in each iteration). After training is completed, a trained classification fine-tuning model is obtained. Then use the validation set to detect the accuracy of the classification fine-tuning model, and select the classification fine-tuning model with the highest recognition accuracy on the validation set as the defect pattern recognition model. Step 6. Use the defect pattern recognition model obtained in step 5 to perform recognition tests on various defect pattern images and normal defect-free images in the test set to obtain the recognition accuracy of the model for the defect pattern of this product.

[0087] Step 7. Collect the product image in the actual production process, input the product image into the defect pattern recognition model, the model first outputs the probability of each defect pattern corresponding to the product in the image, and then the model automatically selects the defect pattern with the highest probability as the defect pattern recognition result of the product in the input image. In this disclosure, no defect is also a category of defect pattern.

[0088] In order to implement the above-mentioned embodiments, the second aspect of the present disclosure proposes a defect pattern recognition device, including: an acquisition module, used to acquire product images in the production process; and a recognition module, used to identify the defect pattern of the product in the product image according to a preset defect pattern recognition model; wherein the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product.

[0089] In order to implement the above-mentioned embodiments, the third aspect embodiment of the present disclosure proposes an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are configured to execute a defect pattern recognition method of the above-mentioned embodiment.

[0090] In order to implement the above-mentioned embodiments, a fourth aspect of the present disclosure provides a computer-readable storage medium on which a computer program is stored. The program is executed by a processor to execute a defect pattern recognition method of the above-mentioned embodiment.

[0091] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0092] The computer readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device. The computer readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device executes a defect pattern recognition method of the above embodiment.

[0093] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0094] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0095] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0096] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0097] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.

[0098] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0099] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0100] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above-mentioned embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above-mentioned embodiments within the scope of the present application.

Claims

1. A defect pattern recognition method, It is characterized in that include: Collect images of products during production; According to a preset defect pattern recognition model, the defect pattern of the product in the product image is recognized; wherein the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product; Wherein, before identifying the defect pattern of the product in the product image according to the preset defect pattern recognition model, the method further includes: Training the defect pattern recognition model; Wherein, the training of the defect pattern recognition model comprises: Acquire a dataset of images of the product during the production process, wherein the images include defective images and normal images of the product; Dividing the data set into an unlabeled data set and a labeled data set; wherein the labeled data set includes an image and a defect pattern of the product in the image; Constructing an unsupervised pre-training model, and using the unlabeled data set to train the unsupervised pre-training model to obtain parameters of the unsupervised pre-training model; Constructing a classification fine-tuning model, using the parameters of the unsupervised pre-training model as initialization parameters of the classification fine-tuning model, using the label data set to train the classification fine-tuning model, and using the trained classification fine-tuning model as a defect pattern recognition model; The step of training the unsupervised pre-training model using the unlabeled data set includes: Taking each image in the unlabeled dataset as a target sample; According to the K-nearest neighbor recursive transfer algorithm, the unlabeled data set is mapped to a low dimension to obtain a corresponding low-dimensional data set, and samples belonging to the same defect mode as the target sample are found from the low-dimensional data set to form a positive sample set of the target sample; Using the positive sample set of the target sample, a difficult positive sample set and a difficult negative sample set of the target sample are obtained from the low-dimensional data set by sampling; Constructing a loss function for each image in the unlabeled dataset according to the difficult positive sample set and the difficult negative sample set; According to the loss function, the unlabeled data set is input into the classification fine-tuning model for training until a set number of iterations is reached to obtain a trained unsupervised pre-training model; The K nearest neighbor recursive transfer algorithm includes: The unlabeled dataset is denoted as A = {a i }, map the unlabeled dataset to a low-dimensional set B = {b i }, i = {1, 2, ..., n}, where n is the total number of images in the unlabeled dataset; Any image a in the unlabeled dataset i The probability of being identified as the rth type of defect mode is: in, is the characteristic of the rth defect mode, b i is the i-th image a in the unlabeled dataset i After mapping to low-dimensional data, is the defect feature of the current batch of images, τ is the temperature coefficient of the unsupervised model; The a i As the target sample, according to the calculated probability, a sample composition a having the same defect mode category as the target sample is obtained from the low-dimensional set B. i The positive sample set H(i); The specific method of the sampling is: Select the sample a from the positive sample set H(i) that matches the target sample a i The Q samples with the lowest similarity under the same defect mode constitute a i The difficult positive sample set H p (i) Selecting samples with similar characteristics to the target sample in other defect modes from the low-dimensional set B to form a i The difficult negative sample set H n (i); Select b from the low-dimensional set B i The Z adjacent samples constitute the target sample a i The adjacent sample set H z (i) wherein the H z (i) including the H n (i) Some negative samples; then the target sample a i The difficult negative sample set is expressed as: H n (i) = H z (i)-H(i).

2. The method according to claim 1, It is characterized in that The step of training the classification fine-tuning model using the label data set includes: Divide the labeled data set into a training set, a validation set, and a test set according to a set ratio; Setting the loss function of the classification fine-tuning model; According to the loss function, the classification fine-tuning model is trained using the training set in the label data set until a set number of iterations is reached to obtain a trained classification fine-tuning model; The verification set is used to detect the accuracy of the trained classification fine-tuning model, and the classification fine-tuning model with the highest recognition accuracy on the verification set is selected as the defect pattern recognition model.

3. The method according to claim 2, It is characterized in that Before using the unlabeled data set to train the unsupervised pre-training model, the method further includes performing image enhancement on the images in the unlabeled data set; Before using the training set in the label data set to train the classification fine-tuning model, the method further includes performing image enhancement on the images in the training set in the label data set; The image enhancement includes: one or more of translation, flipping, random noise addition, rotation and cropping.

4. The method according to claim 3, It is characterized in that The loss function for each image in the unlabeled dataset is: in, For the set H p (i) Sample image features, is the set H n (i)∪H p Sample image features in (i).

5. A defect pattern recognition device for executing the method as claimed in claim 1, It is characterized in that include: A collection module, used to collect product images during the production process; An identification module is used to identify the defect pattern of the product in the product image according to a preset defect pattern recognition model; wherein the preset defect pattern recognition model outputs the probability of each defect pattern corresponding to the product in the product image, and selects the defect pattern with the highest probability as the defect pattern recognition result of the product.

6. An electronic device, It is characterized in that include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are configured to execute the method according to any one of claims 1 to 4.

7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 4.