Model input size determination method and related equipment

The method of determining model input size, including encoding, decoding, segmentation and Gaussian mixed model processing, solves the problem that the prior art is difficult to detect subtle defects and improves the accuracy of defect detection.

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

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, when conducting overall defect detection on industrial products, it is difficult to detect subtle defects, resulting in a decrease in detection accuracy.

Method used

Provide a model input size determination method, by obtaining test image sets, encoding processing, decoding processing, segmenting coded vectors, input subvectors to Gaussian mixed model, calculating test errors and accuracy, and selecting the best input size to improve the accuracy of defect detection.

Benefits of technology

By determining the model input size suitable for defect detection, the accuracy of defect detection is significantly improved and subtle defects can be effectively detected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114663336B_ABST
    Figure CN114663336B_ABST
Patent Text Reader

Abstract

The present application relates to image detection, and provides a method for determining a model input size and related equipment. The method can encode a test image, obtain a coding vector and decode it, obtain a reconstructed image, compare the reconstructed image with the test image, obtain a reconstruction error, divide the coding vector according to multiple preset sizes, obtain multiple sub-vectors of each preset size, input the multiple sub-vectors into a Gaussian mixture model, obtain multiple sub-probabilities of each preset size, determine the estimated probability and test error of each preset size, determine the detection result and accuracy according to each test error and each error threshold, and determine the input size according to the accuracy. The present application improves the accuracy of defect detection by determining a model input size suitable for 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 method for determining a model input size and related equipment. Background Art

[0002] In order to improve the quality of industrial products, they are usually inspected for defects before packaging. When inspecting the product as a whole, if the defects in the product are relatively subtle, they are difficult to detect, thus reducing the accuracy of defect detection on the image. Summary of the invention

[0003] In view of the above, it is necessary to provide a model input size determination method and related equipment, which can detect the presence of subtle defects, thereby improving the accuracy of defect detection.

[0004] A first aspect of the present application provides a method for determining a model input size, the method comprising:

[0005] Acquire a test image set, wherein the test image set includes a test image and a defect result;

[0006] Performing encoding processing on the test image to obtain an encoding vector;

[0007] Decoding the coding vector to obtain a reconstructed image of the test image, and comparing the reconstructed image with the test image to obtain a reconstruction error of the test image;

[0008] Splitting the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size;

[0009] Inputting multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining an estimated probability of each preset size according to the multiple sub-probabilities of each preset size;

[0010] Determine a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of a test image at each preset size according to the test error for each preset size and an error threshold for each preset size;

[0011] The accuracy of each preset size is determined according to the detection result of each preset size and the defect result, and an input size is selected from the plurality of preset sizes according to the accuracy of each preset size.

[0012] According to an optional embodiment of the present application, the decoding process of the coding vector to obtain the reconstructed image of the test image includes:

[0013] Get the vector mapping table;

[0014] Mapping the coded vector into a plurality of reconstructed pixel points according to the vector mapping table;

[0015] The multiple reconstructed pixel points are combined to obtain the reconstructed image.

[0016] According to an optional embodiment of the present application, comparing the reconstructed image with the test image to obtain a reconstruction error of the test image includes:

[0017] Extracting test pixels corresponding to each reconstructed pixel from the test image;

[0018] Comparing each reconstructed pixel with the corresponding test pixel, and determining the number of reconstructed pixels that are different from the corresponding test pixel as a first number;

[0019] Calculating the number of the plurality of reconstructed pixel points to obtain a second number;

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

[0021] According to an optional embodiment of the present application, dividing the encoding vector according to multiple preset sizes to obtain multiple sub-vectors corresponding to each preset size includes:

[0022] The encoding vector is sequentially divided according to each preset size to obtain multiple sub-vectors corresponding to each preset size.

[0023] According to an optional embodiment of the present application, the step of inputting the multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining the estimated probability of each preset size according to the multiple sub-probabilities of each preset size includes:

[0024] Obtaining feature distribution and mixing coefficients in the Gaussian mixture model;

[0025] Determining a mean and a covariance based on the characteristic distribution;

[0026] Determine a plurality of sub-probabilities of each preset size according to a plurality of sub-vectors corresponding to each preset size, the mixing coefficient, the average value, and the covariance;

[0027] A product operation is performed on multiple sub-probabilities of each preset size to obtain an estimated probability of each preset size.

[0028] According to an optional embodiment of the present application, determining the test error of each preset size according to the estimated probability of each preset size and the reconstruction error includes:

[0029] Calculate the logarithm of each estimated probability;

[0030] A weighted sum operation is performed on the inverse of each logarithmic value and the reconstruction error to obtain a test error of each preset size.

[0031] According to an optional embodiment of the present application, determining the accuracy of each preset size according to the detection result of each preset size and the defect result, and selecting an input size from the multiple preset sizes according to the accuracy of each preset size includes:

[0032] For each preset size, determining the detection result that is the same as the defect result as the target result;

[0033] Calculating the target number of the target results and calculating the total number of the test results;

[0034] Dividing the target quantity by the total quantity to obtain the accuracy of each preset size;

[0035] The accuracy with the largest value is determined as the target accuracy, and the preset size corresponding to the target accuracy is determined as the input size.

[0036] A second aspect of the present application provides a model input size determination device, the model input size determination device comprising:

[0037] An acquisition unit, used for acquiring a test image set, wherein the test image set includes a test image and a defect result;

[0038] A coding unit, used for performing coding processing on the test image to obtain a coding vector;

[0039] a comparing unit, configured to decode the coding vector to obtain a reconstructed image of the test image, and compare the reconstructed image with the test image to obtain a reconstruction error of the test image;

[0040] A segmentation unit, used to segment the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size;

[0041] A determination unit, used to input multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determine an estimated probability of each preset size according to the multiple sub-probabilities of each preset size;

[0042] The determination unit is further used to determine a test error of each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of the test image under each preset size according to the test error of each preset size and the error threshold of each preset size;

[0043] The determination unit is further configured to determine the accuracy of each preset size according to the detection result of each preset size and the defect result, and select an input size from the plurality of preset sizes according to the accuracy of each preset size.

[0044] A third aspect of the present application provides an electronic device, the electronic device comprising:

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

[0046] A processor executes the instructions stored in the memory to implement the model input size determination method.

[0047] A fourth aspect of the present application provides a computer-readable storage medium, wherein at least one instruction is stored in the computer-readable storage medium, and the at least one instruction is executed by a processor in an electronic device to implement the model input size determination method.

[0048] It can be seen from the above technical solutions that the present application improves the accuracy of defect detection by determining a model input size suitable for defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 It is a flow chart of a preferred embodiment of the method for determining the model input size of the present application.

[0050] Figure 2 It is a functional module diagram of a preferred embodiment of the model input size determination device of the present application.

[0051] Figure 3 It is a structural schematic diagram of an electronic device of a preferred embodiment of the present application for implementing the method for determining the model input size. DETAILED DESCRIPTION

[0052] 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.

[0053] like Figure 1 FIG. 1 is a flowchart of a preferred embodiment of the method for determining the model input size of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

[0054] The model input size determination 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 (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA), digital signal processors (Digital Signal Processor, DSP), embedded devices, etc.

[0055] 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.

[0056] 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.

[0057] 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.

[0058] S10, obtaining a test image set, where the test image set includes a test image and a defect result.

[0059] In at least one embodiment of the present application, the test image set includes multiple test images and defect results of each test image, wherein the test image includes a defect detection object, and the defect results include defective and non-defective.

[0060] In at least one embodiment of the present application, the electronic device may obtain the test image set from a configuration library, wherein the configuration library stores images that have undergone defect detection.

[0061] S11, encoding the test image to obtain an encoding vector.

[0062] In at least one embodiment of the present application, the electronic device may use a pre-trained encoder to encode the test image to obtain the encoding vector.

[0063] Among them, the process of the electronic device training the encoder belongs to the existing technology and will not be described in detail in this application.

[0064] In other embodiments, the electronic device may encode the test image using an encoder in an autoencoder (AE) to obtain the encoding vector. The encoder in the autoencoder includes multiple hidden layers, and the number of the multiple hidden layers can be arbitrarily set according to the application scenario.

[0065] Specifically, the electronic device uses an encoder in an autoencoder to encode the test image, and obtaining the encoding vector includes:

[0066] Performing vectorization processing on the test image to obtain a feature vector of the test image;

[0067] Extracting a hidden layer of an encoder in the autoencoder;

[0068] The hidden layer is used to operate the feature vector to obtain the encoding vector.

[0069] Specifically, the electronic device uses the hidden layer to operate the feature vector to obtain the encoding vector, which includes:

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

[0071] Multiplying the feature vector by the weight matrix to obtain a calculation result;

[0072] The operation result is added to the bias value to obtain the encoding vector.

[0073] S12, decoding the coding vector to obtain a reconstructed image of the test image, and comparing the reconstructed image with the test image to obtain a reconstruction error of the test image.

[0074] In at least one embodiment of the present application, the coding vector is converted into the reconstructed image through the vector mapping table, and therefore, the reconstruction error refers to the error of converting the test image into the coding vector.

[0075] In at least one embodiment of the present application, the electronic device performs decoding processing on the coding vector to obtain a reconstructed image of the test image, including:

[0076] Get the vector mapping table;

[0077] Mapping the coded vector into a plurality of reconstructed pixel points according to the vector mapping table;

[0078] The multiple reconstructed pixel points are combined to obtain the reconstructed image.

[0079] The vector mapping table stores a mapping relationship between vectors and pixels.

[0080] The reconstructed image can be accurately generated through the vector mapping table.

[0081] In at least one embodiment of the present application, the electronic device compares the reconstructed image with the test image to obtain a reconstruction error of the test image, including:

[0082] Extracting test pixels corresponding to each reconstructed pixel from the test image;

[0083] Comparing each reconstructed pixel with the corresponding test pixel, and determining the number of reconstructed pixels that are different from the corresponding test pixel as a first number;

[0084] Calculating the number of the plurality of reconstructed pixel points to obtain a second number;

[0085] The reconstruction error is obtained by dividing the first number by the second number.

[0086] By determining the reconstruction error, the error in converting the test image into the coding vector can be determined, and further the error generated before the coding vector is input into the model can be determined, thereby avoiding interference with the determination of the model input size.

[0087] S13, dividing the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size.

[0088] In at least one embodiment of the present application, the multiple preset sizes may be vectors with a dimension of 1*1*8 or a vector with a dimension of 2*2*8, and the values ​​of the multiple preset sizes may be set by a user.

[0089] In at least one embodiment of the present application, the electronic device divides the encoding vector according to multiple preset sizes, and obtains multiple sub-vectors corresponding to each preset size, including:

[0090] The encoding vector is sequentially divided according to each preset size to obtain multiple sub-vectors corresponding to each preset size.

[0091] For example: Encoded vector: A vector with a dimension of 3*3*3, the preset size is 1*1*3, and the vector with a dimension of 3*3*3 is sequentially split according to 1*1*3 to obtain 9 sub-vectors with a dimension of 1*1*3.

[0092] S14, inputting multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian Mixture Model (GMM) to obtain multiple sub-probabilities of each preset size, and determining an estimated probability of each preset size according to the multiple sub-probabilities of each preset size.

[0093] In at least one embodiment of the present application, the Gaussian mixture model includes multiple single Gaussian models.

[0094] In at least one embodiment of the present application, the electronic device inputs a plurality of sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain a plurality of sub-probabilities of each preset size, and determines an estimated probability of each preset size according to the plurality of sub-probabilities of each preset size, including:

[0095] Obtaining feature distribution and mixing coefficients in the Gaussian mixture model;

[0096] Determining a mean and a covariance based on the characteristic distribution;

[0097] Determine a plurality of sub-probabilities of each preset size according to a plurality of sub-vectors corresponding to each preset size, the mixing coefficient, the average value, and the covariance;

[0098] A product operation is performed on multiple sub-probabilities of each preset size to obtain an estimated probability of each preset size.

[0099] By fusing the probabilities of multiple sub-vectors, an estimated probability having the characteristics of multiple sub-vectors can be determined.

[0100] S15, determining a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determining a detection result of the test image under each preset size according to the test error for each preset size and the error threshold of each preset size.

[0101] In at least one embodiment of the present application, the detection result includes two results: the test image has a defect, and the test image does not have a defect.

[0102] In at least one embodiment of the present application, the error threshold is determined by the electronic device according to a plurality of positive sample images.

[0103] In at least one embodiment of the present application, the electronic device determines the test error of each preset size according to the estimated probability of each preset size and the reconstruction error, including:

[0104] Calculate the logarithm of each estimated probability;

[0105] A weighted sum operation is performed on the inverse of each logarithmic value and the reconstruction error to obtain a test error of each preset size.

[0106] For example: the estimated probability is 0.001, the reconstruction error is 0.03, the logarithm of the estimated probability is calculated as: log(0.001)=-3, the inverse of the logarithm is calculated, and the value is 3. The weighted sum of 3 and 0.03 is calculated. When the estimated probability accounts for 10% of the test error and the reconstruction error accounts for 90% of the test error, the test error is calculated to be: 3*10%+0.03*90%=0.327.

[0107] In at least one embodiment of the present application, the electronic device determines the detection result of the test image at each preset size according to the test error of each preset size and the error threshold of each preset size, including:

[0108] When the test error of a given preset size is less than the corresponding error threshold, determining the test result of the test image at the given preset size as the image to be detected is flawless; or

[0109] When the test error of the given preset size is greater than or equal to the corresponding error threshold, the detection result of the test image under the given preset size is determined as the image to be detected having defects.

[0110] 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 is a defect in the image to be detected.

[0111] S16, determining the accuracy of each preset size according to the detection result of each preset size and the defect result, and selecting an input size from the multiple preset sizes according to the accuracy of each preset size.

[0112] In at least one embodiment of the present application, the input size refers to a vector input into the Gaussian mixture model for probability determination.

[0113] In at least one embodiment of the present application, the electronic device determines the accuracy of each preset size according to the detection result of each preset size and the defect result, and selects the input size from the multiple preset sizes according to the accuracy of each preset size, including:

[0114] For each preset size, determining the detection result that is the same as the defect result as the target result;

[0115] Calculating the target number of the target results and calculating the total number of the test results;

[0116] Dividing the target quantity by the total quantity to obtain the accuracy of each preset size;

[0117] The accuracy with the largest value is determined as the target accuracy, and the preset size corresponding to the target accuracy is determined as the input size.

[0118] For example, the preset size X is 1*1*8, the preset size Y is 2*2*8, and the preset size Z is 4*4*8. There are 3 detection results (i.e., target results) that are the same as the defect result in the preset size X, 6 target results in the preset size Y, and 10 target results in the preset size Z. The total number of detection results is 12. After calculation, the accuracy of the preset size X is 25%, the accuracy of the preset size Y is 50%, and the accuracy of the preset size Z is 83.3%. The value of 83.3% is the largest, and 83.3% is determined as the target accuracy, and the preset size Z corresponding to 83.3% is determined as the input size.

[0119] By determining the preset size with the highest accuracy as the input size, the accuracy of defect detection is improved.

[0120] It can be seen from the above technical solutions that the present application improves the accuracy of defect detection by determining a model input size suitable for defect detection.

[0121] like Figure 2 , which is a functional module diagram of a preferred embodiment of the model input size determination device of the present application. The model input size determination device 11 includes an acquisition unit 110, an encoding unit 111, a comparison unit 112, a segmentation unit 113 and a determination unit 114. 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.

[0122] The acquisition unit 110 acquires a test image set, where the test image set includes a test image and a defect result.

[0123] In at least one embodiment of the present application, the test image set includes multiple test images and defect results of each test image, wherein the test image includes a defect detection object, and the defect results include defective and non-defective.

[0124] In at least one embodiment of the present application, the acquisition unit 110 may acquire the test image set from a configuration library, wherein the configuration library stores images that have undergone defect detection.

[0125] The encoding unit 111 performs encoding processing on the test image to obtain an encoding vector.

[0126] In at least one embodiment of the present application, the encoding unit 111 may use a pre-trained encoder to encode the test image to obtain the encoding vector.

[0127] Among them, the process of the encoding unit 111 training the encoder belongs to the existing technology and will not be repeated in this application.

[0128] In other embodiments, the encoding unit 111 may use an encoder in an autoencoder (AE) to encode the test image to obtain the encoding vector. The encoder in the autoencoder includes multiple hidden layers, and the number of the multiple hidden layers can be arbitrarily set according to the application scenario.

[0129] Specifically, the encoding unit 111 uses the encoder in the autoencoder to encode the test image, and the encoding vector obtained includes:

[0130] Performing vectorization processing on the test image to obtain a feature vector of the test image;

[0131] Extracting a hidden layer of an encoder in the autoencoder;

[0132] The hidden layer is used to operate the feature vector to obtain the encoding vector.

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

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

[0135] Multiplying the feature vector by the weight matrix to obtain a calculation result;

[0136] The operation result is added to the bias value to obtain the encoding vector.

[0137] The comparison unit 112 decodes the coding vector to obtain a reconstructed image of the test image, and compares the reconstructed image with the test image to obtain a reconstruction error of the test image.

[0138] In at least one embodiment of the present application, the comparing unit 112 performs decoding processing on the coding vector to obtain a reconstructed image of the test image, including:

[0139] Get the vector mapping table;

[0140] Mapping the coded vector into a plurality of reconstructed pixel points according to the vector mapping table;

[0141] The multiple reconstructed pixel points are combined to obtain the reconstructed image.

[0142] The vector mapping table stores a mapping relationship between vectors and pixels.

[0143] The reconstructed image can be accurately generated through the vector mapping table.

[0144] In at least one embodiment of the present application, the coding vector is converted into the reconstructed image through the vector mapping table, and therefore, the reconstruction error refers to the error of converting the test image into the coding vector.

[0145] In at least one embodiment of the present application, the comparing unit 112 compares the reconstructed image with the test image to obtain a reconstruction error of the test image, including:

[0146] Extracting test pixels corresponding to each reconstructed pixel from the test image;

[0147] Comparing each reconstructed pixel with the corresponding test pixel, and determining the number of reconstructed pixels that are different from the corresponding test pixel as a first number;

[0148] Calculating the number of the plurality of reconstructed pixel points to obtain a second number;

[0149] The reconstruction error is obtained by dividing the first number by the second number.

[0150] By determining the reconstruction error, the error in converting the test image into the coding vector can be determined, and further the error generated before the coding vector is input into the model can be determined, thereby avoiding interference with the determination of the model input size.

[0151] The segmentation unit 113 segments the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size.

[0152] In at least one embodiment of the present application, the multiple preset sizes may be vectors with a dimension of 1*1*8 or a vector with a dimension of 2*2*8, and the values ​​of the multiple preset sizes may be set by a user.

[0153] In at least one embodiment of the present application, the segmentation unit 113 segments the encoding vector according to a plurality of preset sizes, and obtains a plurality of sub-vectors corresponding to each preset size, including:

[0154] The encoding vector is sequentially divided according to each preset size to obtain multiple sub-vectors corresponding to each preset size.

[0155] For example: Encoded vector: A vector with a dimension of 3*3*3, the preset size is 1*1*3, and the vector with a dimension of 3*3*3 is sequentially split according to 1*1*3 to obtain 9 sub-vectors with a dimension of 1*1*3.

[0156] The determination unit 114 inputs the multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian Mixture Model (GMM) to obtain multiple sub-probabilities of each preset size, and determines the estimated probability of each preset size according to the multiple sub-probabilities of each preset size.

[0157] In at least one embodiment of the present application, the Gaussian mixture model includes multiple single Gaussian models.

[0158] In at least one embodiment of the present application, the determining unit 114 inputs the multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determines the estimated probability of each preset size according to the multiple sub-probabilities of each preset size, including:

[0159] Obtaining feature distribution and mixing coefficients in the Gaussian mixture model;

[0160] Determining a mean and a covariance based on the characteristic distribution;

[0161] Determine a plurality of sub-probabilities of each preset size according to a plurality of sub-vectors corresponding to each preset size, the mixing coefficient, the average value, and the covariance;

[0162] A product operation is performed on multiple sub-probabilities of each preset size to obtain an estimated probability of each preset size.

[0163] By fusing the probabilities of multiple sub-vectors, an estimated probability having the characteristics of multiple sub-vectors can be determined.

[0164] The determination unit 114 determines a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determines a detection result of the test image at each preset size according to the test error for each preset size and an error threshold for each preset size.

[0165] In at least one embodiment of the present application, the detection result includes two results: the test image has a defect, and the test image does not have a defect.

[0166] In at least one embodiment of the present application, the error threshold is determined by the determination unit 114 according to a plurality of positive sample images.

[0167] In at least one embodiment of the present application, the determining unit 114 determines the test error of each preset size according to the estimated probability of each preset size and the reconstruction error, including:

[0168] Calculate the logarithm of each estimated probability;

[0169] A weighted sum operation is performed on the inverse of each logarithmic value and the reconstruction error to obtain a test error of each preset size.

[0170] For example: the estimated probability is 0.001, the reconstruction error is 0.03, the logarithm of the estimated probability is calculated as: log(0.001)=-3, the inverse of the logarithm is calculated, and the value is 3. The weighted sum of 3 and 0.03 is calculated. When the estimated probability accounts for 10% of the test error and the reconstruction error accounts for 90% of the test error, the test error is calculated to be: 3*10%+0.03*90%=0.327.

[0171] In at least one embodiment of the present application, the determining unit 114 determines the detection result of the test image at each preset size according to the test error of each preset size and the error threshold of each preset size, including:

[0172] When the test error of a given preset size is less than the corresponding error threshold, determining the test result of the test image at the given preset size as the image to be detected is flawless; or

[0173] When the test error of the given preset size is greater than or equal to the corresponding error threshold, the detection result of the test image under the given preset size is determined as the image to be detected having defects.

[0174] 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 is a defect in the image to be detected.

[0175] The determining unit 114 determines the accuracy of each preset size according to the detection result of each preset size and the defect result, and selects an input size from the plurality of preset sizes according to the accuracy of each preset size.

[0176] In at least one embodiment of the present application, the input size refers to a vector input into the Gaussian mixture model for probability determination.

[0177] In at least one embodiment of the present application, the determining unit 114 determines the accuracy of each preset size according to the detection result of each preset size and the defect result, and selects the input size from the multiple preset sizes according to the accuracy of each preset size, including:

[0178] For each preset size, determining the detection result that is the same as the defect result as the target result;

[0179] Calculating the target number of the target results and calculating the total number of the test results;

[0180] Dividing the target quantity by the total quantity to obtain the accuracy of each preset size;

[0181] The accuracy with the largest value is determined as the target accuracy, and the preset size corresponding to the target accuracy is determined as the input size.

[0182] For example, the preset size X is 1*1*8, the preset size Y is 2*2*8, and the preset size Z is 4*4*8. There are 3 detection results (i.e., target results) that are the same as the defect result in the preset size X, 6 target results in the preset size Y, and 10 target results in the preset size Z. The total number of detection results is 12. After calculation, the accuracy of the preset size X is 25%, the accuracy of the preset size Y is 50%, and the accuracy of the preset size Z is 83.3%. The value of 83.3% is the largest, and 83.3% is determined as the target accuracy, and the preset size Z corresponding to 83.3% is determined as the input size.

[0183] By determining the preset size with the highest accuracy as the input size, the accuracy of defect detection is improved.

[0184] It can be seen from the above technical solutions that the present application improves the accuracy of defect detection by determining a model input size suitable for defect detection.

[0185] like Figure 3 , which is a schematic diagram of the structure of an electronic device of a preferred embodiment of the present application for implementing the method for determining the model input size.

[0186] 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 model input size determination program.

[0187] 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.

[0188] 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.

[0189] 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 embodiments of the model input size determination method, for example Figure 1 Steps shown.

[0190] Alternatively, when the processor 13 executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, for example:

[0191] Acquire a test image set, wherein the test image set includes a test image and a defect result;

[0192] Performing encoding processing on the test image to obtain an encoding vector, and performing decoding processing on the encoding vector to obtain a reconstructed image of the test image;

[0193] Comparing the reconstructed image with the test image to obtain a reconstruction error of the test image;

[0194] Splitting the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size;

[0195] Inputting multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining an estimated probability of each preset size according to the multiple sub-probabilities of each preset size;

[0196] Determine a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of a test image at each preset size according to the test error for each preset size and an error threshold for each preset size;

[0197] The accuracy of each preset size is determined according to the detection result of each preset size and the defect result, and an input size is selected from the plurality of preset sizes according to the accuracy.

[0198] 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 comparison unit 112, a segmentation unit 113, and a determination unit 114.

[0199] 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.

[0200] 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.

[0201] 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.

[0202] 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).

[0203] Combination Figure 1 The memory 12 in the electronic device 1 stores a plurality of instructions to implement a method for determining a model input size, and the processor 13 may obtain the plurality of instructions to implement:

[0204] Acquire a test image set, wherein the test image set includes a test image and a defect result;

[0205] Performing encoding processing on the test image to obtain an encoding vector, and performing decoding processing on the encoding vector to obtain a reconstructed image of the test image;

[0206] Comparing the reconstructed image with the test image to obtain a reconstruction error of the test image;

[0207] Splitting the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size;

[0208] Inputting multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining an estimated probability of each preset size according to the multiple sub-probabilities of each preset size;

[0209] Determine a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of a test image at each preset size according to the test error for each preset size and an error threshold for each preset size;

[0210] The accuracy of each preset size is determined according to the detection result of each preset size and the defect result, and an input size is selected from the plurality of preset sizes according to the accuracy.

[0211] 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.

[0212] 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.

[0213] 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.

[0214] 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.

[0215] 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.

[0216] 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.

[0217] 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 method for determining a model input size, characterized in that: The model input size determination method comprises: Acquire a test image set, wherein the test image set includes a test image and a defect result; Performing encoding processing on the test image to obtain an encoding vector; Decoding the coding vector to obtain a reconstructed image of the test image, and comparing the reconstructed image with the test image to obtain a reconstruction error of the test image; Splitting the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size; Inputting multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining an estimated probability of each preset size according to the multiple sub-probabilities of each preset size; Determine a test error for each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of a test image at each preset size according to the test error for each preset size and an error threshold for each preset size; The accuracy of each preset size is determined according to the detection result of each preset size and the defect result, and an input size is selected from the plurality of preset sizes according to the accuracy of each preset size.

2. The method for determining the model input size according to claim 1, characterized in that: The decoding process of the coding vector to obtain the reconstructed image of the test image comprises: Get the vector mapping table; Mapping the coded vector into a plurality of reconstructed pixel points according to the vector mapping table; The multiple reconstructed pixel points are combined to obtain the reconstructed image.

3. The method for determining the model input size according to claim 2, characterized in that: The comparing the reconstructed image with the test image to obtain a reconstruction error of the test image comprises: Extracting test pixels corresponding to each reconstructed pixel from the test image; Comparing each reconstructed pixel with the corresponding test pixel, and determining the number of reconstructed pixels that are different from the corresponding test pixel as a first number; Calculating the number of the plurality of reconstructed pixel points to obtain a second number; The reconstruction error is obtained by dividing the first number by the second number.

4. The method for determining the model input size according to claim 1, wherein: The step of dividing the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size comprises: The encoding vector is sequentially divided according to each preset size to obtain multiple sub-vectors corresponding to each preset size.

5. The method for determining the model input size according to claim 1, wherein: The step of inputting the multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determining the estimated probability of each preset size according to the multiple sub-probabilities of each preset size includes: Obtaining feature distribution and mixing coefficients in the Gaussian mixture model; Determining a mean and a covariance based on the characteristic distribution; Determine a plurality of sub-probabilities of each preset size according to a plurality of sub-vectors corresponding to each preset size, the mixing coefficient, the average value, and the covariance; A product operation is performed on multiple sub-probabilities of each preset size to obtain an estimated probability of each preset size.

6. The method for determining the model input size according to claim 1, wherein: Determining the test error of each preset size according to the estimated probability of each preset size and the reconstruction error includes: Calculate the logarithm of each estimated probability; A weighted sum operation is performed on the inverse of each logarithmic value and the reconstruction error to obtain a test error of each preset size.

7. The method for determining the model input size according to claim 1, characterized in that: Determining the accuracy of each preset size according to the detection result of each preset size and the defect result, and selecting an input size from the plurality of preset sizes according to the accuracy of each preset size includes: For each preset size, determining the detection result that is the same as the defect result as the target result; Calculating the target number of the target results and calculating the total number of the test results; Dividing the target quantity by the total quantity to obtain the accuracy of each preset size; The accuracy with the largest value is determined as the target accuracy, and the preset size corresponding to the target accuracy is determined as the input size.

8. A device for determining a model input size, characterized in that: The model input size determination device comprises: An acquisition unit, used for acquiring a test image set, wherein the test image set includes a test image and a defect result; A coding unit, used for performing coding processing on the test image to obtain a coding vector; a comparing unit, configured to decode the coding vector to obtain a reconstructed image of the test image, and compare the reconstructed image with the test image to obtain a reconstruction error of the test image; A segmentation unit, used to segment the encoding vector according to a plurality of preset sizes to obtain a plurality of sub-vectors corresponding to each preset size; A determination unit, used to input multiple sub-vectors corresponding to each preset size into a pre-trained Gaussian mixture model to obtain multiple sub-probabilities of each preset size, and determine an estimated probability of each preset size according to the multiple sub-probabilities of each preset size; The determination unit is further used to determine a test error of each preset size according to the estimated probability of each preset size and the reconstruction error, and determine a detection result of the test image under each preset size according to the test error of each preset size and the error threshold of each preset size; The determination unit is further configured to determine the accuracy of each preset size according to the detection result of each preset size and the defect result, and select an input size from the plurality of preset sizes according to the accuracy of each preset size.

9. An electronic device, 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 model input size determination method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: 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 model input size determination method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Palm and key point detection method, device and terminal device thereof

    CN109345553A

  • Medical image processing method and device, equipment and storage medium

    CN111275699A