Defect detection method, device, electronic equipment and storage medium

By encoding and decoding the image to be detected and the positive sample image, combined with the probability calculation of the Gaussian mixed model, the problem of large error in reconstruction images in the prior art is solved, and the accuracy of defect detection is improved.

CN114663334BActive Publication Date: 2025-05-23FU TAI HUA IND SHENZHEN +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011524958.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-22
Publication Date
2025-05-23
Estimated Expiration
2040-12-22

AI Technical Summary

Technical Problem

The existing defect detection methods have errors in the process of reconstructing images, resulting in the inability to detect subtle defects, reducing the accuracy of detection.

Method used

The image to be detected and the positive sample image are encoded by the encoder, the target vector and the latent vector are generated, and the decoder is used to decode and reconstruct the image. Then, the error between the target image and the image to be detected is compared, and the test probability and sample error of the image are calculated through the Gaussian mixed model, the error threshold is determined, and finally the image is determined.

Benefits of technology

It improves the accuracy of defect detection, can detect subtle defects, and enhances the reliability of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114663334B_ABST
    Figure CN114663334B_ABST
Patent Text Reader

Abstract

The present application relates to image detection technology, and provides a defect detection method, device, electronic device and storage medium. The method can obtain an image to be detected and multiple positive sample images, encode the image to be detected and multiple positive sample images, obtain a target vector and multiple latent vectors and decode them, obtain a target image and multiple reconstructed images, compare the target image with the image to be detected, obtain a target error, compare the reconstructed image with the positive sample image, obtain a reconstruction error, determine the test probability and test error of the image to be detected, determine the estimated probability and sample error of each positive sample image and determine the error threshold, and determine the detection result according to the test error and the error threshold. The present application can detect whether there are subtle defects in the image to be detected, and improve the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image detection technology, and in particular to a defect detection method, device, electronic device and storage medium. Background Art

[0002] In order to improve the quality of industrial products, they are usually inspected for defects before packaging. However, the current defect detection methods will produce certain errors in the image reconstruction process, which makes it impossible to detect products with minor defects, thereby reducing the accuracy of defect detection. Summary of the invention

[0003] In view of the above, it is necessary to provide a defect detection method, device, electronic device and storage medium, which can detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection.

[0004] A defect detection method, the defect detection method comprising:

[0005] When a defect detection request is received, obtaining an image to be detected and a plurality of positive sample images according to the defect detection request;

[0006] Using an encoder to encode the image to be detected to obtain a target vector corresponding to the image to be detected, and using the encoder to encode the multiple positive sample images to obtain multiple latent vectors corresponding to the multiple positive sample images;

[0007] Using a decoder corresponding to the encoder to decode the target vector to obtain a target image corresponding to the image to be detected, and using the decoder to decode the multiple latent vectors to obtain multiple reconstructed images corresponding to the multiple positive sample images;

[0008] Comparing the target image with the image to be detected to obtain a target error, and determining a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images;

[0009] Inputting the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image;

[0010] Determine a test error of the image to be detected according to the target error and the test probability, and determine a sample error of each positive sample image according to each reconstruction error and each estimated probability;

[0011] An error threshold is selected from the sample error, and a detection result of the image to be detected is determined according to the test error and the error threshold.

[0012] According to an optional embodiment of the present application, encoding the image to be detected by using an encoder to obtain a target vector corresponding to the image to be detected includes:

[0013] Performing vectorization processing on the image to be detected to obtain a first feature vector of the image to be detected;

[0014] extracting a hidden layer in the encoder;

[0015] The first feature vector is operated by using the hidden layer to obtain the target vector.

[0016] According to an optional embodiment of the present application, comparing the target image with the image to be detected to obtain a target error includes:

[0017] Extracting all pixel points of the image to be detected to obtain a plurality of pixel points to be detected, and extracting all pixel points of the target image to obtain a plurality of target pixel points;

[0018] Compare each target pixel with each pixel to be detected to obtain a comparison result;

[0019] When the comparison result indicates that the target pixel point is different from the pixel point to be detected, the number of different target pixels from the pixel point to be detected is calculated as a first number, and the number of the plurality of target pixels is calculated as a second number;

[0020] The target error is obtained by dividing the first number by the second number.

[0021] According to an optional embodiment of the present application, the step of inputting the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image includes:

[0022] Inputting the multiple latent vectors into the Gaussian mixture model to obtain feature distributions of the multiple positive sample images;

[0023] Determine the mean value and covariance of the multiple latent vectors according to the feature distribution, and obtain the mixing coefficient of the Gaussian mixture model;

[0024] The test probability of the image to be detected is determined according to the target vector, the mean value, the covariance and the mixing coefficient, and the estimated probability of each positive sample image is determined according to each latent vector, the mean value, the covariance and the mixing coefficient.

[0025] According to an optional embodiment of the present application, determining the sample error of each positive sample image according to each reconstruction error and each estimated probability includes:

[0026] Calculate the logarithm of each estimated probability to obtain the logarithm value of each estimated probability;

[0027] A weighted sum operation is performed on the inverse of each logarithmic value and each reconstruction error to obtain the sample error.

[0028] According to an optional embodiment of the present application, selecting an error threshold from the sample error includes:

[0029] Sort the sample errors in ascending order to obtain an error list and a sample sequence number for each sample error;

[0030] Calculating the number of sample errors and multiplying the number by a configuration value to obtain a target value;

[0031] A sample error whose sample number is equal to the target value is selected from the error list as the error threshold.

[0032] According to an optional embodiment of the present application, determining the detection result of the image to be detected according to the test error and the error threshold includes:

[0033] When the test error is less than the error threshold, determining the detection result as the image to be detected is flawless; or

[0034] When the test error is greater than or equal to the error threshold, the detection result is determined as the image to be detected has defects.

[0035] A defect detection device, comprising:

[0036] An acquisition unit, configured to acquire an image to be detected and a plurality of positive sample images according to a defect detection request when a defect detection request is received;

[0037] An encoding unit, configured to encode the image to be detected using an encoder to obtain a target vector corresponding to the image to be detected, and to encode the plurality of positive sample images using the encoder to obtain a plurality of latent vectors corresponding to the plurality of positive sample images;

[0038] A decoding unit, configured to decode the target vector using a decoder corresponding to the encoder to obtain a target image corresponding to the image to be detected, and decode the multiple latent vectors using the decoder to obtain multiple reconstructed images corresponding to the multiple positive sample images;

[0039] a determination unit, configured to compare the target image with the image to be detected to obtain a target error, and determine a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images;

[0040] An input unit, used to input the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and input the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image;

[0041] The determination unit is further used to determine the test error of the image to be detected according to the target error and the test probability, and to determine the sample error of each positive sample image according to each reconstruction error and each estimated probability;

[0042] The determination unit is further configured to select an error threshold from the sample error, and determine a detection result of the image to be detected according to the test error and the error threshold.

[0043] According to an optional embodiment of the present application, the encoding unit is specifically used for:

[0044] Performing vectorization processing on the image to be detected to obtain a first feature vector of the image to be detected;

[0045] extracting a hidden layer in the encoder;

[0046] The first feature vector is operated by using the hidden layer to obtain the target vector.

[0047] According to an optional embodiment of the present application, the determination unit compares the target image with the image to be detected, and obtaining the target error includes:

[0048] Extracting all pixel points of the image to be detected to obtain a plurality of pixel points to be detected, and extracting all pixel points of the target image to obtain a plurality of target pixel points;

[0049] Compare each target pixel with each pixel to be detected to obtain a comparison result;

[0050] When the comparison result indicates that the target pixel point is different from the pixel point to be detected, the number of different target pixels from the pixel point to be detected is calculated as a first number, and the number of the plurality of target pixels is calculated as a second number;

[0051] The target error is obtained by dividing the first number by the second number.

[0052] According to an optional embodiment of the present application, the input unit is specifically used for:

[0053] Inputting the multiple latent vectors into the Gaussian mixture model to obtain feature distributions of the multiple positive sample images;

[0054] Determine the mean value and covariance of the multiple latent vectors according to the feature distribution, and obtain the mixing coefficient of the Gaussian mixture model;

[0055] The test probability of the image to be detected is determined according to the target vector, the mean value, the covariance and the mixing coefficient, and the estimated probability of each positive sample image is determined according to each latent vector, the mean value, the covariance and the mixing coefficient.

[0056] According to an optional embodiment of the present application, the determining unit determines the sample error of each positive sample image according to each reconstruction error and each estimated probability, including:

[0057] Calculate the logarithm of each estimated probability to obtain the logarithm value of each estimated probability;

[0058] A weighted sum operation is performed on the inverse of each logarithmic value and each reconstruction error to obtain the sample error.

[0059] According to an optional embodiment of the present application, the determining unit selects an error threshold from the sample error including:

[0060] Sort the sample errors in ascending order to obtain an error list and a sample sequence number for each sample error;

[0061] Calculating the number of sample errors and multiplying the number by a configuration value to obtain a target value;

[0062] A sample error whose sample number is equal to the target value is selected from the error list as the error threshold.

[0063] According to an optional embodiment of the present application, the determining unit determines the detection result of the image to be detected according to the test error and the error threshold, including:

[0064] When the test error is less than the error threshold, determining the detection result as the image to be detected is flawless; or

[0065] When the test error is greater than or equal to the error threshold, the detection result is determined as the image to be detected has defects.

[0066] An electronic device, comprising:

[0067] a memory storing at least one instruction; and

[0068] A processor executes the instructions stored in the memory to implement the defect detection method.

[0069] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in an electronic device to implement the defect detection method.

[0070] It can be seen from the above technical solutions that the present application can accurately determine the error threshold by determining the reconstruction error generated during image reconstruction and by determining the estimated probability generated by the Gaussian mixture model, and then by comparing the test error with the error threshold. Since the test error and the error threshold are compared numerically, it is possible to detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] Figure 1 It is a flow chart of a preferred embodiment of the defect detection method of the present application.

[0072] Figure 2 It is a functional module diagram of a preferred embodiment of the defect detection device of the present application.

[0073] Figure 3 It is a schematic diagram of the structure of an electronic device of a preferred embodiment of the defect detection method of the present application. DETAILED DESCRIPTION

[0074] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is described in detail below with reference to the accompanying drawings and specific embodiments.

[0075] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the defect detection method of the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.

[0076] The defect detection method is applied to one or more electronic devices 1, and the electronic device 1 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.

[0077] The electronic device 1 can be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.

[0078] The electronic device 1 may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.

[0079] The network where the electronic device 1 is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0080] S10, when a defect detection request is received, obtaining an image to be detected and a plurality of positive sample images according to the defect detection request.

[0081] In at least one embodiment of the present application, the defect detection request may be triggered by a user (eg, triggered by a preset function button) or may be automatically triggered within a preset time, and the present application does not impose any limitation thereto.

[0082] The preset time may be a time point (eg, 9:00 a.m. every day) or a time period.

[0083] In at least one embodiment of the present application, the information carried in the defect detection request includes, but is not limited to: a detection object, etc.

[0084] In at least one embodiment of the present application, the electronic device acquiring the image to be detected and the plurality of positive sample images according to the defect detection request includes:

[0085] Parsing the method body of the defect detection request to obtain data information carried by the defect detection request;

[0086] Acquire a preset label, and acquire information corresponding to the preset label from the data information as the detection object;

[0087] The image to be detected is obtained from a library to be detected according to the detection object, and the plurality of positive sample images are obtained from a sample library according to the detection object.

[0088] The preset tag refers to a predefined tag, for example, the preset tag may be name.

[0089] Furthermore, the to-be-detected library stores to-be-detected images that have not been subjected to defect detection, and the sample library stores a plurality of defect-free positive sample images.

[0090] By parsing the method body of the defect detection request, the parsing time of the defect detection request can be shortened, thereby improving the parsing efficiency. Furthermore, through the mapping relationship between the preset label and the detection object, the detection object can be accurately determined, and the image to be detected and the multiple positive sample images can be accurately obtained.

[0091] S11, using an encoder to encode the image to be detected to obtain a target vector corresponding to the image to be detected, and using the encoder to encode the multiple positive sample images to obtain multiple latent vectors corresponding to the multiple positive sample images.

[0092] In at least one embodiment of the present application, the encoder may be an encoder in an autoencoder (AE). Further, the encoder includes multiple hidden layers, and the number of the multiple hidden layers can be arbitrarily set according to the application scenario.

[0093] In at least one embodiment of the present application, the electronic device uses an encoder to encode the image to be detected, and obtaining a target vector corresponding to the image to be detected includes:

[0094] Performing vectorization processing on the image to be detected to obtain a first feature vector of the image to be detected;

[0095] extracting a hidden layer in the encoder;

[0096] The first feature vector is operated by using the hidden layer to obtain the target vector.

[0097] Specifically, the electronic device uses the hidden layer to operate the first feature vector to obtain the target vector, which includes:

[0098] Obtaining a weight matrix and a bias value of the hidden layer;

[0099] Multiplying the first eigenvector by the weight matrix to obtain a calculation result;

[0100] The operation result is added to the offset value to obtain the target vector.

[0101] In other embodiments, the electronic device uses the hidden layer to operate on each second eigenvector in the same manner as the electronic device uses the hidden layer to operate on the first eigenvector, which is not described in detail in this application.

[0102] S12, using a decoder corresponding to the encoder to decode the target vector to obtain a target image corresponding to the image to be detected, and using the decoder to decode the multiple latent vectors to obtain multiple reconstructed images corresponding to the multiple positive sample images.

[0103] In at least one embodiment of the present application, the decoder may be a decoder in the autoencoder. Further, the decoder includes a computing layer corresponding to a hidden layer in the encoder.

[0104] In at least one embodiment of the present application, the electronic device uses the operation layer to operate on the target vector, and performs restoration processing on the vector obtained after the operation to obtain the target vector.

[0105] In other embodiments, the electronic device obtains the multiple reconstructed images in the same manner as the target vector, which is not described in detail in this application.

[0106] S13, comparing the target image with the image to be detected to obtain a target error, and determining a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images.

[0107] In at least one embodiment of the present application, the target error refers to an error generated when the image to be detected is reconstructed.

[0108] In at least one embodiment of the present application, the electronic device compares the target image with the image to be detected, and obtaining the target error includes:

[0109] Extracting all pixel points of the image to be detected to obtain a plurality of pixel points to be detected, and extracting all pixel points of the target image to obtain a plurality of target pixel points;

[0110] Compare each target pixel with each pixel to be detected to obtain a comparison result;

[0111] When the comparison result indicates that the target pixel point is different from the pixel point to be detected, the number of different target pixels from the pixel point to be detected is calculated as a first number, and the number of the plurality of target pixels is calculated as a second number;

[0112] The target error is obtained by dividing the first number by the second number.

[0113] Through the above implementation, the target error can be accurately determined.

[0114] In other embodiments, the electronic device determines the reconstruction error of each positive sample image in the same manner as the target error, which is not described in detail in this application.

[0115] S14, inputting the target vector into a pre-trained Gaussian mixture model (GMM) to obtain the test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain the estimated probability of each positive sample image.

[0116] In at least one embodiment of the present application, the Gaussian mixture model refers to an open source mixture model, and the Gaussian mixture model includes multiple single Gaussian models.

[0117] In at least one embodiment of the present application, the electronic device inputs the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputs the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image, including:

[0118] Inputting the multiple latent vectors into the Gaussian mixture model to obtain feature distributions of the multiple positive sample images;

[0119] Determine the mean value and covariance of the multiple latent vectors according to the feature distribution, and obtain the mixing coefficient of the Gaussian mixture model;

[0120] The test probability of the image to be detected is determined according to the target vector, the mean value, the covariance and the mixing coefficient, and the estimated probability of each positive sample image is determined according to each latent vector, the mean value, the covariance and the mixing coefficient.

[0121] Through the above implementation, the test probability and the estimated probability can be accurately determined.

[0122] S15, determining a test error of the image to be detected according to the target error and the test probability, and determining a sample error of each positive sample image according to each reconstruction error and each estimated probability.

[0123] In at least one embodiment of the present application, the electronic device determines the sample error of each positive sample image according to each reconstruction error and each estimated probability, including:

[0124] Calculate the logarithm of each estimated probability to obtain the logarithm value of each estimated probability;

[0125] A weighted sum operation is performed on the inverse of each logarithmic value and each reconstruction error to obtain the sample error.

[0126] For example: the estimated probability is 0.01, the reconstruction error is 0.03, the logarithm of the estimated probability is calculated, and the logarithm value is: log(0.01)=-2, the opposite of the logarithm is calculated, and the value is 2, and the weighted sum of 2 and 0.03 is calculated. When the estimated probability accounts for 20% of the sample error and the reconstruction error accounts for 80% of the sample error, the sample error is calculated to be: 2*20%+0.03*80%=0.424.

[0127] Through the above implementation, the error range generated by the image reconstruction process and the probability distribution can be determined.

[0128] S16, selecting an error threshold from the sample error, and determining a detection result of the image to be detected according to the test error and the error threshold.

[0129] In at least one embodiment of the present application, the detection result includes whether the image to be detected has defects or whether the image to be detected has no defects.

[0130] In at least one embodiment of the present application, the electronic device selecting an error threshold from the sample error includes:

[0131] Sort the sample errors in ascending order to obtain an error list and a sample sequence number for each sample error;

[0132] Calculating the number of sample errors and multiplying the number by a configuration value to obtain a target value;

[0133] A sample error whose sample number is equal to the target value is selected from the error list as the error threshold.

[0134] Through the above implementation, the errors that affect the image reconstruction process and probability distribution can be determined.

[0135] In at least one embodiment of the present application, the electronic device determines the detection result of the image to be detected according to the test error and the error threshold, including:

[0136] When the test error is less than the error threshold, determining the detection result as the image to be detected is flawless; or

[0137] When the test error is greater than or equal to the error threshold, the detection result is determined as the image to be detected has defects.

[0138] By comparing the test error with the error threshold, since the test error and the error threshold are compared numerically, it is possible to detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection.

[0139] In at least one embodiment of the present application, when the image to be detected has defects, the electronic device generates reminder information according to the image to be detected, and sends the reminder information to a terminal device of a designated contact.

[0140] The designated contact person may be a quality control personnel responsible for testing the test object.

[0141] Through the above implementation, when there is a defect in the image to be detected, the designated contact person can be notified in time.

[0142] It can be seen from the above technical solutions that the present application can accurately determine the error threshold by determining the reconstruction error generated during image reconstruction and by determining the estimated probability generated by the Gaussian mixture model, and then by comparing the test error with the error threshold. Since the test error and the error threshold are compared numerically, it is possible to detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection.

[0143] like Figure 2 , which is a functional module diagram of a preferred embodiment of the defect detection device of the present application. The defect detection device 11 includes an acquisition unit 110, an encoding unit 111, a decoding unit 112, a determination unit 113, an input unit 114 and a generation unit 115. The module / unit referred to in the present application refers to a series of computer program segments that can be acquired by the processor 13 and can perform fixed functions, which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0144] When receiving a defect detection request, the acquisition unit 110 acquires the image to be detected and a plurality of positive sample images according to the defect detection request.

[0145] In at least one embodiment of the present application, the defect detection request may be triggered by a user (eg, triggered by a preset function button) or may be automatically triggered within a preset time, and the present application does not impose any limitation thereto.

[0146] The preset time may be a time point (eg, 9:00 a.m. every day) or a time period.

[0147] In at least one embodiment of the present application, the information carried in the defect detection request includes, but is not limited to: a detection object, etc.

[0148] In at least one embodiment of the present application, the acquiring unit 110 acquires the image to be detected and the plurality of positive sample images according to the defect detection request, including:

[0149] Parsing the method body of the defect detection request to obtain data information carried by the defect detection request;

[0150] Acquire a preset label, and acquire information corresponding to the preset label from the data information as the detection object;

[0151] The image to be detected is obtained from a library to be detected according to the detection object, and the plurality of positive sample images are obtained from a sample library according to the detection object.

[0152] The preset tag refers to a predefined tag, for example, the preset tag may be name.

[0153] Furthermore, the to-be-detected library stores to-be-detected images that have not been subjected to defect detection, and the sample library stores a plurality of defect-free positive sample images.

[0154] By parsing the method body of the defect detection request, the parsing time of the defect detection request can be shortened, thereby improving the parsing efficiency. Furthermore, through the mapping relationship between the preset label and the detection object, the detection object can be accurately determined, and the image to be detected and the multiple positive sample images can be accurately obtained.

[0155] The encoding unit 111 uses an encoder to encode the image to be detected to obtain a target vector corresponding to the image to be detected, and uses the encoder to encode the multiple positive sample images to obtain multiple latent vectors corresponding to the multiple positive sample images.

[0156] In at least one embodiment of the present application, the encoder may be an encoder in an autoencoder (AE). Further, the encoder includes multiple hidden layers, and the number of the multiple hidden layers can be arbitrarily set according to the application scenario.

[0157] In at least one embodiment of the present application, the encoding unit 111 uses an encoder to encode the image to be detected, and obtaining a target vector corresponding to the image to be detected includes:

[0158] Performing vectorization processing on the image to be detected to obtain a first feature vector of the image to be detected;

[0159] extracting a hidden layer in the encoder;

[0160] The first feature vector is operated by using the hidden layer to obtain the target vector.

[0161] Specifically, the encoding unit 111 uses the hidden layer to operate the first feature vector to obtain the target vector including:

[0162] Obtaining a weight matrix and a bias value of the hidden layer;

[0163] Multiplying the first eigenvector by the weight matrix to obtain a calculation result;

[0164] The operation result is added to the offset value to obtain the target vector.

[0165] In other embodiments, the encoding unit 111 uses the hidden layer to operate each second feature vector in the same manner as the encoding unit 111 uses the hidden layer to operate the first feature vector, which is not described in detail in this application.

[0166] The decoding unit 112 uses a decoder corresponding to the encoder to decode the target vector to obtain a target image corresponding to the image to be detected, and uses the decoder to decode the multiple latent vectors to obtain multiple reconstructed images corresponding to the multiple positive sample images.

[0167] In at least one embodiment of the present application, the decoder may be a decoder in the autoencoder. Further, the decoder includes a computing layer corresponding to a hidden layer in the encoder.

[0168] In at least one embodiment of the present application, the decoding unit 112 uses the operation layer to operate on the target vector, and performs restoration processing on the vector obtained after the operation to obtain the target vector.

[0169] In other embodiments, the decoding unit 112 obtains the multiple reconstructed images in the same manner as the target vector, which is not described in detail in this application.

[0170] The determination unit 113 compares the target image with the image to be detected to obtain a target error, and determines a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images.

[0171] In at least one embodiment of the present application, the target error refers to an error generated when the image to be detected is reconstructed.

[0172] In at least one embodiment of the present application, the determination unit 113 compares the target image with the image to be detected, and obtaining the target error includes:

[0173] Extracting all pixel points of the image to be detected to obtain a plurality of pixel points to be detected, and extracting all pixel points of the target image to obtain a plurality of target pixel points;

[0174] Compare each target pixel with each pixel to be detected to obtain a comparison result;

[0175] When the comparison result indicates that the target pixel point is different from the pixel point to be detected, the number of different target pixels from the pixel point to be detected is calculated as a first number, and the number of the plurality of target pixels is calculated as a second number;

[0176] The target error is obtained by dividing the first number by the second number.

[0177] Through the above implementation, the target error can be accurately determined.

[0178] In other embodiments, the determination unit 113 determines the reconstruction error of each positive sample image in the same manner as the target error, which will not be described in detail in this application.

[0179] The input unit 114 inputs the target vector into a pre-trained Gaussian mixture model (GMM) to obtain the test probability of the image to be detected, and inputs the multiple latent vectors into the Gaussian mixture model to obtain the estimated probability of each positive sample image.

[0180] In at least one embodiment of the present application, the Gaussian mixture model refers to an open source mixture model, and the Gaussian mixture model includes multiple single Gaussian models.

[0181] In at least one embodiment of the present application, the input unit 114 inputs the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputs the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image, including:

[0182] Inputting the multiple latent vectors into the Gaussian mixture model to obtain feature distributions of the multiple positive sample images;

[0183] Determine the mean value and covariance of the multiple latent vectors according to the feature distribution, and obtain the mixing coefficient of the Gaussian mixture model;

[0184] The test probability of the image to be detected is determined according to the target vector, the mean value, the covariance and the mixing coefficient, and the estimated probability of each positive sample image is determined according to each latent vector, the mean value, the covariance and the mixing coefficient.

[0185] Through the above implementation, the test probability and the estimated probability can be accurately determined.

[0186] The determination unit 113 determines the test error of the image to be detected according to the target error and the test probability, and determines the sample error of each positive sample image according to each reconstruction error and each estimated probability.

[0187] In at least one embodiment of the present application, the determining unit 113 determines the sample error of each positive sample image according to each reconstruction error and each estimated probability, including:

[0188] Calculate the logarithm of each estimated probability to obtain the logarithm value of each estimated probability;

[0189] A weighted sum operation is performed on the inverse of each logarithmic value and each reconstruction error to obtain the sample error.

[0190] For example: the estimated probability is 0.01, the reconstruction error is 0.03, the logarithm of the estimated probability is calculated, and the logarithm value is: log(0.01)=-2, the opposite of the logarithm is calculated, and the value is 2, and the weighted sum of 2 and 0.03 is calculated. When the estimated probability accounts for 20% of the sample error and the reconstruction error accounts for 80% of the sample error, the sample error is calculated to be: 2*20%+0.03*80%=0.424.

[0191] Through the above implementation, the error range generated by the image reconstruction process and the probability distribution can be determined.

[0192] The determination unit 113 selects an error threshold from the sample error, and determines a detection result of the image to be detected according to the test error and the error threshold.

[0193] In at least one embodiment of the present application, the detection result includes whether the image to be detected has defects or whether the image to be detected has no defects.

[0194] In at least one embodiment of the present application, the determining unit 113 selects an error threshold from the sample error including:

[0195] Sort the sample errors in ascending order to obtain an error list and a sample sequence number for each sample error;

[0196] Calculating the number of sample errors and multiplying the number by a configuration value to obtain a target value;

[0197] A sample error whose sample number is equal to the target value is selected from the error list as the error threshold.

[0198] Through the above implementation, the errors that affect the image reconstruction process and probability distribution can be determined.

[0199] In at least one embodiment of the present application, the determining unit 113 determines the detection result of the image to be detected according to the test error and the error threshold, including:

[0200] When the test error is less than the error threshold, determining the detection result as the image to be detected is flawless; or

[0201] When the test error is greater than or equal to the error threshold, the detection result is determined as the image to be detected has defects.

[0202] By comparing the test error with the error threshold, since the test error and the error threshold are compared numerically, it is possible to detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection.

[0203] In at least one embodiment of the present application, when the image to be detected has defects, the generating unit 115 generates reminder information according to the image to be detected, and sends the reminder information to a terminal device of a designated contact.

[0204] The designated contact person may be a quality control personnel responsible for testing the test object.

[0205] Through the above implementation, when there is a defect in the image to be detected, the designated contact person can be notified in time.

[0206] It can be seen from the above technical solutions that the present application can accurately determine the error threshold by determining the reconstruction error generated during image reconstruction and by determining the estimated probability generated by the Gaussian mixture model, and then by comparing the test error with the error threshold. Since the test error and the error threshold are compared numerically, it is possible to detect whether there are subtle defects in the image to be detected, thereby improving the accuracy of defect detection.

[0207] like Figure 3 , which is a schematic diagram of the structure of an electronic device of a preferred embodiment of the defect detection method of the present application.

[0208] In one embodiment of the present application, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program stored in the memory 12 and executable on the processor 13, such as a defect detection program.

[0209] Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation on the electronic device 1. The electronic device 1 may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the electronic device 1 may also include input and output devices, network access devices, buses, etc.

[0210] The processor 13 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 13 is the computing core and control center of the electronic device 1, and uses various interfaces and lines to connect various parts of the entire electronic device 1, and obtain the operating system of the electronic device 1 and various installed applications, program codes, etc.

[0211] The processor 13 obtains the operating system of the electronic device 1 and various installed applications. The processor 13 obtains the applications to implement the steps in the above-mentioned various defect detection method embodiments, for example Figure 1 Steps shown.

[0212] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and acquired by the processor 13 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the acquisition process of the computer program in the electronic device 1. For example, the computer program may be divided into an acquisition unit 110, an encoding unit 111, a decoding unit 112, a determination unit 113, an input unit 114, and a generation unit 115.

[0213] The memory 12 can be used to store the computer program and / or module, and the processor 13 implements various functions of the electronic device 1 by running or acquiring the computer program and / or module stored in the memory 12, and calling the data stored in the memory 12. The memory 12 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device, etc. In addition, the memory 12 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.

[0214] The memory 12 may be an external memory and / or an internal memory of the electronic device 1. Furthermore, the memory 12 may be a memory in a physical form, such as a memory stick, a TF card (Trans-flash Card), and the like.

[0215] If the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is obtained by the processor, the steps of each of the above-mentioned method embodiments can be implemented.

[0216] The computer program includes computer program code, which may be in source code form, object code form, an accessible file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0217] Combination Figure 1 , the memory 12 in the electronic device 1 stores a plurality of instructions to implement a defect detection method, and the processor 13 can obtain the plurality of instructions to implement:

[0218] When a defect detection request is received, obtaining an image to be detected and a plurality of positive sample images according to the defect detection request;

[0219] Using an encoder to encode the image to be detected to obtain a target vector corresponding to the image to be detected, and using the encoder to encode the multiple positive sample images to obtain multiple latent vectors corresponding to the multiple positive sample images;

[0220] Using a decoder corresponding to the encoder to decode the target vector to obtain a target image corresponding to the image to be detected, and using the decoder to decode the multiple latent vectors to obtain multiple reconstructed images corresponding to the multiple positive sample images;

[0221] Comparing the target image with the image to be detected to obtain a target error, and determining a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images;

[0222] Inputting the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image;

[0223] Determine a test error of the image to be detected according to the target error and the test probability, and determine a sample error of each positive sample image according to each reconstruction error and each estimated probability;

[0224] An error threshold is selected from the sample error, and a detection result of the image to be detected is determined according to the test error and the error threshold.

[0225] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0226] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

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

[0228] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0229] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present application is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0230] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in this application can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0231] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. A defect detection method, It is characterized in that The defect detection method comprises: When a defect detection request is received, obtaining an image to be detected and a plurality of positive sample images according to the defect detection request; Using an encoder to encode the image to be detected to obtain a target vector corresponding to the image to be detected, and using the encoder to encode the multiple positive sample images to obtain multiple latent vectors corresponding to the multiple positive sample images; Using a decoder corresponding to the encoder to decode the target vector to obtain a target image corresponding to the image to be detected, and using the decoder to decode the multiple latent vectors to obtain multiple reconstructed images corresponding to the multiple positive sample images; Comparing the target image with the image to be detected to obtain a target error, and determining a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images; Inputting the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image; Determine a test error of the image to be detected according to the target error and the test probability, and determine a sample error of each positive sample image according to each reconstruction error and each estimated probability; An error threshold is selected from the sample error, and a detection result of the image to be detected is determined according to the test error and the error threshold.

2. The defect detection method according to claim 1, It is characterized in that The encoding process of the image to be detected by using an encoder to obtain a target vector corresponding to the image to be detected comprises: Performing vectorization processing on the image to be detected to obtain a first feature vector of the image to be detected; extracting a hidden layer in the encoder; The first feature vector is operated by using the hidden layer to obtain the target vector.

3. The defect detection method according to claim 1, It is characterized in that The comparing the target image with the image to be detected to obtain a target error comprises: Extracting all pixel points of the image to be detected to obtain a plurality of pixel points to be detected, and extracting all pixel points of the target image to obtain a plurality of target pixel points; Compare each target pixel with each pixel to be detected to obtain a comparison result; When the comparison result indicates that the target pixel point is different from the pixel point to be detected, the number of different target pixels from the pixel point to be detected is calculated as a first number, and the number of the plurality of target pixels is calculated as a second number; The target error is obtained by dividing the first number by the second number.

4. The defect detection method according to claim 1, It is characterized in that The step of inputting the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and inputting the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image includes: Inputting the multiple latent vectors into the Gaussian mixture model to obtain feature distributions of the multiple positive sample images; Determine the mean value and covariance of the multiple latent vectors according to the feature distribution, and obtain the mixing coefficient of the Gaussian mixture model; The test probability of the image to be detected is determined according to the target vector, the mean value, the covariance and the mixing coefficient, and the estimated probability of each positive sample image is determined according to each latent vector, the mean value, the covariance and the mixing coefficient.

5. The defect detection method according to claim 1, It is characterized in that Determining the sample error of each positive sample image according to each reconstruction error and each estimated probability includes: Calculate the logarithm of each estimated probability to obtain the logarithm value of each estimated probability; A weighted sum operation is performed on the inverse of each logarithmic value and each reconstruction error to obtain the sample error.

6. The defect detection method according to claim 1, It is characterized in that The selecting an error threshold from the sample error comprises: Sort the sample errors in ascending order to obtain an error list and a sample sequence number for each sample error; Calculating the number of sample errors and multiplying the number by a configuration value to obtain a target value; A sample error whose sample number is equal to the target value is selected from the error list as the error threshold.

7. The defect detection method according to claim 1, It is characterized in that The step of determining the detection result of the image to be detected according to the test error and the error threshold comprises: When the test error is less than the error threshold, determining the detection result as the image to be detected is flawless; or When the test error is greater than or equal to the error threshold, the detection result is determined as the image to be detected has defects.

8. A defect detection device, It is characterized in that The defect detection device comprises: An acquisition unit, configured to acquire an image to be detected and a plurality of positive sample images according to a defect detection request when a defect detection request is received; An encoding unit, configured to encode the image to be detected using an encoder to obtain a target vector corresponding to the image to be detected, and to encode the plurality of positive sample images using the encoder to obtain a plurality of latent vectors corresponding to the plurality of positive sample images; A decoding unit, configured to decode the target vector using a decoder corresponding to the encoder to obtain a target image corresponding to the image to be detected, and decode the multiple latent vectors using the decoder to obtain multiple reconstructed images corresponding to the multiple positive sample images; a determination unit, configured to compare the target image with the image to be detected to obtain a target error, and determine a reconstruction error of each positive sample image according to the multiple reconstructed images and the multiple positive sample images; An input unit, used to input the target vector into a pre-trained Gaussian mixture model to obtain a test probability of the image to be detected, and input the multiple latent vectors into the Gaussian mixture model to obtain an estimated probability of each positive sample image; The determination unit is further used to determine the test error of the image to be detected according to the target error and the test probability, and to determine the sample error of each positive sample image according to each reconstruction error and each estimated probability; The determination unit is further configured to select an error threshold from the sample error, and determine a detection result of the image to be detected according to the test error and the error threshold.

9. An electronic device, It is characterized in that The electronic device comprises: a memory storing at least one instruction; and A processor executes instructions stored in the memory to implement the defect detection method according to any one of claims 1 to 7.

10. A computer-readable storage medium, Features: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in an electronic device to implement the defect detection method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and apparatus for liveness detection, device, and storage medium

    US20200364478A1

  • Anomaly detection in computer networks

    WO2018224670A1