Defect detection method and device, electronic device and computer-readable storage medium
By training weight-driven autoencoders and autoregressive networks to segment test sample features, the problems of defect detection errors and inaccurate judgment of small defects in existing technologies are solved, and high-precision defect detection is achieved.
Patent Information
- Application Number
- CN202011613567.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2040-12-30
AI Technical Summary
Existing defect detection methods have errors in defect determination due to the presence of a lot of noise in the test samples, making it difficult to accurately judge small defects.
The training weights obtained when training the autoencoder and autoregressive network using normal training samples are loaded into the autoencoder and autoregressive network, the test sample is encoded, the test encoding features are split into sub-test encoding features, and the sub-test encoding features are input into the autoregressive network one by one to output the test results, including whether the test sample has defects.
It avoids noise interference in the test sample, accurately judges small defects, avoids errors in defect determination, and improves the accuracy of detection.
Smart Images

Figure CN114691477B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection technology, and in particular to a defect detection method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Current defect detection methods feed a test sample into a trained autoencoder to obtain a reconstructed image corresponding to the test sample. The method then determines whether the test sample is defective based on the difference between the reconstructed image and the test sample. However, due to the high level of noise in the test sample, defect determination is subject to error and cannot accurately identify even small defects. Summary of the Invention
[0003] In view of this, it is necessary to provide a defect detection method and device, an electronic device and a computer-readable storage medium, which can avoid errors in determining defects and accurately judge small defects.
[0004] A first aspect of the present application provides a defect detection method, the defect detection method comprising:
[0005] Get the training weights obtained when training the autoencoder and autoregressive network using normal training samples;
[0006] Loading the training weights into the autoencoder and the autoregressive network to encode a test sample through the autoencoder loaded with the training weights to obtain a test encoding feature;
[0007] Splitting the test coding signature into sub-test coding signatures;
[0008] The sub-test encoding features are input one by one into the autoregressive network loaded with the training weights to output a test result, where the test result includes one of the following: the test sample has a defect and the test sample does not have a defect.
[0009] Preferably, said dividing the test coding feature into sub-test coding features comprises:
[0010] determining a length of the test coding feature;
[0011] Obtaining a preset condition for segmentation, wherein the preset condition includes one of a preset length and a preset number of parts;
[0012] The test code feature of the length is divided into the sub-test code features according to the preset condition.
[0013] Preferably, the step of inputting the sub-test encoding features one by one into the autoregressive network loaded with the training weights to output the test results comprises:
[0014] Inputting the subtest coding features one by one into the autoregressive network loaded with the training weights until all subtest coding features are tested or it is determined that the subtest coding features have defects;
[0015] Output test results.
[0016] Preferably, inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights until all sub-test coding features are tested or it is determined that the sub-test coding features have defects includes:
[0017] Inputting one of the subtest encoding features into the autoregressive network loaded with the training weights to output a subtest result;
[0018] determining whether the subtest coding feature has a defect based on the subtest result;
[0019] If the subtest coding feature does not have defects, determining whether all subtest coding feature tests are complete;
[0020] If not all sub-test coding feature tests are completed, continue to input the next sub-test coding feature into the autoregressive network loaded with the training weights, determine whether the sub-test coding feature has defects, and determine whether all sub-test coding feature tests are completed until all sub-test coding feature tests are completed or it is determined that the sub-test coding feature has defects.
[0021] Preferably, the defect detection method further includes:
[0022] If the sub-test coding feature has defects, a result indicating that the test sample has defects is output.
[0023] Preferably, the defect detection method further includes:
[0024] If all sub-test coding feature tests are completed, the result indicating that the test sample has no defects is output.
[0025] Preferably, the defect detection method further includes:
[0026] Get normal training samples;
[0027] Inputting the normal training sample into the autoencoder to encode the normal training sample to obtain a training coding feature;
[0028] Splitting the training coding features into sub-training coding features;
[0029] The sub-training encoded features are input into the autoregressive network for training to generate training weights of the autoencoder and the autoregressive network.
[0030] A second aspect of the present application provides a defect detection device, comprising:
[0031] The training weight acquisition module is used to obtain the training weights obtained when training the autoencoder and autoregressive network using normal training samples;
[0032] A test encoding module, configured to load the training weights into the autoencoder and the autoregressive network to encode a test sample through the autoencoder loaded with the training weights to obtain a test encoding feature;
[0033] A test splitting module, configured to split the test coding feature into sub-test coding features;
[0034] An output module is used to input the sub-test coding features one by one into the autoregressive network loaded with the training weights to output a test result, wherein the test result includes one of the following: the test sample has a defect and the test sample does not have a defect.
[0035] A third aspect of the present application provides an electronic device, comprising one or more processors and a memory, wherein the processor is configured to implement any one of the above-described defect detection methods when executing at least one instruction stored in the memory.
[0036] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor to implement the defect detection method as described in any one of the above.
[0037] In this case, the training weights obtained when training the autoencoder and the autoregressive network using normal training samples are obtained, and the training weights are loaded into the autoencoder and the autoregressive network to encode the test sample through the autoencoder loaded with the training weights to obtain a test coding feature, and the test coding feature is divided into sub-test coding features, and the sub-test coding features are input one by one into the autoregressive network loaded with the training weights to output a test result. The test result includes one of the existence of a defect in the test sample and the non-defectiveness of the test sample. The essence of the test sample can be directly used to determine whether the test sample has a defect, rather than directly using the test sample to determine whether the test sample has a defect, and there is no need to compare with the test sample, thereby avoiding noise in the test sample, avoiding errors in determining defects, and accurately judging small defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 This is a block diagram of a defect detection device provided in Example 1 of the present invention.
[0040] Figure 2 It is a block diagram of a defect detection device provided in Example 2 of the present invention.
[0041] Figure 3 This is a flowchart of the defect detection method provided in Example 3 of the present invention.
[0042] Figure 4 This is a flowchart of the defect detection method provided in Example 4 of the present invention.
[0043] Figure 5 It is a block diagram of an electronic device provided in Embodiment 5 of the present invention.
[0044] The following specific embodiments will further illustrate the present invention in conjunction with the above-mentioned drawings.
[0045] Description of main component symbols
[0046] Defect detection device 10, 20
[0047] Training weight acquisition module 101, 205
[0048] Test encoding modules 102, 206
[0049] Test segmentation module 103, 207
[0050] Output modules 104, 208
[0051] Training sample acquisition module 201
[0052] Training encoding module 202
[0053] Training segmentation module 203
[0054] Training weight generation module 204
[0055] Electronic device 5
[0056] Memory 51
[0057] Processor 52
[0058] Computer Program 53
[0059] The following specific embodiments will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0060] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein may be combined with each other.
[0061] The following description sets forth numerous specific details to facilitate a thorough understanding of the present invention. The embodiments described are merely a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0063] Figure 1 : This is a block diagram of a defect detection device provided in a first embodiment of the present invention. The defect detection device 10 is applied to an electronic device. The electronic device may be a smart phone, a desktop computer, a tablet computer, etc. The defect detection device 10 includes a training weight acquisition module 101, a test encoding module 102, a test segmentation module 103, and an output module 104. The training weight acquisition module 101 is used to obtain the training weights obtained when the autoencoder and the autoregressive network are trained using normal training samples. The test encoding module 102 is used to load the training weights into the autoencoder and the autoregressive network to encode the test sample by the autoencoder loaded with the training weights to obtain a test encoding feature. The test segmentation module 103 is used to split the test encoding feature into sub-test encoding features. The output module 104 is used to input the sub-test encoding features one by one into the autoregressive network loaded with the training weights to output a test result, wherein the test result includes one of the presence of a defect in the test sample and the absence of a defect in the test sample.
[0064] Figure 2This is a block diagram of a defect detection device provided in a second embodiment of the present invention. The defect detection device 20 is applied to an electronic device. The electronic device may be a smartphone, a desktop computer, a tablet computer, or the like. The defect detection device 20 includes a training sample acquisition module 201, a training encoding module 202, a training segmentation module 203, a training weight generation module 204, a training weight acquisition module 205, a test encoding module 206, a test segmentation module 207, and an output module 208. The training sample acquisition module 201 is used to acquire normal training samples. The training encoding module 202 is used to input the normal training samples into the autoencoder to encode the normal training samples to obtain training encoding features. The training segmentation module 203 is used to segment the training encoding features into sub-training encoding features. The training weight generation module 204 is used to input the sub-training encoding features into the autoregressive network for training to generate training weights for the autoencoder and the autoregressive network. The training weight acquisition module 205 is used to obtain the training weights obtained when training the autoencoder and the autoregressive network using normal training samples. The test encoding module 206 is used to load the training weights into the autoencoder and the autoregressive network to encode the test sample through the autoencoder loaded with the training weights to obtain a test encoding feature. The test segmentation module 207 is used to segment the test encoding feature into sub-test encoding features. The output module 208 is used to input the sub-test encoding features one by one into the autoregressive network loaded with the training weights to output a test result, wherein the test result includes one of the following: the test sample has a defect or the test sample does not have a defect.
[0065] The specific functions of modules 101 - 104 and modules 201 - 208 will be described in detail below in conjunction with a flowchart of a defect detection method.
[0066] Figure 3 Flowchart of the defect detection method provided by the third embodiment of the present invention. The defect detection method may include the following steps:
[0067] S31: Obtain the training weights obtained when training the autoencoder and the autoregressive network using normal training samples.
[0068] The normal training samples are images of product surfaces without any defects. The autoencoder and the autoregressive network are the architecture of the autoencoder with the autoregressive network added. The training weights are the optimal weights of the architecture of the autoencoder with the autoregressive network added.
[0069] S32: Loading the training weights into the autoencoder and the autoregressive network to encode the test sample through the autoencoder loaded with the training weights to obtain a test coding feature.
[0070] The autoencoder includes an encoder. The test encoding features are features generated when the encoder of the autoencoder loaded with the training weights encodes the test sample, i.e., hidden layer features. The test encoding features represent the essence of the test sample, removing much of the noise in the test sample. Loading the training weights into the autoencoder and the autoregressive network yields a trained architecture of the autoencoder supplemented with the autoregressive network. The test sample is a test image of a product surface.
[0071] S33: Split the test coding feature into sub-test coding features.
[0072] The splitting of the test coding feature into sub-test coding features includes: determining the length of the test coding feature; obtaining the preset conditions for splitting, the preset conditions including one of a preset length and a preset number of parts; and splitting the test coding feature of the length into the sub-test coding features according to the preset conditions.
[0073] S34: Inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output a test result, wherein the test result includes one of the following: the test sample has a defect and the test sample does not have a defect.
[0074] In this embodiment, the autoregressive network includes a convolution kernel, multiple convolution layers, multiple residual modules and a softmax layer. The convolution kernel, multiple residual modules, multiple convolution layers and the softmax layer are connected in sequence. The convolution kernel is a 7x7 convolution kernel. The autoregressive network extracts the features of the subtest coding features by connecting the 7x7 convolution kernel with the input subtest coding features. The multiple residual modules are used to process the features of the extracted subtest coding features. The convolution layer is a 1x1 convolution layer. The number of the 1x1 convolution layers is two. The output layer of the autoregressive network is a softmax layer. The autoregressive network outputs a probability value through the softmax layer.
[0075] The step of inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output the test results includes: inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output probability values; and outputting the test results according to the probability values. If the probability value of the sub-test coding features approaches 1, the test result is that the test sample has a defect; if the probability value of each sub-test coding feature approaches 0, the test result is that the test sample does not have a defect. The value approaching 1 is preferably 1, 0.99, 0.98, etc., which can be set according to the needs of the user. The value approaching 0 is preferably 0, 0.01, 0.02, etc., which can be set according to the needs of the user.
[0076] In this embodiment, the step of inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output the test results includes: inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights until all sub-test coding feature tests are completed or it is determined that the sub-test coding features have defects; and outputting the test results.
[0077] In this embodiment, inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights until all sub-test coding features are tested or it is determined that the sub-test coding features have defects includes:
[0078] a1: Input one of the subtest encoding features into the autoregressive network loaded with the training weights to output a subtest result.
[0079] a2: Determine whether the sub-test coding feature has defects based on the sub-test result.
[0080] a3: If there is no defect in the sub-test coding feature, determine whether all sub-test coding feature tests are completed.
[0081] a4: If not all sub-test coding feature tests are completed, continue to input the next sub-test coding feature into the autoregressive network loaded with the training weights, determine whether the sub-test coding feature has defects, and determine whether all sub-test coding feature tests are completed until all sub-test coding feature tests are completed or it is determined that the sub-test coding feature has defects.
[0082] For example: sub-test coding feature 1 is input into the autoregressive network loaded with the training weights to output a probability value of 0, and based on the probability value 0, it is determined that sub-test coding feature 1 does not have defects, and it is determined that not all sub-test coding feature tests have been completed, and sub-test coding feature 2 is input into the autoregressive network loaded with the training weights to output a probability value of 1, and based on the probability value 1, it is determined that sub-test coding feature 1 has defects.
[0083] In this embodiment, the defect detection method further includes: if the sub-test coding feature has a defect, outputting a result indicating that the test sample has a defect.
[0084] In this embodiment, the defect detection method further includes: if all sub-test coding feature tests are completed, outputting a result that the test sample does not have defects.
[0085] In this embodiment, inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output the test result may further include: inputting all sub-test coding features one by one into the autoregressive network loaded with the training weights to perform tests one by one to output the test result. For example, all sub-test coding features include sub-test coding feature 1 and sub-test coding feature 2, sub-test coding feature 1 is input into the autoregressive network loaded with the training weights to output probability value 1, and then sub-test coding feature 2 is input into the autoregressive network loaded with the training weights to output probability value 2, and the test result is output based on probability value 1 and probability value 2.
[0086] In the third embodiment, training weights obtained when training an autoencoder and an autoregressive network using normal training samples are obtained, and the training weights are loaded into the autoencoder and the autoregressive network. The autoencoder loaded with the training weights then encodes a test sample to obtain a test coding feature. The test coding feature is then divided into sub-test coding features, and each of the sub-test coding features is input one by one into the autoregressive network loaded with the training weights to output a test result. The test result includes one of the following: the presence of a defect in the test sample and the absence of a defect in the test sample. Thus, this embodiment can directly utilize the essence of the test sample to determine whether the test sample is defective, rather than directly utilizing the test sample to determine whether the test sample is defective, and does not require comparison with the test sample, thereby avoiding noise in the test sample and errors in defect determination. Furthermore, dividing the test coding feature into sub-test coding features for testing avoids mutual interference among the test coding features, prevents defect information from being averaged, and accurately determines small defects.
[0087] Figure 4 Flowchart of the defect detection method provided by the fourth embodiment of the present invention. The defect detection method may include the following steps:
[0088] S41: Obtain normal training samples.
[0089] The normal training samples are images of product surfaces without any defects.
[0090] S42: Inputting the normal training sample into the autoencoder to encode the normal training sample to obtain training coding features.
[0091] The autoencoder includes an encoder. The training encoding features are features generated when the autoencoder's encoder encodes the normal training samples, i.e., hidden layer features. The training encoding features are the essence of the normal training samples, removing much of the noise of the normal training samples.
[0092] S43: Split the training coding features into sub-training coding features.
[0093] The splitting of the training coding feature into sub-training coding features includes: determining the length of the training coding feature; obtaining a preset condition for splitting, the preset condition including one of a preset length and a preset number; and splitting the training coding feature of the length into the sub-training coding features according to the preset condition.
[0094] S44: Inputting the sub-training encoding features into the autoregressive network for training to generate training weights for the autoencoder and the autoregressive network.
[0095] The inputting of the sub-training coding features into the autoregressive network for training to generate the training weights of the autoencoder and the autoregressive network can be, for example: inputting sub-training coding features 1 and sub-training coding features 2 into the autoregressive network for training to generate the training weights of the autoencoder and the autoregressive network.
[0096] The step of inputting the sub-training coding features into the autoregressive network for training to generate the training weights of the autoencoder and the autoregressive network includes: inputting one of the sub-training coding features into the autoregressive network for training to generate the sub-training weights of the autoencoder and the autoregressive network; loading the sub-training weights into the autoencoder and the autoregressive network to iteratively train the autoencoder and the autoregressive network according to the next sub-training coding feature until all sub-training coding features are input into the autoencoder and the autoregressive network to generate the training weights of the autoencoder and the autoregressive network. For example, the sub-training coding features include sub-training coding feature 1 and sub-training coding feature 2, inputting sub-training coding feature 1 into the autoregressive network for training to generate sub-training weight 1 of the autoencoder and the autoregressive network, and loading the sub-training weight 1 into the autoencoder and the autoregressive network to iteratively train the autoencoder and the autoregressive network according to sub-training coding feature 2 to generate training weight 2 of the autoencoder and the autoregressive network.
[0097] S45: Obtaining training weights obtained when training the autoencoder and the autoregressive network using normal training samples.
[0098] Step S45 of this embodiment is similar to step S31 of the third embodiment. Please refer to the detailed description of step S31 in the third embodiment for details, which will not be repeated here.
[0099] S46: Loading the training weights into the autoencoder and the autoregressive network to encode the test sample through the autoencoder loaded with the training weights to obtain a test coding feature.
[0100] Step S46 of this embodiment is similar to step S32 of the third embodiment. Please refer to the detailed description of step S32 in the third embodiment for details, which will not be repeated here.
[0101] S47: Split the test coding signature into sub-test coding signatures.
[0102] Step S47 of this embodiment is similar to step S33 of the third embodiment. Please refer to the detailed description of step S33 in the third embodiment for details, which will not be repeated here.
[0103] S48: Inputting the sub-test coding features one by one into the autoregressive network loaded with the training weights to output a test result, wherein the test result includes one of the following: the test sample has a defect and the test sample does not have a defect.
[0104] Step S48 of this embodiment is similar to step S34 of the third embodiment. Please refer to the detailed description of step S34 in the third embodiment for details, which will not be repeated here.
[0105] In the fourth embodiment, a normal training sample is obtained, the normal training sample is input into the autoencoder to encode the normal training sample to obtain a training coding feature, the training coding feature is divided into sub-training coding features, the sub-training coding features are input into the autoregressive network for training to generate training weights for the autoencoder and the autoregressive network, the training weights obtained when the autoencoder and the autoregressive network are trained using the normal training sample are obtained, the training weights are loaded into the autoencoder and the autoregressive network to encode a test sample through the autoencoder loaded with the training weights to obtain a test coding feature, the test coding feature is divided into sub-test coding features, and the sub-test coding features are input one by one into the autoregressive network loaded with the training weights to output a test result, the test result including one of the presence of a defect in the test sample and the absence of a defect in the test sample. Thus, in this embodiment, the training weights can be obtained based on the normal training sample through the autoencoder, the split training coding features, and the autoregressive network training. This case can also directly use the essence of the test sample to determine whether the test sample has defects, instead of directly using the test sample to determine whether the test sample has defects, and there is no need to compare with the test sample, thereby avoiding noise in the test sample and avoiding errors in determining defects. At the same time, the test code features are divided into sub-test code features for testing, which can avoid mutual interference between the test code features and prevent defect information from being averaged, so that small defects can be accurately judged.
[0106] Figure 5 is a block diagram of an electronic device provided in a fifth embodiment of the present invention. The electronic device 5 includes a memory 51, at least one processor 52, and a computer program 53 stored in the memory 51 and executable on the at least one processor 52. When the at least one processor 52 executes the computer program 53, the steps of the aforementioned method embodiment are implemented. Alternatively, when the at least one processor 52 executes the computer program 53, the functions of the modules in the aforementioned device embodiment are implemented.
[0107] Exemplarily, the computer program 53 may be divided into one or more modules / units, which are stored in the memory 51 and executed by the at least one processor 52 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 53 in the electronic device 5. For example, the computer program 53 may be divided into Figure 1 The module shown or Figure 2 For the modules shown, please refer to Example 1 or Example 2 for the specific functions of each module.
[0108] The electronic device 5 can be any electronic product, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), etc. It will be understood by those skilled in the art that the schematic diagram Figure 5 This is only an example of the electronic device 5 and does not constitute a limitation of the electronic device 5. The electronic device 5 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 5 may also include a bus, etc.
[0109] The at least one processor 52 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. The processor 52 may be a microprocessor or any conventional processor, etc. The processor 52 is the control center of the electronic device 5 and connects various parts of the entire electronic device 5 using various interfaces and lines.
[0110] The memory 51 can be used to store the computer program 53 and / or modules / units. The processor 52 implements the various functions of the electronic device 5 by running or executing the computer-readable instructions and / or modules / units stored in the memory 51, and by accessing the data stored in the memory 51. The memory 51 may primarily include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), and the data storage area may store data generated based on the use of the electronic device 5 (such as audio data, etc.). In addition, the memory 51 may include non-volatile computer-readable memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device.
[0111] If the module / unit integrated in the electronic device 5 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 invention implements all or part of the process 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 executed by the processor, it can implement the steps of the above-mentioned method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), etc.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A defect detection method, characterized in that: The defect detection method comprises: Obtaining training weights obtained when training a network architecture including an autoencoder and an autoregressive network using normal training samples, wherein the normal training samples include images of defect-free product surfaces, and the training weights are training weights of the network architecture; Loading the training weights into the network architecture, and encoding the test sample using an autoencoder in the network architecture after loading the training weights to obtain a test encoding feature; Splitting the test coding signature into sub-test coding signatures; The sub-test coding features are input one by one into the autoregressive network in the network architecture after the training weights are loaded, and an output test result is obtained, wherein the test result includes one of the presence of defects in the test sample and the absence of defects in the test sample.
2. The defect detection method according to claim 1, wherein: The dividing the test coding feature into sub-test coding features comprises: determining a length of the test coding feature; Obtaining a preset condition for segmentation, wherein the preset condition includes one of a preset length and a preset number of parts; The test code feature of the length is divided into the sub-test code features according to the preset condition.
3. The defect detection method according to claim 1, wherein: Inputting the sub-test encoding features one by one into the autoregressive network in the network architecture loaded with the training weights to obtain the output test results includes: The sub-test coding features are input one by one into the autoregressive network in the network architecture after the training weights are loaded, until all sub-test coding feature tests are completed or it is determined that the sub-test coding features have defects, and the test results are obtained as output.
4. The defect detection method according to claim 3, wherein: Inputting the sub-test coding features one by one into the autoregressive network in the network architecture loaded with the training weights until all sub-test coding features are tested or it is determined that the sub-test coding features have defects includes: Inputting one of the subtest encoding features into the autoregressive network in the network architecture loaded with the training weights to obtain an output subtest result; determining whether the subtest coding feature has a defect based on the subtest result; If the subtest coding feature does not have defects, determining whether all subtest coding feature tests are complete; If not all sub-test coding feature tests are completed, continue to input the next sub-test coding feature into the autoregressive network in the network architecture after loading the training weights, determine whether the sub-test coding feature has defects, and determine whether all sub-test coding feature tests are completed until all sub-test coding feature tests are completed or it is determined that the sub-test coding feature has defects.
5. The defect detection method according to claim 4, wherein: The defect detection method further includes: If the sub-test coding feature has defects, a result indicating that the test sample has defects is output.
6. The defect detection method according to claim 4, wherein: The defect detection method further includes: If all sub-test coding feature tests are completed, the result indicating that the test sample has no defects is output.
7. The defect detection method according to claim 1, wherein: The defect detection method further includes: Get normal training samples; Inputting the normal training sample into the autoencoder to encode the normal training sample to obtain a training coding feature; Splitting the training coding features into sub-training coding features; The sub-training encoding features are input into the autoregressive network for training to generate the training weights.
8. A defect detection device, characterized in that: The defect detection device comprises: a training weight acquisition module, configured to acquire training weights obtained by training a network architecture comprising an autoencoder and an autoregressive network using normal training samples, wherein the normal training samples include images of defect-free product surfaces, and the training weights are the training weights of the network architecture; A test encoding module is used to load the training weights into the network architecture, and encode the test sample by the autoencoder in the network architecture after loading the training weights to obtain a test encoding feature; A test splitting module, configured to split the test coding feature into sub-test coding features; An output module is used to input the sub-test coding features one by one into the autoregressive network in the network architecture after loading the training weights, and obtain an output test result, wherein the test result includes one of the following: the test sample has defects and the test sample does not have defects.
9. An electronic device, characterized in that: The electronic device includes one or more processors and a memory, and the processor is configured to implement the defect detection method according to any one of claims 1 to 7 when executing at least one instruction stored in the memory.
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 to implement the defect detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Structure local defect detection method based on vector autoregression model
CN110555235A
Surface defect detection method and device and electronic device
CN110619618A