An image anomaly detection method based on edge world generation network

The feature expansion and distillation of the edge world generation network generates pseudo-exception features. Combined with the exception classifier of Weber transform, the problems of unknowns and feature information loss in image anomaly detection are solved, and anomaly detection and positioning are achieved with higher accuracy.

CN117274195BActive Publication Date: 2025-08-12ANHUI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311231918.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2025-08-12
Estimated Expiration
2043-09-22

AI Technical Summary

Technical Problem

The prior art is difficult to effectively deal with the unknown, diversity and rareness of abnormal situations in image anomaly detection, resulting in the imbalance of positive and negative samples of the model during training, making it difficult to generalize to untrained data sets, and the traditional model is inaccurate in recognition of subtle changes in image.

Method used

Using a method of generating networks based on edge worlds, an exception classifier is constructed through feature expanders, feature distillation generators and Weber transformations, a pseudo-exception feature vector is generated and the boundaries of normal samples are portrayed in high-dimensional feature spaces, and adversarial training is used to optimize network parameters to improve the accuracy of anomaly detection.

Benefits of technology

More accurately portraying the feature space boundaries of normal samples in high-dimensional feature spaces improves the accuracy of image anomaly detection and the generalization ability of the model, and solves the problems of unknown abnormal situations and loss of feature information in traditional models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117274195B_ABST
    Figure CN117274195B_ABST
Patent Text Reader

Abstract

The present invention discloses an image anomaly detection method based on an edge world generation network, which is used for unsupervised image anomaly detection and positioning, including: 1. using a feature expander to make the feature dimension space spanned by the feature vector sufficiently full and complete, 2. using a feature distillation generator to generate a pseudo-abnormal edge feature space at the boundary of the feature dimension space spanned by the feature vector of the normal sample, thereby generating a large number of pseudo-abnormal feature vectors in this edge feature dimension space. 3. inputting the normal feature vector and the pseudo-abnormal feature vector into an anomaly separator together, and obtaining an image pixel-level anomaly score through a Weber transform, thereby completing the detection of image anomalies and positioning of image abnormal areas. The present invention can better depict the feature space boundary of normal samples in a high-dimensional feature space when it is impossible to model the statistical distribution of all abnormal data, thereby improving image detection performance through an edge world generation network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image anomaly detection. The present invention proposes an edge world generation network that focuses on optimization in an edge feature space for unsupervised image anomaly detection and positioning. Background Art

[0002] Image anomaly detection algorithms are widely used in smart manufacturing, the Industrial Internet, medical image analysis, and other fields. However, the occurrence of image anomalies is highly uncertain, exhibiting unknown, diverse, and rare characteristics. This makes acquiring abnormal sample data extremely costly, and the data lacks stable statistical patterns. Since it is impossible to fully sample all possible anomalies, the number of positive and negative samples during training is extremely unbalanced, making it difficult for models trained using traditional supervised learning algorithms to effectively generalize to untrained datasets. In the field of image anomaly detection, there is a desire to find a reliable support point within this uncertain anomaly factor.

[0003] In generative adversarial training, the classification model can accurately distinguish the original image. However, subtle changes to the original image that appear unchanged to humans can be misclassified with high confidence by the classification model. While such subtle changes may not appear to make a significant difference in the visual image, the differences in the feature space after feature extraction by the model are very significant.

[0004] There are three main directions of research on image anomaly detection at home and abroad.

[0005] Based on the reconstruction model method, only normal data is usually included to train the encoder and decoder. During testing, the normal data can be accurately reconstructed through a set of basis functions, while the reconstruction error of the abnormal data is often significantly larger than the reconstruction error of the normal data. Therefore, the size of the reconstruction error can be used to determine whether the data is abnormal.

[0006] Based on the synthetic model method, pseudo anomalies are generated on non-anomaly images for training to estimate the decision boundary between normal and anomaly, thereby distinguishing normal data from abnormal data areas.

[0007] Based on the density model method, the probability distribution of normal data or features is first learned and modeled, and then the learned probability distribution is used to estimate the likelihood probability of the test data to determine anomalies during testing. Usually, the likelihood probability of normal data is high, and the likelihood probability of abnormal data is low. Summary of the Invention

[0008] In order to address the shortcomings of the above-mentioned prior art, the present invention proposes an image anomaly detection method based on an edge world generation network. In the field of image anomaly detection, when faced with the unknown nature of abnormal situations and the inability to perform statistical distribution modeling on all abnormal data, it is hoped that the feature space boundaries of normal samples can be more accurately portrayed in a high-dimensional feature space, thereby enabling efficient and accurate unsupervised image anomaly detection and positioning.

[0009] In order to achieve the above-mentioned object, the present invention adopts the following technical solutions:

[0010] The image anomaly detection method based on the edge world generation network of the present invention is characterized in that it is performed according to the following steps:

[0011] Step 1: Get the training image dataset A and construct a random space vector set Z:

[0012] Step 1.1, obtain a real normal image dataset, denoted as A = {a1, a2, ..., a i ,…,a N}, where a i represents the i-th normal image, i = 1, 2, ..., N, N is the total number of normal images;

[0013] Step 1.2: After random Gaussian sampling on the uniform distribution in the range [-1, 1], the random space vector set Z = {z1, z2, ..., z j ,…,z M}, z j represents the jth random space vector; M represents the total number of random space vectors;

[0014] Step 2: Construct a feature extraction network F and process the normal image dataset A to obtain the normal feature vector set ν true ;

[0015] Step 3: Construct the feature expansion network E and perform the normal feature vector set ν true Processing is performed to obtain the normal feature vector set ν true The expanded eigenvector set ν mapped on the eigenspace V E :

[0016] Step 4: Construct a feature distillation generation network G and process the random space vector set Z to obtain the random space vector set Z = {z1, z2, ..., z j ,…,z M}The pseudo-abnormal feature vector set ν mapped on the feature space V fake :

[0017] Step 5: Construct shared parameters through the edge feature discrimination network D1 and the anomaly classification network D2:

[0018] Step 5.1: Construct edge feature discrimination network D1 and use pseudo abnormal feature vector set ν fake As the input data of the edge feature discriminant network D1, the jth pseudo-abnormal feature vector ν is obtained fake,j On the edge feature discriminant network D1, the Kth D1 The j-th output d1(K D1 )(ν fake,j );

[0019] According to formula (4), the edge feature discriminant network D1 obtains the j-th pseudo-abnormal feature vector ν fake,j Anomaly score

[0020]

[0021] In formula (5), e is the base of the natural logarithm, r and λ are the hyperparameters in the Weibull transformation function;

[0022] Step 5.2: Construct anomaly classification network D2 and expand the feature vector set ν E and the pseudo-abnormal feature vector set ν fake Construct the set of positive and abnormal feature vectors I = {ν E ,ν fake}, and used as the input data of the abnormal classification network D2, thereby obtaining the kth feature vector In the Kth D2 The output of the hidden layer

[0023] According to formula (7), the abnormal classification network D2 is obtained for the kth feature vector Anomaly score

[0024]

[0025] Step 5.3, construct shared parameters:

[0026] The shared parameters of the hidden layers of the edge feature discrimination network D1 and the anomaly classification network D2 are constructed using equations (8) and (9);

[0027]

[0028]

[0029] Step 6: The feature extraction network F, feature expansion network E, feature distillation generation network G, edge feature discrimination network D1 and anomaly classification network D2 constitute an edge world generation network and perform adversarial training:

[0030] Step 6.1: Use formula (10) to establish the adversarial loss function l weibull :

[0031]

[0032] In formula (10), eps is a perturbation value, E represents expectation, a~p(A) represents a batch of normal image groups a taken from the distribution p(A) of the training image dataset A, z~p(Z) represents a batch of random space vector groups z taken from the distribution p(Z) of the random space vector set Z, G(z) represents the pseudo-abnormal feature vector generated by the feature distillation generation network G when the random space vector group z of the batch is taken from the distribution p(Z) of the random space vector set Z; D2(G(z)) represents the abnormal score of the pseudo-abnormal feature vector G(z) generated by the abnormal classification network D2 for the feature distillation generation network G. F(a) represents the normal feature vector extracted from the normal image group a of the batch from the distribution p(A) of the training image dataset A on the feature extraction network F; E(F(a)) represents the expanded feature vector obtained by mapping the normal feature vector F(a) on the feature expansion network E; D2(E(F(a))) represents the abnormality score of the expanded feature vector E(F(a)) on the feature expansion network E by the abnormal classification network D2; l() is the hinge loss function, and:

[0033]

[0034] In formula (11), when the input ξ is the abnormal score of the expanded feature vector, let the label +1, when the input ξ is the anomaly score of the pseudo-anomaly feature vector, then the label is -1;

[0035] Step 6.2: Use formula (12) to establish the expansion loss function l expand :

[0036]

[0037] In formula (12), a′ and a″ represent two groups of similar images obtained after performing different random transformations on the normal image group a;

[0038] log|Σ nm (;)| represents the constructed covariance matrix determinant loss function, and has:

[0039]

[0040] In formula (13), ν α , ν β Represents two inputs, Respectively represent ν α , ν β The mean of , T represents transpose;

[0041] Step 6.3: Establish the edge feature loss function l gan :

[0042] Step 6.3.1. Use formula (14) to establish the Weber edge feature vector ν weibull :

[0043] ν weibull =E a~p(A) [E(F(a))]+ω[N(ζ;μ,σ);r,λ] (14)

[0044] In formula (14), N(ζ; μ, σ) represents Gaussian distribution, ζ is the random input value of Gaussian distribution, μ, σ are the mean parameter and variance parameter of Gaussian distribution; ω represents the Weibull transformation function, and:

[0045]

[0046] In formula (15), θ represents the input of the Weibull transformation function;

[0047] Step 6.3.2: Use Equation (16) to establish the edge deviation loss function ω_rim(G(z)||ν weibull ):

[0048] ω_rim(G(z)||ν weibull )=Grad(G(z),ν weibull )+l1(G(z),ν weibull )+SSIM(G(z),ν weibull ) (16)

[0049] In formula (16), l1 represents the mean absolute error loss function and is obtained by formula (17); Grad represents the matrix gradient loss function and is obtained by formula (18); SSIM represents the structural similarity index loss function and is obtained by formula (19).

[0050]

[0051]

[0052] In formula (18), and Respectively represent ν weibull The difference between the first and second dimensions, ΔG(z) dim1 and ΔG(z) dim2 represent the difference of G(z) in the first and second dimensions respectively;

[0053]

[0054] In formula (19), μ G(z) , σ G(z) Respectively represent the mean and variance of G(z), μ weibull , σ weibull Respectively represent ν weibull The mean and variance, σ G(z)_weibull Denotes G(z) and ν weibull The covariance of , c1, c2 are constants;

[0055] Step 6.3.3: Use formula (20) to establish the edge feature loss function l gan :

[0056] l gan =E z~p(Z) max[0,1-D1(G(z))]+E z~p(Z) {ω_rim[G(z)||ν weibull ]} (20)

[0057] In formula (20), D1(G(z)) represents the anomaly score of the pseudo anomaly feature vector G(z) generated by the edge feature discriminant network D1 for the feature distillation generation network G;

[0058] Step 6.4: Use the stochastic gradient descent method to optimize and solve equations (20), (12), and (10) respectively, so that l gan value, l expand Value and l weibull The values converge to the optimal value in the mutual confrontation; when the edge feature loss function l is generated gan When the optimal value is reached, the feature distillation generation network G reaches the optimal value; when the expansion loss function l expand When the optimal value is reached, the feature expansion network E reaches the optimal value; when the adversarial loss function l weibull When it reaches the optimal state, the anomaly classification network D2 reaches the optimal state; and the trained edge world generation network is used to detect anomalies in the input image, output the pixel-level anomaly score map of the image, and complete the image anomaly detection and positioning.

[0059] The image anomaly detection method based on edge world generation network of the present invention is also characterized in that step 2 includes:

[0060] Step 2.1: Set the total number of hidden layers of the feature extraction network F to K F ; Let the current hidden layer be h F layer;

[0061] Step 2.2, randomly initialize h F =1;

[0062] Step 2.3: Calculate the normal image a in the normal image dataset A according to formula (1): i In the h F The output of the hidden layer Thus, all normal images in the normal image dataset A are obtained in the hth F The output of the hidden layer is:

[0063]

[0064] In formula (1), * represents matrix multiplication, BN() is the batch normalization layer; represents the hth F The transformation matrix of the hidden layer; represents the hth F The bias matrix of the hidden layer; when h F =1, let h F -1 hidden layer output

[0065] Step 2.4, h F +1 is assigned to h F , and judge h F >K F Is it established? If so, let Represents the i-th normal image a i The i-th normal feature vector extracted on the feature extraction network F is obtained, thereby obtaining the normal feature vector set ν of all normal images in the normal image dataset A extracted on the feature extraction network F true ; Otherwise, return to step 2.3.

[0066] The step 3 comprises:

[0067] Step 3.1: Set the total number of hidden layers of the feature expansion network E to K E ; Let the current hidden layer be h E layer;

[0068] Step 3.2, randomly initialize h E =1;

[0069] Step 3.3: Calculate the i-th normal eigenvector ν according to formula (2): true,i In the hE The output of the hidden layer Thus we get the normal eigenvector set ν true In the h E The output of the hidden layer is:

[0070]

[0071] In formula (2), represents the hth E The transformation matrix of the hidden layer; represents the hth E The bias matrix of the hidden layer; when h E =1, let h E -1 hidden layer output

[0072] Step 3.4, h E +1 is assigned to h E , and judge h E >K E Is it established? If so, let Represents the i-th normal feature vector ν extracted from the training image dataset A on the feature extraction network F true,i The expanded eigenvectors mapped on the eigenspace V are used to obtain the normal eigenvector set ν true The expanded eigenvector set ν mapped on the eigenspace V E ; Otherwise, return to step 3.3.

[0073] The step 4 comprises:

[0074] Step 4.1: Set the total number of hidden layers of the feature distillation generation network G to K G ; Let the current hidden layer be h G layer;

[0075] Step 4.2, randomly initialize h G =1;

[0076] Step 4.3: Calculate the jth random space vector z according to formula (3) j In the h G The output of the hidden layer Thus, all random space vectors on the random space vector set Z are obtained in the hth order. G The output of the hidden layer is:

[0077]

[0078] In formula (3), represents the hth feature distillation generation network G G The transformation matrix of the hidden layer; represents the hth feature distillation generation network G G The bias matrix of the hidden layer; when h G =1, let h G -1 hidden layer output

[0079] Step 4.4, h G +1 is assigned to h G , and judge h G >K G Is it established? If so, let represents the jth random space vector z j The jth pseudo-abnormal feature vector is generated on the feature distillation generation network G, thereby obtaining a pseudo-abnormal feature vector set ν generated by all random space vectors on the random space vector set Z on the feature distillation generation network G. fake ; Otherwise, return to step 4.3.

[0080] The step 5.1 includes:

[0081] Step 5.1.1, set the total number of hidden layers of the edge feature discrimination network D1 to K D1 ; Let the current hidden layer be h D1 layer;

[0082] Step 5.1.2, randomly initialize h D1 =1;

[0083] Step 5.1.3: Calculate the jth pseudo-anomaly feature vector ν according to formula (4): fake,j In the h D1 The output of the hidden layer Thus, the pseudo-abnormal feature vector set ν is obtained fake All pseudo-abnormal feature vectors in h D1 The output of the hidden layer is:

[0084]

[0085] In formula (4), Represents the hth edge feature discriminant network D1 D1 The transformation matrix of the hidden layer; Represents the hth edge feature discriminant network D1 D1 The bias matrix of the hidden layer; when h D1 =1, let h D1 -1 hidden layer output

[0086] Step 5.1.4, h D1 +1 is assigned to h D1 , and judge h D1 >K D1 Is it true? If so, it means that the jth pseudo-abnormal feature vector ν is obtained fake,j On the edge feature discriminant network D1, the Kth D1 The j-th output of the hidden layer Thus, the pseudo-abnormal feature vector set ν is obtained fake The Kth edge feature discriminant network D1 of all pseudo-abnormal feature vectors D1 The output of the hidden layer of the layer, otherwise, return to step 5.1.3.

[0087] The step 5.2 includes:

[0088] Step 5.2.1: Set the total number of hidden layers of the abnormal classification network D2 to K D2 ; Let the current hidden layer be h D2 layer;

[0089] Step 5.2.2, randomly initialize h D2 =1;

[0090] Step 5.2.3: Calculate any k-th feature vector in the set of positive and abnormal feature vectors I according to formula (7): In the h D2 The output of the hidden layer Thus, all the feature vectors in the normal and abnormal feature vector set I are obtained in the hth D2 The output of the hidden layer, k∈[1,N+M]:

[0091]

[0092] In formula (6), represents the hth D2 The transformation matrix of the hidden layer; represents the hth D2 The bias matrix of the hidden layer; when h D2 =1, let h D2 -1 hidden layer output

[0093] Step 5.2.4, h D2 +1 is assigned to h D2 , and judge h D2 >K D2 Is it true? If it is true, it means that the kth eigenvector is obtained In the Kth D2 The output of the hidden layer Thus, all the feature vectors in the positive and abnormal feature vector set I are obtained in the Kth order of the abnormal classification network D2. D2 The output of the hidden layer of the layer, otherwise, return to step 5.2.3.

[0094] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the image anomaly detection method, and the processor is configured to execute the program stored in the memory.

[0095] The present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program executes the steps of the image anomaly detection method when executed by a processor.

[0096] Compared with the prior art, the present invention has the following beneficial effects:

[0097] 1. The present invention uses the edge world generation network to better characterize the feature space boundaries of normal samples in high-dimensional feature space, thereby solving the difficulty of traditional models in the field of image anomaly detection in facing many unknowns of abnormal situations and being unable to perform statistical distribution modeling on all abnormal data. It realizes the ability to find certain support points among these uncertain abnormal factors.

[0098] 2. The present invention proposes the use of an anomaly classifier based on the Weber transform as a new measure conversion between the feature vector space dimensional information and the sample anomaly score, thereby solving the problem in the field of image anomaly detection that the anomaly score output by the model cannot reach the preset threshold range and the anomaly score of normal data is difficult to distinguish from the anomaly score of abnormal data, thereby achieving the distinction of image pixel-level anomaly scores with higher accuracy.

[0099] 3. The present invention, through the designed feature space expander module, can better make each pixel-level feature vector in the image data form a feature space with full dimensionality as much as possible, thereby solving the problem that the feature space formed by the feature vectors obtained in the feature extraction process of conventional models is prone to dimensional collapse, that is, the dimensional information of the feature vector is easily lost, which leads to incomplete feature information obtained by the model.

[0100] 4. The present invention, through the designed feature distillation generator module, generates a pseudo-anomaly edge feature space at the boundary of the feature dimension space spanned by the feature vectors of normal samples. In this edge feature dimension space, a large number of pseudo-anomaly feature vectors are generated. Finally, the feature vectors of normal samples and the pseudo-anomaly feature vectors generated by the feature distillation generator are input into the anomaly classifier together, which effectively improves the model's recognition performance for abnormal situations, thereby solving the problem that conventional models perform noise perturbations on visual images to enhance the model's generalization ability. The present invention performs effective noise perturbations on the feature space, which further improves the performance of the model.

[0101] 5. The feature space expander designed in this invention increases the richness of feature vector dimensional information; the feature distillation generator designed in this invention improves the effectiveness of generating pseudo-anomaly edge feature spaces at the boundaries of normal sample feature spaces; and the anomaly classifier designed in this invention uses the Weber transform to build a bridge between feature vector space dimensional information and sample anomaly scores, improving the discrimination of anomaly scores between positive and anomalous samples. This optimization method in high-dimensional edge feature spaces also provides a new perspective on feature vectors in the field of image anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0102] Figure 1 This is a flow chart of the image anomaly detection method based on the edge world generation network of the present invention;

[0103] Figure 2 Generate a network structure diagram of the network for the edge world of the present invention;

[0104] Figure 3 Schematic diagram of the edge feature space of the present invention;

[0105] Figure 4 Schematic diagram of the anomaly scores of all pixels in the image of the present invention;

[0106] Figure 5 、 Figure 6 、 Figure 7 Schematic diagrams showing visualization of image anomaly detection results on the VisA dataset, MVTec AD dataset, and Hyper Kvasir dataset, respectively;

[0107] Figure 8 Schematic diagram comparing the image-level detection average precision, pixel-level detection average precision, and PRO accuracy of the present invention and existing image anomaly detection methods on the VisA dataset;

[0108] Figure 9Schematic diagram comparing the image-level detection average precision, pixel-level detection average precision, and PRO precision of the present invention and the existing image anomaly detection method on the MVTecAD dataset. DETAILED DESCRIPTION

[0109] In this embodiment, based on the existing solutions and problems faced, the present invention provides an image anomaly detection method based on an edge world generation network, which first proposes three problem targets that need to be solved. First, break the boundary barrier of the anomaly score so that the anomaly score can reach the preset threshold range as much as possible. Second, compress the width of the transition zone of the anomaly score interval so that the area where the anomaly score is intertwined in the middle is as small as possible. Third, widen the distance between the anomaly scores of positive and negative samples so that the anomaly scores of abnormal data and normal data are as far apart as possible to be effectively distinguished.

[0110] This paper integrates several unique and intuitive solutions. For example, to better identify the classification boundary between cats and dogs, more tiger and wolf data samples, two very similar categories, can be introduced into the training set. This allows the model to more clearly characterize the feature space boundary of the cat category, thereby better distinguishing between cats and dogs. Three solutions are proposed to address the three aforementioned problems and objectives.

[0111] 1. Replace the distribution transformation of the measure function. Using the traditional exponential function to convert the spatial distance of pixel-level feature vectors into anomaly scores results in information loss, leading to the aforementioned issues. Therefore, this paper proposes using the Weber transform as a new measure transformation to alleviate these issues with higher performance.

[0112] Second, spanning a feature space with rich dimensions. In traditional generative adversarial models, simply perturbing visual images with noise to enhance the model's generalization is insufficient. To significantly improve model performance, this invention applies effective noise perturbation to the feature space. A feature space expander module is also designed to ensure that each pixel-level feature vector extracted by the model spans a feature space with rich dimensions, preserving feature information.

[0113] 3. Adaptively generate abnormal sample boundaries. Due to the unknown, diversity, and scarcity of abnormal situations, it is impossible to model the statistical distribution of all abnormal data. The present invention changes the perspective and shifts the focus of modeling from the unknown that cannot be exhaustively enumerated outside the sample to the modeling that can be determined within the sample. On the basis of solution two, since the dimension of the feature space of normal samples has been stretched as full as possible, the present invention uses a generative adversarial network to generate an edge pseudo-abnormal feature space at the boundary of the feature space, which is stretched by the pixel-level feature vectors extracted from the normal samples. In the edge feature space of the pseudo-abnormality, a large number of pseudo-abnormal feature vectors are generated, so as to find the feature vectors of normal samples as much as possible and the boundary of the feature space stretched. Finally, a more accurate normal boundary is depicted in the high-dimensional feature space, so that normal data and abnormal data can be distinguished with high precision.

[0114] Specifically, if Figure 1 As shown, the image anomaly detection method of the present invention includes the following steps:

[0115] Step 1: Get the training image dataset A and construct a random space vector set Z:

[0116] Step 1.1, obtain a real normal image dataset, denoted as A = {a1, a2, ..., a i ,…,a N}, where a i represents the i-th normal image, i = 1, 2, ..., N, where N is the total number of normal images. The real image datasets are public anomaly detection datasets, including the VisA dataset, the MVTecAD dataset, and the Hyper Kvasir dataset. In this embodiment, the pixel size of all images after normalization is 256 × 256.

[0117] Step 1.2: After random Gaussian sampling on the uniform distribution in the range [-1, 1], the random space vector set Z = {z1, z2, ..., z j ,…,z M}, z j represents the jth random space vector; M represents the total number of random space vectors;

[0118] Step 2: Construct the feature extraction network F and obtain the normal feature vector set ν true :

[0119] Step 2.1: Set the total number of hidden layers of the feature extraction network F to K F ; Let the current hidden layer be h F Layer; ResNet is generally used as the backbone network for feature extraction network F. Figure 2As shown, the ResNet in the network structure diagram of the edge world generation network.

[0120] Step 2.2, randomly initialize h F =1;

[0121] Step 2.3: Calculate the normal image a in the normal image dataset A according to formula (1): i In the h F The output of the hidden layer Thus, all normal images in the normal image dataset A are obtained in the hth F The output of the hidden layer is:

[0122]

[0123] In formula (1), * represents matrix multiplication, BN() is the batch normalization layer; represents the hth feature extraction network F F The transformation matrix of the hidden layer; represents the hth feature extraction network F F The bias matrix of the hidden layer; when h F =1, let h F -1 hidden layer output

[0124] Step 2.4, h F +1 is assigned to h F , and judge h F >K F Is it established? If so, let Represents the i-th normal image a i The i-th normal feature vector extracted on the feature extraction network F is obtained, thereby obtaining the normal feature vector set ν of all normal images in the normal image dataset A extracted on the feature extraction network F true ; Otherwise, return to step 2.3;

[0125] Step 3: Construct the feature expansion network E and obtain the normal feature vector set ν true The expanded eigenvector set ν mapped on the eigenspace V E :

[0126] Step 3.1: Set the total number of hidden layers of the feature expansion network E to K E ; Let the current hidden layer be h E layer; such as Figure 2 As shown, the feature expander in the network structure diagram of the edge world generation network.

[0127] Step 3.2, randomly initialize h E =1;

[0128] Step 3.3: Calculate the i-th normal eigenvector ν according to formula (2): true,i In the h E The output of the hidden layer Thus we get the normal eigenvector set ν true In the h E The output of the hidden layer is:

[0129]

[0130] In formula (2), represents the hth E The transformation matrix of the hidden layer; represents the hth E The bias matrix of the hidden layer; when h E =1, let h E -1 hidden layer output

[0131] Step 3.4, h E +1 is assigned to h E , and judge h E >K E Is it established? If so, let Represents the i-th normal feature vector ν extracted from the training image dataset A on the feature extraction network F true,i The expanded eigenvectors mapped on the eigenspace V are used to obtain the normal eigenvector set ν true The expanded eigenvector set ν mapped on the eigenspace V E ; Otherwise, return to step 3.3;

[0132] Step 4: Construct a feature distillation generation network G and obtain a random space vector set Z = {z1,z2,…,z j ,…,z M}The pseudo-abnormal feature vector set ν mapped on the feature space V fake :

[0133] Step 4.1: Set the total number of hidden layers of the feature distillation generation network G to K G ; Let the current hidden layer be h G layer; such as Figure 2 As shown, the feature distillation generator in the network structure diagram of the edge world generation network.

[0134] Step 4.2, randomly initialize h G =1;

[0135] Step 4.3: Calculate the jth random space vector z according to formula (3)j In the h G The output of the hidden layer Thus, all random space vectors on the random space vector set Z are obtained in the hth order. G The output of the hidden layer is:

[0136]

[0137] In formula (3), represents the hth feature distillation generation network G G The transformation matrix of the hidden layer; represents the hth feature distillation generation network G G The bias matrix of the hidden layer; when h G =1, let h G -1 hidden layer output

[0138] Step 4.4, h G +1 is assigned to h G , and judge h G >K G Is it established? If so, let represents the jth random space vector z j The jth pseudo-abnormal feature vector is generated on the feature distillation generation network G, thereby obtaining the pseudo-abnormal feature vector set ν generated by all random space vectors on the random space vector set Z on the feature distillation generation network G fake The feature space position of the generated pseudo-abnormal feature vector set is at the edge of the feature space of the normal data sample. Figure 3 As shown in the figure, the edge feature space diagram is shown in the figure. The center is the normal feature space diagram, and the surrounding is the edge feature space diagram. Otherwise, return to step 4.3;

[0139] Step 5: Construct shared parameters through the edge feature discrimination network D1 and the anomaly classification network D2:

[0140] Step 5.1, construct edge feature discrimination network D1:

[0141] Step 5.1.1: Take the pseudo-abnormal feature vector set ν fake As input data of edge feature discriminant network D1;

[0142] Step 5.1.2: Set the total number of hidden layers of the edge feature discrimination network D1 to K D1 ; Let the current hidden layer be h D1 layer; such as Figure 2 As shown, the edge feature discriminator in the network structure diagram of the edge world generation network.

[0143] Step 5.1.3, randomly initialize h D1 =1;

[0144] Step 5.1.4: Calculate the jth pseudo-anomaly feature vector ν according to formula (4): fake,j In the h D1 The output of the hidden layer Thus we get the pseudo-abnormal feature vector set ν fake All pseudo-abnormal feature vectors in h D1 The output of the hidden layer is:

[0145]

[0146] In formula (4), Represents the hth edge feature discriminant network D1 D1 The transformation matrix of the hidden layer; Represents the hth edge feature discriminant network D1 D1 The bias matrix of the hidden layer; when h D1 =1, let h D1 -1 hidden layer output

[0147] Step 5.1.5, h D1 +1 is assigned to h D1 , and judge h D1 >K D1 Is it true? If so, it means the jth pseudo-abnormal feature vector ν is obtained fake,j On the edge feature discriminant network D1, the Kth D1 The j-th output d1(K D1 )(ν fake,j ), thus obtaining the pseudo-abnormal feature vector set ν fake All pseudo-abnormal feature vectors in the edge feature discrimination network D1 on the Kth D1 The output of the hidden layer of the layer and execute step 5.1.6, otherwise, return to step 5.1.4;

[0148] Step 5.1.6: According to formula (4), the edge feature discriminant network D1 is obtained for the j-th pseudo-abnormal feature vector ν fake,j Anomaly score

[0149]

[0150] In formula (5), e is the base of the natural logarithm, r and λ are the hyperparameters in the Weibull transformation function;

[0151] Step 5.2: Construct anomaly classification network D2:

[0152] Step 5.2.1: Expand the feature vector set ν E and the set of pseudo-anomalous feature vectors ν fake Construct the set of positive and abnormal feature vectors I = {ν E ,ν fake}, and used as input data for the anomaly classification network D2;

[0153] Step 5.2.2: Set the total number of hidden layers of the anomaly classification network D2 to K D2 ; Let the current hidden layer be h D2 layer; such as Figure 2 As shown, the anomaly classifier in the network structure diagram of the edge world generation network.

[0154] Step 5.2.3, randomly initialize h D2 =1;

[0155] Step 5.2.4: Calculate any k-th eigenvector in the set of positive and abnormal eigenvectors I according to formula (7): In the h D2 The output of the hidden layer Thus, all the eigenvectors in the normal and abnormal eigenvector set I are obtained in the hth D2 The output of the hidden layer, k∈[1,N+M]:

[0156]

[0157] In formula (6), represents the hth D2 The transformation matrix of the hidden layer; represents the hth D2 The bias matrix of the hidden layer; when h D2 =1, let h D2 -1 hidden layer output

[0158] Step 5.2.5, h D2 +1 is assigned to h D2 , and judge h D2 >K D2 Is it true? If so, it means the kth eigenvector obtained In the Kth D2 The output of the hidden layer Thus, all the feature vectors in the positive and abnormal feature vector set I are obtained in the Kth order of the abnormal classification network D2. D2 The output of the hidden layer of the layer and execute step 5.2.6, otherwise, return to step 5.2.4;

[0159] Step 5.2.6: According to formula (7), the abnormal classification network D2 is obtained for the kth feature vector Anomaly score

[0160]

[0161] Step 5.3, construct shared parameters:

[0162] Use equations (8) and (9) to construct the shared parameters of the hidden layers of the edge feature discrimination network D1 and the anomaly classification network D2;

[0163]

[0164]

[0165] Step 6: The edge world generation network is constructed by the feature extraction network F, the feature expansion network E, the feature distillation generation network G, the edge feature discrimination network D1 and the anomaly classification network D2, and adversarial training is performed:

[0166] Step 6.1: Use formula (10) to establish the adversarial loss function l weibull :

[0167]

[0168] In formula (10), eps is a perturbation value, E represents the expectation, a~p(A) represents a batch of normal image groups a taken from the distribution p(A) of the training image dataset A, where a={a1,…,abs}, bs is the total number of normal images in the batch, bs≤N; z~p(Z) represents a batch of random space vector groups z taken from the distribution p(Z) of the random space vector set Z, where z={z1,…,zbs}, bs≤M; G(z) represents the pseudo-abnormal feature vector generated by the feature distillation generation network G when the random space vector group z of the batch is taken from the distribution p(Z) of the random space vector set Z; D2(G(z)) represents the abnormal score of the pseudo-abnormal feature vector G(z) generated by the feature distillation generation network G for the abnormal classification network D2. F(a) represents the normal feature vector extracted from the normal image group a of the batch from the distribution p(A) of the training image dataset A on the feature extraction network F; E(F(a)) represents the expanded feature vector obtained by mapping the normal feature vector F(a) on the feature expansion network E; D2(E(F(a))) represents the abnormal score of the expanded feature vector E(F(a)) on the feature expansion network E by the abnormal classification network D2; l() is the hinge loss function, and:

[0169]

[0170] In formula (11), when the input ξ is the abnormal score of the expanded feature vector, let the label +1, when the input ξ is the anomaly score of the pseudo-anomaly feature vector, then the label = -1; that is, the anomaly score of normal sample data will converge to the value 1, and the anomaly score of abnormal sample data will converge to the value -1, so that the anomaly scores of positive and abnormal data will gather at the two vertices of the Weibull distribution, thus achieving efficient differentiation.

[0171] Step 6.2: Use formula (12) to establish the expansion loss function l expand :

[0172]

[0173] In formula (12), a′ and a″ represent two groups of similar images obtained after performing different random transformations on the normal image group a;

[0174] log|Σ nm (;)| represents the constructed covariance matrix determinant loss function, and has:

[0175]

[0176] In formula (13), ν α , ν β Represents two inputs, Respectively represent ν α , ν β The mean of , T represents transpose;

[0177] Among them, for the feature vector set ν τ The specific process of constructing the covariance matrix is:

[0178]

[0179] In formula (14), express The mean of .

[0180] Step 6.3: Establish the edge feature loss function l gan :

[0181] Step 6.3.1. Use formula (15) to establish the Weber edge feature vector ν weibull :

[0182] ν weibull =E a~p(A) [E(F(a))]+ω[N(ζ;μ,σ);r,λ] (15)

[0183] In formula (15), N(ζ; μ, σ) represents Gaussian distribution, ζ is the random input value of Gaussian distribution, μ, σ are the mean parameter and variance parameter of Gaussian distribution; the specific expression is as follows:

[0184]

[0185] ω() represents the Weibull transformation function, and has:

[0186]

[0187] In formula (17), θ represents the input of the Weibull transformation function;

[0188] Step 6.3.2: Use Equation (16) to establish the edge deviation loss function ω_rim(G(z)||ν weibull ):

[0189] ω_rim(G(z)||ν weibull )=Grad(G(z),ν weibull )+l1(G(z),ν weibull )+SSIM(G(z),ν weibull ) (18)

[0190] In formula (18), l1() represents the mean absolute error loss function and is obtained by formula (19); Grad() represents the matrix gradient loss function and is obtained by formula (20); SSIM() represents the structural similarity index loss function and is obtained by formula (21).

[0191]

[0192]

[0193] In formula (20), and Respectively represent ν weibull The difference between the first and second dimensions, ΔG(z) dim1 and ΔG(z) dim2 represent the differences of G(z) in the first and second dimensions respectively.

[0194]

[0195] In formula (21), μ G(z) , σ G(z) Respectively represent the mean and variance of G(z), μ weibull , σ weibull Respectively represent ν weibull The mean and variance, σ G(z)_weibull Denotes G(z) and ν weibullThe covariance of , c1, c2 are constants;

[0196] Step 6.3.3: Use formula (22) to establish the edge feature loss function l gan :

[0197] l gan =E z~p(Z) max[0,1-D1(G(z))]+E z~p(Z) {ω_rim[G(z)||ν weibull ]} (twenty two)

[0198] In formula (22), D1(G(z)) represents the abnormal score of the pseudo abnormal feature vector G(z) generated by the feature distillation generation network G for the edge feature discriminant network D1;

[0199] Step 6.4: Use the stochastic gradient descent method to optimize and solve equations (22), (12), and (10) respectively, so that l gan value, l expand Value and l weibull The values converge to the optimal value in the mutual confrontation. When the edge feature loss function l is generated gan When the optimal value is reached, the feature distillation generation network G reaches the optimal value and generates more data in the edge feature space; when the expansion loss function l expand When the optimal value is reached, the feature expansion network E reaches the optimal value. The fuller the dimension of the normal feature vector extracted on the feature extraction network F, the less the dimension information is lost. When the adversarial loss function l weibull When the optimal value is reached, the anomaly classification network D2 reaches the optimal value; and the trained edge world generation network is used to detect anomalies in the input image and output the pixel-level anomaly score map of the image. The maximum value in the pixel-level anomaly score map is selected as the image-level anomaly score to determine whether the image is an abnormal image. And the area in the pixel-level anomaly score map where the anomaly score is greater than the threshold is regarded as the abnormal area of the image. Finally, the image anomaly detection and positioning is completed. Figure 4 As shown in , the schematic diagram of the abnormal scores of all pixels in the image. Figure 5 、 Figure 6 、 Figure 7 , which are schematic diagrams of the visualization of image anomaly detection results on the VisA dataset, MVTecAD dataset, and HyperKvasir dataset, respectively.

[0200] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.

[0201] In this embodiment, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are executed.

[0202] Finally, the image anomaly detection method based on edge world generation network provided by the present invention has the following experimental results on the Visa dataset: Figure 8 As shown in Figure 1, the average image-level detection accuracy, pixel-level detection average accuracy, and PRO accuracy of the 12 categories are all higher than the current optimal algorithm. The image-level average AUROC value reaches 97.86%, the pixel-level average AUROC value reaches 98.75%, and the PRO value reaches 94.26%. The experimental results on the MVTec dataset are shown in Figure 1. Figure 9 As shown in the figure, the average accuracy of image-level detection for 15 categories is higher than that of existing methods, and the average accuracy and PRO accuracy of pixel-level detection are close to the current optimal algorithm. The average AUROC value at the image level reaches 99.79%, the average AUROC value at the pixel level reaches 97.81%, and the PRO value reaches 91.34%.

[0203] In summary, the present invention proposes a method that focuses on various optimizations within the feature space - the edge world generation network, for unsupervised image anomaly detection and localization. The edge world generation network is composed of a feature extractor, a feature space expander, a feature distillation generator, an edge feature discriminator, and anomaly classifier. These modules all have their own innovative highlights and inspirations. The feature space expander reflects the importance of feature vector dimensional information. The feature distillation generator realizes the effectiveness of generating pseudo-anomaly edge feature space at the boundary of the normal sample feature space. The anomaly classifier uses the Weber transform to build a bridge for the conversion between feature vector space dimensional information and sample anomaly scores. These various optimizations that are full of charm in high-dimensional edge feature space also provide a new perspective on thinking about feature vectors in the field of image anomaly detection. At the same time, the edge world generation network also achieves the current highest algorithm performance on the MVtec dataset and Visa dataset.

Claims

1. A method for image anomaly detection based on edge world generation network, characterized in that Follow these steps: Step 1: Get the training image dataset A and construct a random space vector set Z: Step 1.1, obtain a real normal image dataset, denoted as A={a1,a2,…,a i ,…,a N }, where a i represents the i-th normal image, i=1,2,…,N, N is the total number of normal images; Step 1.2: After random Gaussian sampling on the uniform distribution in the range [-1,1], the random space vector set Z={z1,z2,…,z j ,…,z M }, z j represents the jth random space vector; M represents the total number of random space vectors; Step 2: Construct a feature extraction network F and process the normal image dataset A to obtain a normal feature vector set. ; Step 3: Construct the feature expansion network E and perform the normal feature vector set Processing is performed to obtain a normal feature vector set The set of expanded eigenvectors mapped on the eigenspace V : Step 4: Construct a feature distillation generation network G and process the random space vector set Z to obtain the random space vector set Z={z1,z2,…,z j ,…,z M }The set of pseudo-abnormal feature vectors mapped on the feature space V : Step 5: Construct shared parameters through the edge feature discrimination network D1 and the anomaly classification network D2: Step 5.1: Construct edge feature discrimination network D1 and use pseudo abnormal feature vector set As the input data of the edge feature discriminant network D1, the jth pseudo-abnormal feature vector is obtained. On the edge feature discriminant network D1, the Kth D1 The j-th output of the hidden layer ; According to formula (5), the edge feature discriminant network D1 obtains the j-th pseudo-abnormal feature vector Anomaly score ( ): ( )= (5) In formula (5), is the base of natural logarithms, 、 is the hyperparameter in the Weibull transformation function; Step 5.2: Construct anomaly classification network D2 and expand the feature vector set and the pseudo-anomaly feature vector set Construct the set of positive and abnormal feature vectors I={ , }, and used as the input data of the abnormal classification network D2, thereby obtaining the kth feature vector In the Kth D2 The output of the hidden layer ; According to formula (7), the abnormal classification network D2 is obtained for the kth feature vector Anomaly score ( ): ( )= (7) Step 5.3, construct shared parameters: The shared parameters of the hidden layers of the edge feature discrimination network D1 and the anomaly classification network D2 are constructed using equations (8) and (9); = (8) = (9) In formula (8) and formula (9), Represents the hth edge feature discriminant network D1 D1 The transformation matrix of the hidden layer; Represents the hth edge feature discriminant network D1 D1 The bias matrix of the hidden layer; represents the hth D2 The transformation matrix of the hidden layer; represents the hth D2 The bias matrix of the hidden layer; Step 6: The feature extraction network F, feature expansion network E, feature distillation generation network G, edge feature discrimination network D1 and anomaly classification network D2 constitute an edge world generation network and perform adversarial training: Step 6.1: Use formula (10) to establish the adversarial loss function : (10) In formula (10), is a disturbance value, E represents the expectation, Represents the distribution of the training image dataset A Take out a batch of normal image groups , Denotes the distribution of a random space vector set Z Take out a batch of random space vector groups , Denotes the distribution of a random space vector set Z Take out the random space vector group of this batch The pseudo abnormal feature vector generated by the feature distillation generation network G; Represents the pseudo abnormal feature vector generated by the abnormal classification network D2 to the feature distillation generation network G Anomaly score of ; Represents the distribution of the training image dataset A Take out the normal image group of this batch A normal feature vector extracted on the feature extraction network F; represents the normal eigenvector Mapping the obtained expanded feature vector on the feature expansion network E; Represents the expanded feature vector of the feature expansion network E by the abnormal classification network D2 The anomaly score of belonging; () is the hinge loss function, and: (11) In formula (11), when the input When is the abnormal score of the expanded feature vector, let the label +1, when input When is the anomaly score of the pseudo-anomaly feature vector, the label is -1; Step 6.2: Use formula (12) to establish the expansion loss function : (12) In formula (12), and Indicates the normal image group After performing different random transformations, two sets of similar images are obtained; Represents the constructed covariance matrix determinant loss function, and has: (13) In formula (13), , Represents two inputs, 、 Respectively , The mean of , T represents transpose; Step 6.3: Establishing the edge feature loss function : Step 6.3.

1. Use formula (14) to establish the Weber edge feature vector : (14) In formula (14), represents a Gaussian distribution, is a random input value from a Gaussian distribution, are the mean parameter and variance parameter of the Gaussian distribution; represents the Weibull transformation function, and we have: (15) In formula (15), represents the input of the Weibull transformation function; Step 6.3.2: Use Equation (16) to establish the edge deviation loss function : (16) In formula (16), represents the mean absolute error loss function and is obtained by formula (17); represents the matrix gradient loss function, and is obtained from Equation (18), represents the structural similarity index loss function, and is obtained from formula (19), (17) (18) In formula (18), and Respectively The difference in the first and second dimensions, and Respectively Difference in the first dimension and the second dimension; (19) In formula (19), 、 Respectively The mean and variance of 、 Respectively The mean and variance of express and The covariance of 、 is a constant; Step 6.3.3: Use formula (20) to establish the edge feature loss function : (20) In formula (20), Represents the pseudo abnormal feature vector generated by the edge feature discrimination network D1 to the feature distillation generation network G The anomaly score of belonging; Step 6.4: Optimize and solve Equation (20), Equation (12), and Equation (10) respectively by using the stochastic gradient descent method, so that value, Value and The values converge to the optimal value in the mutual confrontation; when the edge feature loss function is generated When the optimal value is reached, the feature distillation generation network G reaches the optimal value; when the expansion loss function When the optimal value is reached, the feature expansion network E reaches the optimal value; when the adversarial loss function When it reaches the optimal state, the anomaly classification network D2 reaches the optimal state; and the trained edge world generation network is used to detect anomalies in the input image, output the pixel-level anomaly score map of the image, and complete the image anomaly detection and positioning.

2. The image anomaly detection method based on edge world generation network according to claim 1 is characterized in that The step 2 includes: Step 2.1: Set the total number of hidden layers of the feature extraction network F to K F ; Let the current hidden layer be h F layer; Step 2.2, randomly initialize h F =1; Step 2.3: Calculate the normal image a in the normal image dataset A according to formula (1): i In the h F The output f of the hidden layer (h F ) (a i ), so that all normal images in the normal image dataset A are obtained at the hth F The output of the hidden layer is: f (h F ) (a i ) = BN(W f (h F ) * (a i ) + b f (h F ) ) (1) In formula (1), * represents matrix multiplication, BN( ) is the batch normalization layer; W f (h F ) represents the hth F The transformation matrix of the hidden layer; b f (h F ) represents the hth F The bias matrix of the hidden layer; when h F =1, let h F -1 hidden layer output (a i )=a i ; Step 2.4, h F +1 is assigned to h F , and judge h F >K F Is it established? If so, let = f (h F ) (a i ) represents the i-th normal image a i The i-th normal feature vector extracted on the feature extraction network F is used to obtain the normal feature vector set of all normal images in the normal image dataset A extracted on the feature extraction network F. ; Otherwise, return to step 2.

3.

3. The image anomaly detection method based on edge world generation network according to claim 2 is characterized in that: The step 3 comprises: Step 3.1: Set the total number of hidden layers of the feature expansion network E to K E ; Let the current hidden layer be h E layer; Step 3.2, randomly initialize h E =1; Step 3.3: Calculate the i-th normal eigenvector according to formula (2): In the h E The output of the hidden layer is e (h E ) ( ), thus obtaining a normal feature vector set In the h E The output of the hidden layer is: have been (h E ) ( ) = BN(W e (h E ) * ( ) + b e (h E ) ) (2) In formula (2), W e (h E ) represents the hth E The transformation matrix of the hidden layer; b e (h E ) represents the hth E The bias matrix of the hidden layer; when h E =1, let h E -1 hidden layer output ( )= ; Step 3.4, h E +1 is assigned to h E , and judge h E >K E Is it established? If so, let = e (h E ) ( ) represents the i-th normal feature vector extracted from the training image dataset A on the feature extraction network F The expanded eigenvectors mapped on the eigenspace V are used to obtain the normal eigenvector set The set of expanded eigenvectors mapped on the eigenspace V ; Otherwise, return to step 3.

3.

4. The image anomaly detection method based on edge world generation network according to claim 3 is characterized in that The step 4 comprises: Step 4.1: Set the total number of hidden layers of the feature distillation generation network G to K G ; Let the current hidden layer be h G layer; Step 4.2, randomly initialize h G =1; Step 4.3: Calculate the jth random space vector z according to formula (3) j In the h G The output g of the hidden layer (h G ) (z j ), thus obtaining all random space vectors on the random space vector set Z at the hth G The output of the hidden layer is: g (h G ) (z j ) = BN(W g (h G ) * (z j ) + b g (h G ) ) (3) In formula (3), W g (h G ) represents the hth feature distillation generation network G G The transformation matrix of the hidden layer; b g (h G ) represents the hth feature distillation generation network G G The bias matrix of the hidden layer; when h G =1, let h G -1 hidden layer output (z j )=z j ; Step 4.4, h G +1 is assigned to h G , and judge h G >K G Is it established? If so, let = g (h G ) (z j ) represents the jth random space vector z j The jth pseudo-abnormal feature vector is generated on the feature distillation generation network G, thereby obtaining a pseudo-abnormal feature vector set generated by all random space vectors on the random space vector set Z on the feature distillation generation network G. ; Otherwise, return to step 4.

3.

5. The image anomaly detection method based on edge world generation network according to claim 4 is characterized in that: The step 5.1 includes: Step 5.1.1, set the total number of hidden layers of the edge feature discrimination network D1 to K D1 ; Let the current hidden layer be h D1 layer; Step 5.1.2, randomly initialize h D1 =1; Step 5.1.3: Calculate the jth pseudo-anomaly feature vector according to formula (4): In the h D1 The output d1 of the hidden layer (h D1 ) ( ), thereby obtaining the pseudo-abnormal feature vector set All pseudo-abnormal feature vectors in h D1 The output of the hidden layer is: d1 (h D1 ) ( ) = W d1 (h D1 ) * ( )+ b d1 (h D1 ) (4) In formula (4), W d1 (h D1 ) Represents the hth edge feature discriminant network D1 D1 The transformation matrix of the hidden layer; b d1 (h D1 ) Represents the hth edge feature discriminant network D1 D1 The bias matrix of the hidden layer; when h D1 =1, let h D1 -1 hidden layer output ( )= ; Step 5.1.4, h D1 +1 is assigned to h D1 , and judge h D1 >K D1 Is it true? If it is true, it means that the jth pseudo-abnormal feature vector is obtained On the edge feature discriminant network D1, the Kth D1 The j-th output d1 of the hidden layer ( K D1 ) ( ), thereby obtaining the pseudo-abnormal feature vector set The Kth edge feature discriminant network D1 of all pseudo-abnormal feature vectors D1 The output of the hidden layer of the layer, otherwise, return to step 5.1.

3.

6. The image anomaly detection method based on edge world generation network according to claim 5 is characterized in that: The step 5.2 includes: Step 5.2.1: Set the total number of hidden layers of the abnormal classification network D2 to K D2 ; Let the current hidden layer be h D2 layer; Step 5.2.2, randomly initialize h D2 =1; Step 5.2.3: Calculate any k-th feature vector in the set of positive and abnormal feature vectors I according to formula (6): In the h D2 The output d2 of the hidden layer (h D2 ) ( ), so as to obtain all the feature vectors in the normal and abnormal feature vector set I at the hth D2 The output of the hidden layer, k∈[1,N+M]: d2 (h D2 ) ( ) = W d2 (h D2 ) * ( ) + b d2 (h D2 ) (6) In formula (6), W d2 (h D2 ) represents the hth D2 The transformation matrix of the hidden layer; b d2 (h D2 ) represents the hth D2 The bias matrix of the hidden layer; when h D2 =1, let h D2 -1 hidden layer output ( ) = ; Step 5.2.4, h D2 +1 is assigned to h D2 , and judge h D2 > K D2 Is it true? If it is true, it means that the kth eigenvector is obtained In the Kth D2 The output d2 of the hidden layer ( K D2 ) ( ); thereby obtaining the Kth ... D2 The output of the hidden layer of the layer, otherwise, return to step 5.2.

3.

7. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the image anomaly detection method according to any one of claims 1 to 6, and the processor is configured to execute the program stored in the memory.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image anomaly detection method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • RGB-D image semantic segmentation method for guiding edge information distillation through gate mechanism and terminal

    CN112634296A

  • Mine image super-resolution reconstruction method combined with semantic information

    CN115239564A