Product anomaly detection method, device, equipment and storage medium

By obtaining the product feature matrix and unknown anomaly indicators in the classification model, combining the product category and spatial vector distance or encoder loss value, and optimizing the training process, the problem that the classification model cannot detect the type of defective products is solved, and the accuracy of product anomaly detection is improved.

CN115935229BActive Publication Date: 2025-09-26GOERTEK INC
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211470506.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-22
Publication Date
2025-09-26
Estimated Expiration
2042-11-22

AI Technical Summary

Technical Problem

In the existing technology, the classification model in the industrial big data scenario cannot accurately detect defective product types that do not exist in the training dataset in product anomaly detection, resulting in low detection accuracy.

Method used

By obtaining the product feature matrix output by the input layer of the preset classification model, the unknown abnormality indicators are determined, and the product category is combined to determine whether the product has unknown abnormalities. Including using indicators such as spatial vector distance and encoder loss value, the training process of the classification model is optimized to improve detection accuracy.

Benefits of technology

The accuracy of product anomaly detection is improved, and defective product types that do not exist in the training data set can be more accurately identified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115935229B_ABST
    Figure CN115935229B_ABST
Patent Text Reader

Abstract

The present invention discloses a product anomaly detection method, apparatus, equipment, and storage medium. The method comprises: inputting product data of a product to be detected into a preset classification model, and obtaining the product category of the product to be detected output by the preset classification model; obtaining a product feature matrix output by the input layer of the preset classification model based on the product data; determining an unknown anomaly index based on the product feature matrix, and determining whether the product to be detected has an unknown anomaly based on the unknown anomaly index and the product category. The present invention determines the unknown anomaly index of the product to be detected based on the product feature matrix output by the input layer in the preset classification model, and determines whether the product to be detected has an unknown anomaly based on the unknown anomaly index and the product category. This solves the technical problem in the prior art that, in the process of using a classification model for product anomaly detection, the classification model cannot accurately detect defective product types that do not exist in the training data set, thereby improving the accuracy of product anomaly detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent manufacturing technology, and in particular to a product anomaly detection method, device, equipment and storage medium. Background Art

[0002] With the development of deep learning technology, the application of artificial intelligence in the field of industrial quality inspection is becoming more and more common. Among them, classification models are widely used due to their relatively simple labeling and relatively stable performance. However, in the industrial big data scenario, due to the complexity of actual production conditions, when using classification models for anomaly detection, defective product types that do not exist in the training data set may appear, and the classification model cannot detect such defective product types, resulting in low anomaly detection accuracy of the classification model.

[0003] The above content is only used to assist in understanding the technical solution of the present invention and does not constitute an admission that the above content is prior art. Summary of the Invention

[0004] The main purpose of the present invention is to provide a product anomaly detection method, device, equipment and storage medium, aiming to solve the technical problem of low accuracy of product anomaly detection in classification models in industrial big data scenarios in the existing technology.

[0005] To achieve the above object, the present invention provides a product anomaly detection method, which includes the following steps:

[0006] Input the product data of the product to be tested into a preset classification model, and obtain the product category of the product to be tested output by the preset classification model;

[0007] Obtain the product feature matrix output by the input layer of the preset classification model based on the product data;

[0008] Determine the unknown abnormality index according to the product feature matrix, and determine whether the product to be tested has unknown abnormality according to the unknown abnormality index and product category.

[0009] Optionally, the unknown anomaly indicator includes a first space vector distance;

[0010] Determine unknown abnormality indicators based on the product feature matrix, and determine whether the product to be tested has unknown abnormalities based on the unknown abnormality indicators and product categories, including:

[0011] The product feature matrix is ​​processed by the feature extraction network of the preset classification model and then output to the fully connected layer of the preset classification model;

[0012] Obtaining a product feature vector output by the fully connected layer, and determining a first spatial vector distance based on the product feature vector and a first preset good product cluster center;

[0013] Determine whether the product to be inspected has an unknown abnormality based on the first space vector distance and the product category.

[0014] Optionally, the unknown abnormality indicator includes a loss value of a preset encoder;

[0015] Determine the unknown abnormality index based on the product feature matrix, and determine whether the product to be tested has unknown abnormality based on the unknown abnormality index and the product category, including:

[0016] Input the product feature matrix into the feature extraction network of the preset classification model, and obtain the extracted feature vector output by the feature extraction network;

[0017] Input the extracted feature vector to the feature vector layer of the preset encoder, and obtain the decoded feature vector output by the output layer of the preset encoder;

[0018] Determining a loss value of a preset encoder based on the extracted feature vector, the decoded feature vector, and a preset loss coefficient;

[0019] Determine whether the product to be inspected has unknown abnormalities based on the product category and loss value.

[0020] Optionally, before inputting the product data of the product to be detected into a preset classification model and obtaining the product category of the product to be detected output by the preset classification model, the process further includes:

[0021] Pre-train the initial neural network using training data to obtain a pre-trained classification model;

[0022] Determine the first product category cluster center corresponding to each product category based on the pre-trained classification model;

[0023] Update the loss function of the pre-trained classification model based on the feature vector output by the fully connected layer in the pre-trained classification model, the first product category cluster center corresponding to each product category, and the preset spatial vector distance;

[0024] Train the pre-trained classification model after updating the loss function using training data;

[0025] When the pre-trained classification model after updating the loss function meets the preset conditions, a preset classification model is obtained.

[0026] Optionally, after determining the loss value of the preset encoder according to the extracted feature vector, the decoded feature vector, and the preset loss coefficient, the method further includes:

[0027] Determine a second space vector distance based on the extracted feature vector and the second preset good product cluster center;

[0028] Determine whether the product to be inspected has an unknown abnormality based on the product category, the loss value and the second space vector distance.

[0029] Optionally, before inputting the product feature matrix into a feature extraction network of a preset classification model and obtaining an extracted feature vector output by the feature extraction network, the method further includes:

[0030] Inputting the training data into the initial encoder and the initial neural network, and obtaining a second initial feature vector set output by the feature vector layer in the initial encoder;

[0031] Determining a second product category cluster center corresponding to each product category based on the second initial feature vector set;

[0032] Update the loss function of the initial encoder based on the feature vector output by the feature vector layer, the second product category cluster center corresponding to each product category, the preset space vector distance, and the product category probability output by the initial neural network;

[0033] Train the initial neural network and the initial encoder after updating the loss function using the training data;

[0034] When the preset conditions are met, a preset encoder and a preset classification model are obtained.

[0035] Optionally, determining whether the product to be inspected has an unknown abnormality according to the product category, the loss value, and the second space vector distance includes:

[0036] When the product category is good product, determining whether the loss value is greater than a preset loss threshold and / or whether the second space vector distance is greater than a preset distance threshold;

[0037] If so, it is determined that the product to be tested has an unknown abnormality.

[0038] In addition, to achieve the above-mentioned purpose, the present invention further provides a product abnormality detection device, the device comprising:

[0039] An input module, used to input the product data of the product to be tested into a preset classification model, and obtain the product category of the product to be tested output by the preset classification model;

[0040] An acquisition module is used to obtain a product feature matrix output by the input layer of a preset classification model based on product data;

[0041] The determination module is used to determine the unknown abnormality index according to the product feature matrix, and determine whether the product to be detected has an unknown abnormality according to the unknown abnormality index and the product category.

[0042] In addition, to achieve the above-mentioned purpose, the present invention also proposes a product abnormality detection device, which includes: a memory, a processor, and a product abnormality detection program stored on the memory and runnable on the processor, and the product abnormality detection program is configured to implement the steps of the product abnormality detection method as described above.

[0043] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a product anomaly detection program is stored. When the product anomaly detection program is executed by a processor, the steps of the product anomaly detection method as described above are implemented.

[0044] The present invention inputs the product data of the product to be detected into a preset classification model and obtains the product category of the product to be detected output by the preset classification model; obtains the product feature matrix output by the input layer of the preset classification model based on the product data; determines the unknown anomaly index based on the product feature matrix, and determines whether the product to be detected has an unknown anomaly based on the unknown anomaly index and the product category. The present invention determines the unknown anomaly index of the product to be detected based on the product feature matrix output by the input layer of the preset classification model, and determines whether the product to be detected has an unknown anomaly based on the unknown anomaly index and the product category. This solves the technical problem in the prior art of using a classification model to perform product anomaly detection, in which the classification model cannot accurately detect defective product types that do not exist in the training data set, thereby improving the accuracy of product anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a structural diagram of a product anomaly detection device in a hardware operating environment involved in an embodiment of the present invention;

[0046] Figure 2 This is a flow chart of a first embodiment of a method for detecting product anomalies according to the present invention;

[0047] Figure 3 This is a flow chart of a second embodiment of the product anomaly detection method of the present invention;

[0048] Figure 4 This is a schematic diagram of the model structure of an embodiment of the product anomaly detection method of the present invention;

[0049] Figure 5 This is a flow chart of a third embodiment of the product anomaly detection method of the present invention;

[0050] Figure 6 This is a structural block diagram of the first embodiment of the product abnormality detection device of the present invention.

[0051] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0053] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a product anomaly detection device in the hardware operating environment involved in an embodiment of the present invention.

[0054] like Figure 1 As shown, the product anomaly detection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard. Optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a wireless fidelity (WI-FI) interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0055] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the product abnormality detection device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0056] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a product anomaly detection program.

[0057] exist Figure 1 In the product anomaly detection device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the product anomaly detection device of the present invention can be set in the product anomaly detection device, and the product anomaly detection device calls the product anomaly detection program stored in the memory 1005 through the processor 1001, and executes the product anomaly detection method provided by the embodiment of the present invention.

[0058] The embodiment of the present invention provides a method for detecting product anomalies. Figure 2 , Figure 2 Schematic diagram of the process of the first embodiment of the product anomaly detection method of the present invention.

[0059] In this embodiment, the product anomaly detection method includes the following steps:

[0060] Step S10: inputting the product data of the product to be inspected into a preset classification model, and obtaining the product category of the product to be inspected output by the preset classification model.

[0061] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of performing the above functions, a product anomaly detection device, etc. The following uses a product anomaly detection device (hereinafter referred to as the detection device) as an example to illustrate this embodiment and the following embodiments.

[0062] It can be understood that the product to be inspected can be a product that needs to be detected for abnormalities, and the product data can be data collected by acquisition equipment for product abnormality detection. For example, the product data includes product image data, product audio data, etc.; the preset classification model can be a classification model obtained through training for product abnormality detection; the preset classification model includes an input layer, a feature extraction network, a fully connected layer, and an output layer; product categories include good products and defective products, and defective products can be divided into multiple categories, such as chipped corners, scratches, color differences, etc. The category of defective products is determined according to the specific detection scenario and is not limited to the above types.

[0063] Step S20: Obtaining a product feature matrix output by the input layer of a preset classification model based on product data;

[0064] Step S30: Determine the unknown abnormality index according to the product feature matrix, and determine whether the product to be tested has unknown abnormality according to the unknown abnormality index and the product category.

[0065] In a specific implementation, the product data of the product to be inspected is input into a preset classification model, and the product category output by the preset classification model is obtained. The product feature matrix output by the input layer of the preset classification model based on the product data is obtained, and the unknown abnormality index is determined based on the product feature matrix. Based on the unknown abnormality index, the preset index threshold and the product category, it is determined whether the product to be inspected has an unknown abnormality. For example, if the product category output by the preset classification model is a good product and the unknown abnormality index is greater than the preset index threshold, then it is determined that the product to be inspected has an unknown abnormality.

[0066] Furthermore, in order to improve the accuracy of product anomaly detection, the unknown anomaly indicator includes a first space vector distance. Step S30 includes: processing the product feature matrix through the feature extraction network of the preset classification model and outputting it to the fully connected layer of the preset classification model; obtaining the product feature vector output by the fully connected layer, and determining the first space vector distance based on the product feature vector and the first preset good product cluster center; and determining whether the product to be detected has an unknown anomaly based on the first space vector distance and the product category.

[0067] It can be understood that the product feature vector can be the vector output by the fully connected layer based on the feature vector extracted by the feature extraction network; the first preset good product cluster center can be the cluster center of the good product in the fully connected layer; the first spatial vector distance can be the distance between the product feature vector and the first preset good product cluster center.

[0068] It is understandable that an unknown anomaly may be a product anomaly that the classification model cannot accurately detect. For example, the product itself has an anomaly, but the classification model outputs the category of good product. In this case, the anomaly of the product can be called an unknown anomaly.

[0069] In a specific implementation, for example, the product data of the product to be inspected is image data. The image data of the product to be inspected is collected by an acquisition camera, and the image data is input into a preset classification model. The image data is output after passing through the feature extraction network, the fully connected layer and the output layer to output the product category. The product feature vector output by the fully connected layer is obtained, and the first space vector distance between the product feature vector and the first preset good product cluster center is calculated. If the product category is good, it is further determined whether the first space vector distance is greater than the preset distance threshold. If not, it is determined that the product category of the product to be inspected is good. If so, it is determined that there is an unknown abnormality in the product to be inspected, and an early warning information of an unknown abnormality in the product to be inspected is issued.

[0070] Furthermore, in order to improve the accuracy of product anomaly detection, before the product data of the product to be detected is input into the preset classification model and the product category of the product to be detected output by the preset classification model is obtained, it also includes: pre-training the initial neural network through training data to obtain a pre-trained classification model; determining the first product category cluster center corresponding to each product category according to the pre-trained classification model; updating the loss function of the pre-trained classification model according to the feature vector output by the fully connected layer in the pre-trained classification model, the first product category cluster center corresponding to each product category and the preset space vector distance; training the pre-trained classification model after the updated loss function through training data; and obtaining the preset classification model when the pre-trained classification model after the updated loss function meets the preset conditions.

[0071] In this embodiment, the initial neural network is pre-trained using training data, and a pre-trained classification model is obtained when the first loss function of the initial neural network is less than a preset loss threshold; a first initial feature vector set corresponding to each product category in the training data is determined based on the pre-trained classification model, and a first product category cluster center corresponding to each product category is determined based on the first initial feature vector set corresponding to each product category; a second loss function is determined based on the feature vector output by the fully connected layer in the pre-trained classification model, the first product category cluster center corresponding to each product category, and the preset space vector distance; the first loss function of the pre-trained classification model is updated based on the second loss function, and the pre-trained classification model after the updated loss function is trained using the training data; and a preset classification model is obtained when the pre-trained classification model after the updated loss function meets the preset conditions.

[0072] It can be understood that the training data can be product data for training the initial neural network; the first loss function can be a pre-set loss function of the initial neural network, which can adopt a common classification loss function. When the loss value of the first loss function is less than the preset loss threshold, it is determined that the pre-training of the initial neural network is completed, and a pre-trained classification model is obtained; the first initial feature vector set can be a set of initial feature vectors corresponding to the training data of each product category output by the fully connected layer in the pre-trained classification model. Assuming that there are h categories of products, there are h corresponding first initial feature vector sets. The number of initial feature vectors in the first initial feature vector set is equal to the number of training data of the same product category. For example, if there are Q training data of product category P, then the number of initial feature vectors in the first initial feature vector set corresponding to P is Q.

[0073] It should be understood that determining the first initial feature vector set corresponding to each product category in the training data according to the pre-trained classification model can be inputting the training data of each product category into the pre-trained classification model, obtaining the feature vector output by the fully connected layer in the pre-trained classification model, and the feature vectors corresponding to the training data of the same product category constitute the first initial feature vector set corresponding to the product category; determining the first product category cluster center corresponding to each product category according to the first initial feature vector set corresponding to each product category can be determining the first product category cluster center corresponding to the product category according to each initial feature vector contained in the first initial feature vector set corresponding to each product category; the number of first product cluster centers corresponds to the number of product categories. For example, if there are h product categories, there are h corresponding first product cluster centers.

[0074] In this embodiment, the anomaly detection method based on the spatial vector space is added to the fully connected layer of the pre-trained classification model, and the second loss function is determined based on the feature vector output by the fully connected layer, the cluster center of the first product category, and the preset spatial vector distance. Assuming that the product category represented by 0 is a good product, the second loss function can be expressed by Formula 1:

[0075]

[0076] Where k is a constant that can be set according to the specific application scenario. For example, k can be set to 0.5, 0.2, or other values ​​greater than 0 and less than 1. δ() means that when the conditions in the brackets are met, the value is 1, otherwise it is 0. i Represents the feature vector output by the fully connected layer, c j Represents x i The first product cluster center of the corresponding product category, a j Represents the product category output by the output layer; n represents the number of feature vectors; c0 represents the first preset good product cluster center; m represents the preset spatial vector distance, which can be set according to the specific scenario.

[0077] It can be understood that updating the first loss function of the pre-trained classification model according to the second loss function can be based on the first loss function of the pre-trained classification model, adding the second loss function, and using the added loss function as the loss function of the pre-trained classification model.

[0078] Furthermore, in order to determine the first product category cluster center corresponding to each product category, the method of determining the first product category cluster center corresponding to each product category based on the first initial feature vector set corresponding to each product category includes: calculating the average value of the initial feature vector of the first initial feature vector set corresponding to each product category to obtain the first product category cluster center corresponding to each product category.

[0079] In the specific implementation, for example: define i as the serial number of the current training data in the dataset Dataset0, j represents the product category to which the current training data belongs, c j After all the training data of the jth category are input into the initial neural network, the feature vector x output by the fully connected layer of the initial neural network is i The mean of the first product category cluster center c of the jth product category in the fully connected layer j The good product cluster center in the first product cluster center can be recorded as c0. The initial neural network is trained through training data. When the loss value of the first loss function of the initial neural network is less than the preset loss threshold, the pre-training is ended and the pre-trained classification model is obtained. During the pre-training of the initial neural network, only the cluster center c of each product category is maintained and calculated. j, no additional operations are performed; after obtaining the pre-trained classification model, according to the feature vector x output by the fully connected layer in the pre-trained classification model i , the first product category cluster center c j , the good product cluster center c0 of the first product cluster center and the preset space vector distance m determine the second loss function, which can be expressed by formula 1, δ(a j ≠0) means that when the product category output by the output layer does not belong to category 0, the value is 1, otherwise it is 0; the second loss function Loss center1 The first half of Indicate that, let the eigenvector x i The distance from the cluster center of its corresponding j category is reduced; the second loss function Loss center1 The second half of δ(a j ≠0)max(0,m-||x i -c0|| 2 ) means that when the product category corresponding to the training data does not belong to category 0, let x i The distance from the cluster center c0 of class 0 is enlarged; m is a threshold parameter, when the feature vector x does not belong to class 0 i When the distance from the cluster center of class 0 is greater than m, the loss is 0. The second loss function is added to the first loss function of the pre-trained classification model for optimization. At this time, the loss function of the pre-trained classification model can be finally expressed as: Loss = Loss lable +Loss center1 , Loss lable Represents the first loss function, Loss lable A common classification loss function can be used to continue training the pre-trained model after the updated loss function through training data, and when the pre-trained model meets the preset training termination conditions, a preset classification model is obtained, and the product data of the product to be tested is input into the preset classification model to obtain the product feature vector output by the fully connected layer of the preset classification model and the product category output by the output layer. Assume that the product category output by the output layer is category 0, but the distance between the product feature vector and the cluster center c0 of category 0 is greater than the preset distance threshold. At this time, it is determined that the product to be tested has an unknown abnormality, where the preset training termination conditions can be that the model accuracy is greater than the preset accuracy, the number of model training times is greater than the preset number, and the loss value of the loss function is less than the preset value, etc.; the preset distance threshold can be expressed as α*m, where α can be set to a value between 0.5 and 1.

[0080] This embodiment inputs the product data of the product to be inspected into a preset classification model and obtains the product category of the product to be inspected output by the preset classification model; obtains the product feature matrix output by the input layer of the preset classification model based on the product data; determines the unknown anomaly index based on the product feature matrix, and determines whether the product to be inspected has an unknown anomaly based on the unknown anomaly index and the product category. This embodiment determines the unknown anomaly index of the product to be inspected based on the product feature matrix output by the input layer of the preset classification model, and determines whether the product to be inspected has an unknown anomaly based on the unknown anomaly index and the product category. This solves the technical problem in the prior art of using a classification model for product anomaly detection, in which the classification model cannot accurately detect defective product types that do not exist in the training data set, thereby improving the accuracy of product anomaly detection.

[0081] refer to Figure 3 , Figure 3 2 is a flow chart of the second embodiment of the product anomaly detection method of the present invention.

[0082] Based on the first embodiment, in this embodiment, the unknown abnormality indicator includes a loss value of a preset encoder, and step S30 further includes:

[0083] Step S301: Input the product feature matrix into the feature extraction network of the preset classification model to obtain the extracted feature vector output by the feature extraction network.

[0084] It can be understood that the feature extraction vector can be a vector output after the feature extraction network extracts features from the input data.

[0085] Step S302: input the extracted feature vector to the feature vector layer of the preset encoder, and obtain the decoded feature vector output by the output layer of the preset encoder.

[0086] In this embodiment, referring to Figure 4 , Figure 4 is a schematic diagram of the model structure. Figure 4 The structure within the dotted box can be removed. The preset encoder may include a feature vector layer, a decoding layer, and an output layer. The feature vector output by the feature extraction network in the preset classification model can be used as the input of the feature vector layer in the preset encoder, and the decoded feature vector output by the output layer of the preset encoder can be obtained. The input layer, Gaussian transform layer, and encoder of the preset encoder can be removed, and the extracted feature vector output by the feature extraction network in the preset classification model can be used as the output of the encoder and input into the feature vector layer.

[0087] Step S303: determining a loss value of a preset encoder according to the extracted feature vector, the decoded feature vector and the loss coefficient.

[0088] It can be understood that the category probability of the product category output by the output layer of the preset classification model will be input into the feature vector layer of the preset encoder.

[0089] Step S304: Determine whether the product to be inspected has any unknown anomaly based on the product category and loss value.

[0090] It should be understood that determining whether the product to be inspected has unknown abnormalities based on the product category and loss value can be to judge whether the loss value is greater than the preset loss threshold when the product category is a good product. If so, it is determined that the product to be inspected has unknown abnormalities.

[0091] In another implementation, continue to refer to Figure 4 The preset encoder may also include an input layer, a Gaussian transform layer, a feature extraction layer, a decoding layer and an output layer. The product data can be input into the input layer of the preset classification model and the input layer of the preset encoder at the same time. The preset classification model and the preset encoder can share an input layer. The preset classification model includes a feature extraction network, a fully connected layer and an output layer. The product data of the product to be detected is input from the input layer. The output layer of the preset classification model outputs the category probability of the product category, and transmits the category probability to the feature vector layer of the preset encoder. The Gaussian transform layer of the preset encoder performs a Gaussian transform on the product data to obtain the feature vector input to the encoder, and obtains the decoded feature vector output by the output layer. The loss value is calculated according to the category probability, the feature vector input to the encoding layer and the decoding feature vector through the loss function of the preset encoder. When the product category output by the preset encoder is a good product, it is determined whether the loss value is greater than the preset loss threshold. If so, it is determined that the product to be detected has an unknown abnormality.

[0092] In the specific implementation, continue to refer to Figure 4 For example, the product data is input from the input layer, passed through the feature extraction network, full connection layer and output layer 1 of the preset classification model, and the category probability of the product category output by the output layer 1 is recorded as pred i , softmax_pred i Pred i Normalized version of ; After the Gaussian transform layer, encoding layer, feature vector layer, decoding layer and output layer 2 of the preset encoder, the decoded feature vector output by output layer 2 is recorded as The feature vector input to the encoding layer after Gaussian transformation is recorded as The loss value of the preset encoder can be calculated by formula 2:

[0093]

[0094] Where W is the preset loss coefficient, which can be set to a constant value. In the process of training the initial encoder using training data, in order to prevent the encoder from overfitting, the loss of the classification model can be used to help optimize the encoder to improve the performance of the encoder. In this process, W can be determined by Formula 3:

[0095]

[0096] In the formula Where N represents the total number of training samples, label i represents the sample label of the i-th sample, The meaning of is the accuracy of the current model, and W is equivalent to mixing the prediction of the sample by the classification model with the actual label of the sample to prevent the encoder from overfitting.

[0097] Furthermore, in order to improve the accuracy of product anomaly detection, step S303, after which, also includes: determining the second space vector distance based on the extracted feature vector and the second preset good product cluster center; and determining whether there is an unknown anomaly in the product to be detected based on the product category, loss value, and the second space vector distance.

[0098] It can be understood that the second space vector distance may be the distance between the extracted feature vector and the second preset good product cluster center.

[0099] Furthermore, in order to improve the accuracy of product abnormality detection, it is determined whether the product to be inspected has unknown abnormalities based on the product category, loss value and second space vector distance, including: when the product category is a good product, judging whether the loss value is greater than the preset loss threshold and / or whether the second space vector distance is greater than the preset distance threshold; if so, it is determined that the product to be inspected has unknown abnormalities.

[0100] This embodiment inputs the product feature matrix into the feature extraction network of the preset classification model to obtain the extracted feature vector output by the feature extraction network; inputs the extracted feature vector into the feature vector layer of the preset encoder, and obtains the decoded feature vector output by the output layer of the preset encoder; determines the loss value of the preset encoder based on the extracted feature vector, the decoded feature vector and the loss coefficient; and determines whether the product to be detected has an unknown abnormality based on the product category and the loss value. This embodiment determines whether the product to be detected has an unknown abnormality based on the product category output by the preset classification model and the loss value of the preset encoder. On the basis of the preset classification model, a preset encoder is introduced, and the difference between the output after encoding and the output before encoding is measured by the loss value of the preset encoder. The product category output by the preset classification model and the difference are used to comprehensively judge whether the product to be detected has an unknown abnormality, thereby improving the accuracy of unknown abnormality detection of products.

[0101] refer to Figure 5 , Figure 52 is a flow chart of the third embodiment of the product anomaly detection method of the present invention.

[0102] Based on the above embodiments, in this embodiment, before step S301, the following steps are further included:

[0103] Step S01: input training data into the initial encoder and the initial neural network, and obtain a second initial feature vector set output by the feature vector layer in the initial encoder.

[0104] It can be understood that the second initial feature vector set can be an initial feature vector set corresponding to each product category. Assuming there are h categories of products, there are corresponding h second initial feature vector sets.

[0105] Step S02: input the training data into the initial encoder and the initial neural network, and obtain a second initial feature vector set output by the feature vector layer in the initial encoder.

[0106] In this embodiment, the average value of each initial eigenvector in the second initial eigenvectors corresponding to each product category is calculated to obtain the second product category cluster center corresponding to each product category. The number of the second product category cluster centers corresponds to the number of product categories.

[0107] Step S03: Update the loss function of the initial encoder according to the feature vector output by the feature vector layer, the second product category cluster center corresponding to each product category, the preset space vector distance and the product category probability output by the initial neural network.

[0108] In this embodiment, a third loss function is determined based on the feature vector output by the feature vector layer, the second product category cluster center corresponding to each product category, the preset space vector distance, and the product category probability output by the initial neural network, and the loss function of the initial encoder is updated based on the third loss function;

[0109] Step S04: training the initial neural network and the initial encoder after updating the loss function using the training data;

[0110] Step S05: When the preset conditions are met, a preset encoder and a preset classification model are obtained.

[0111] In the specific implementation, for example, i is defined as the serial number of the current training data in the total data set, j represents the product category to which the current training data belongs, c j The feature vector x output by the feature vector layer of the encoder for all training data of the jth product category i The mean of j The meaning is the second product category cluster center of the jth product category in the feature vector layer, and the feature vector x output by the feature vector layer is iExtract it, and determine the third loss function based on the feature vector, the second product category cluster center corresponding to each product category, the preset spatial vector distance, and the category probability output by the preset classification model. The third loss function is shown in Formula 4:

[0112]

[0113] In the formula, δ() means that when the product category is 0, the value is 1, otherwise the value is 0; the first half of formula 4: Indicates that during the model training process, let x i Distance from the cluster center c of the corresponding j-th product category j The distance is calculated according to the product category probability pred output by the initial neural network. i The sample label of the training sample in the training data i j is used to represent the jth term of the vector in the brackets, T is a constant that can be set according to the specific scenario, for example, T can be set to a constant greater than 1; β can be set to a value between [0,1] according to the actual scenario, or it can be set to the same value as α; the second half of formula 4: δ(b j ≠0)max(0,m-||x i -c0|| 2 ) indicates that during model training, when the product category of the training sample does not belong to category 0, x is calculated. i The difference between the distance from the cluster center c0 of the product category 0 and m is the maximum value between the difference and 0, thus achieving the goal of letting x i The distance amplification effect from the cluster center c0 of the 0-class product category, m is the preset space vector distance. When the distance between the training sample that does not belong to the 0-class and the 0-class cluster center c0 is greater than m, the loss is 0, b j Represents the product category output by the classification model; add the above loss function to the loss of the initial encoder to update the loss function of the initial encoder. The loss function of the initial neural network can use Loss, Loss lable or Loss center1, the model composed of the initial encoder and the initial neural network after the updated loss function is trained using training data, and when the model meets preset conditions, a preset encoder and a preset classification model are obtained, wherein the preset conditions include that the model accuracy is greater than the preset accuracy, the model loss function is less than the preset loss value, and the number of training times reaches the preset number of training times. When product anomaly detection is performed using the trained model, the product data of the product to be detected is input into the input layer of the model, the preset encoder and the preset classification model share an input layer, the product category output by the preset classification model and the product feature vector output by the feature vector layer of the preset encoder are obtained, and the second space vector distance is determined based on the product feature vector and the second preset good product cluster center. When the product category is 0, it is judged whether the second space vector distance is greater than the preset distance threshold α*m. If so, it is determined that the product to be detected has an unknown anomaly. It is also possible to judge whether the second space vector distance is greater than the preset distance threshold and / or whether the loss value of the preset encoder is greater than the preset loss value when the product category output by the preset classification model is 0. If so, it is determined that the product to be detected has an unknown anomaly.

[0114] During the model training process, this embodiment introduces the product category output by the initial neural network into the loss function of the initial encoder to guide the training of the preset encoder, so that the trained model can more accurately detect unknown anomalies in the product, thereby improving the accuracy of product anomaly detection.

[0115] In addition, an embodiment of the present invention further provides a storage medium, on which a product anomaly detection program is stored. When the product anomaly detection program is executed by a processor, the steps of the product anomaly detection method described above are implemented.

[0116] Reference Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the product abnormality detection device of the present invention.

[0117] like Figure 6 As shown, the product anomaly detection device proposed in the embodiment of the present invention includes:

[0118] An input module 10 is used to input product data of the product to be tested into a preset classification model and obtain the product category of the product to be tested output by the preset classification model;

[0119] An acquisition module 20 is used to obtain a product feature matrix output by an input layer of a preset classification model based on product data;

[0120] The determination module 30 is used to determine the unknown abnormality index according to the product feature matrix, and determine whether the product to be detected has an unknown abnormality according to the unknown abnormality index and the product category.

[0121] This embodiment inputs the product data of the product to be inspected into a preset classification model and obtains the product category of the product to be inspected output by the preset classification model; obtains the product feature matrix output by the input layer of the preset classification model based on the product data; determines the unknown anomaly index based on the product feature matrix, and determines whether the product to be inspected has an unknown anomaly based on the unknown anomaly index and the product category. This embodiment determines the unknown anomaly index of the product to be inspected based on the product feature matrix output by the input layer of the preset classification model, and determines whether the product to be inspected has an unknown anomaly based on the unknown anomaly index and the product category. This solves the technical problem in the prior art of using a classification model for product anomaly detection, in which the classification model cannot accurately detect defective product types that do not exist in the training data set, thereby improving the accuracy of product anomaly detection.

[0122] Based on the first embodiment of the product abnormality detection device of the present invention, a second embodiment of the product abnormality detection device of the present invention is proposed.

[0123] In this embodiment, the determination module 30 is also used to output the product feature matrix to the fully connected layer of the preset classification model after being processed by the feature extraction network of the preset classification model; obtain the product feature vector output by the fully connected layer, and determine the first space vector distance based on the product feature vector and the first preset good product cluster center; determine whether there is an unknown abnormality in the product to be inspected based on the first space vector distance and the product category, and the unknown abnormality indicator includes the first space vector distance.

[0124] The determination module 30 is also used to input the product feature matrix into the feature extraction network of the preset classification model, and obtain the extracted feature vector output by the feature extraction network; input the extracted feature vector into the feature vector layer of the preset encoder, and obtain the decoded feature vector output by the output layer of the preset encoder; determine the loss value of the preset encoder based on the extracted feature vector, the decoded feature vector and the preset loss coefficient; determine whether there is an unknown abnormality in the product to be detected based on the product category and the loss value, and the unknown abnormality indicator includes the loss value of the preset encoder.

[0125] The input module 10 is also used to pre-train the initial neural network through training data to obtain a pre-trained classification model; determine the first product category cluster center corresponding to each product category according to the pre-trained classification model; update the loss function of the pre-trained classification model according to the feature vector output by the fully connected layer in the pre-trained classification model, the first product category cluster center corresponding to each product category and the preset space vector distance; train the pre-trained classification model after the updated loss function through the training data; and obtain the preset classification model when the pre-trained classification model after the updated loss function meets the preset conditions.

[0126] The determination module 30 is further configured to determine a second space vector distance based on the extracted feature vector and the second preset good product cluster center; and determine whether the product to be inspected has an unknown abnormality based on the product category, loss value, and the second space vector distance.

[0127] The determination module 30 is further used to input the training data into the initial encoder and the initial neural network, and obtain a second initial feature vector set output by the feature vector layer in the initial encoder; determine the second product category cluster center corresponding to each product category based on the second initial feature vector set; update the loss function of the initial encoder based on the feature vector output by the feature vector layer, the second product category cluster center corresponding to each product category, the preset space vector distance and the product category probability output by the initial neural network; train the initial neural network and the initial encoder after the updated loss function through the training data; and obtain the preset encoder and the preset classification model when the preset conditions are met.

[0128] The determination module 30 is also used to determine whether the loss value is greater than a preset loss threshold and / or whether the second space vector distance is greater than a preset distance threshold when the product category is a good product; if so, it is determined that there is an unknown abnormality in the product to be detected.

[0129] Other embodiments or specific implementations of the product anomaly detection device of the present invention can refer to the above-mentioned method embodiments and will not be repeated here.

[0130] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.

[0131] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0132] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0133] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A product anomaly detection method, characterized in that: The method comprises: Inputting product data of the product to be detected into a preset classification model, and obtaining the product category of the product to be detected output by the preset classification model; Obtaining a product feature matrix output by an input layer of the preset classification model according to the product data; Determining an unknown abnormality index according to the product feature matrix, and determining whether the product to be tested has an unknown abnormality according to the unknown abnormality index and the product category; Wherein, when the unknown abnormality indicator includes the first space vector distance, determining the unknown abnormality indicator according to the product feature matrix, and determining whether the product to be detected has an unknown abnormality according to the unknown abnormality indicator and the product category includes: Processing the product feature matrix through the feature extraction network of the preset classification model and outputting it to the fully connected layer of the preset classification model; Obtaining a product feature vector output by the fully connected layer, and determining the first spatial vector distance based on the product feature vector and a first preset good product cluster center; determining whether the product to be inspected has an unknown abnormality according to the first space vector distance and the product category; When the unknown abnormality indicator includes a loss value of a preset encoder, determining the unknown abnormality indicator according to the product feature matrix, and determining whether the product to be detected has an unknown abnormality according to the unknown abnormality indicator and the product category, includes: Inputting the product feature matrix into the feature extraction network of the preset classification model, and obtaining the extracted feature vector output by the feature extraction network; Inputting the extracted feature vector into the feature vector layer of the preset encoder, and obtaining the decoded feature vector output by the output layer of the preset encoder; Determining a loss value of the preset encoder according to the extracted feature vector, the decoded feature vector and a preset loss coefficient; Determine whether the product to be inspected has an unknown abnormality based on the product category and the loss value.

2. The method according to claim 1, wherein Before inputting the product data of the product to be detected into the preset classification model and obtaining the product category of the product to be detected output by the preset classification model, the method further includes: Pre-train the initial neural network using training data to obtain a pre-trained classification model; Determining a first product category cluster center corresponding to each product category according to the pre-trained classification model; Updating the loss function of the pre-trained classification model according to the feature vector output by the fully connected layer in the pre-trained classification model, the first product category cluster center corresponding to each product category, and the preset spatial vector distance; Training the pre-trained classification model after updating the loss function using the training data; When the pre-trained classification model after the updated loss function meets the preset conditions, a preset classification model is obtained.

3. The method according to claim 1, wherein After determining the loss value of the preset encoder according to the extracted feature vector, the decoded feature vector and the preset loss coefficient, the method further includes: Determining a second space vector distance based on the extracted feature vector and the second preset good product cluster center; Determine whether the product to be inspected has an unknown abnormality according to the product category, the loss value and the second space vector distance.

4. The method according to claim 1, wherein Before inputting the product feature matrix into the feature extraction network of the preset classification model and obtaining the extracted feature vector output by the feature extraction network, the method further includes: Inputting the training data into the initial encoder and the initial neural network, and obtaining a second initial feature vector set output by the feature vector layer in the initial encoder; Determining a second product category cluster center corresponding to each product category based on the second initial feature vector set; Updating the loss function of the initial encoder according to the feature vector output by the feature vector layer, the second product category cluster center corresponding to each product category, the preset space vector distance, and the product category probability output by the initial neural network; Training the initial neural network and the initial encoder after updating the loss function using the training data; When the preset conditions are met, a preset encoder and a preset classification model are obtained.

5. The method according to claim 3, wherein The determining whether the product to be inspected has an unknown abnormality according to the product category, the loss value, and the second space vector distance includes: When the product category is good, determining whether the loss value is greater than a preset loss threshold and / or whether the second space vector distance is greater than a preset distance threshold; If so, it is determined that the product to be tested has an unknown abnormality.

6. A product abnormality detection device, characterized in that: The device comprises: An input module, configured to input product data of a product to be detected into a preset classification model, and obtain the product category of the product to be detected output by the preset classification model; An acquisition module, configured to acquire a product feature matrix output by an input layer of the preset classification model according to the product data; a determination module, configured to determine an unknown abnormality index based on the product feature matrix, and determine whether the product to be tested has an unknown abnormality based on the unknown abnormality index and the product category; The determination module is further configured to, when the unknown abnormality indicator includes a first spatial vector distance, process the product feature matrix through a feature extraction network of the preset classification model and output the processed product feature matrix to a fully connected layer of the preset classification model; obtain a product feature vector output by the fully connected layer, and determine the first spatial vector distance based on the product feature vector and a first preset good product cluster center; and determine whether the product to be inspected has an unknown abnormality based on the first spatial vector distance and the product category; The determination module is further configured to, when the unknown abnormality indicator includes a loss value of a preset encoder, input the product feature matrix into the feature extraction network of the preset classification model and obtain the extracted feature vector output by the feature extraction network; input the extracted feature vector into the feature vector layer of the preset encoder and obtain the decoded feature vector output by the output layer of the preset encoder; determine the loss value of the preset encoder based on the extracted feature vector, the decoded feature vector and a preset loss coefficient; and determine whether the product to be inspected has an unknown abnormality based on the product category and the loss value.

7. A product anomaly detection device, characterized in that: The device includes: a memory, a processor, and a product anomaly detection program stored in the memory and executable on the processor, wherein the product anomaly detection program is configured to implement the steps of the product anomaly detection method according to any one of claims 1 to 5.

8. A storage medium, characterized in that: The storage medium stores a product anomaly detection program, which, when executed by a processor, implements the steps of the product anomaly detection method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Hierarchical network attack identification and unknown attack detection method based on deep learning

    CN110691100A