An image anomaly detection method for industrial product quality control

Through the dual feature encoding mechanism and adversarial training method, the accuracy problem of image anomaly detection in the existing technology is solved, and efficient anomaly detection effect is achieved.

CN118334468BActive Publication Date: 2025-09-30FUJIAN NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410463149.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-17
Publication Date
2025-09-30
Estimated Expiration
2044-04-17

AI Technical Summary

Technical Problem

Existing image anomaly detection technologies have difficulty in accurately distinguishing normal and abnormal samples, especially reconstruction-based methods, which lead to large detection errors.

Method used

A dual feature encoding mechanism is adopted to extract overall features through the preliminary feature encoder and select local key features using the deep feature encoder. Combined with adversarial training, the quality of reconstructed images is improved, and a loss function is constructed to minimize the reconstruction error and determine abnormal results.

Benefits of technology

The accuracy of anomaly detection is improved, which can effectively prevent abnormal data from being accurately reconstructed and improve the accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334468B_ABST
    Figure CN118334468B_ABST
Patent Text Reader

Abstract

The present invention discloses an image anomaly detection method for industrial product quality control, comprising: step 1, standardizing an input industrial product image to adapt to the subsequent feature extraction and reconstruction process; step 2, mapping the normalized original input image into a potential feature map; step 3, converting the potential feature map into a mask vector, using the mask vector to select local key features in the potential feature map, and using a deep feature encoder to perform secondary selection on the local key features to extract representative local key features; step 4, reconstructing the image using the local key features, and using adversarial training to improve the quality of the reconstructed image; step 5, obtaining an anomaly score based on the difference between the original input image and the reconstructed image, and determining an abnormal result based on the anomaly score. The present invention avoids the problem of inability to effectively distinguish abnormal data due to the inaccurate reconstruction of abnormal data, thereby improving the accuracy of 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 image anomaly detection, and in particular to an image anomaly detection method for industrial product quality control. Background Art

[0002] Ensuring product quality is crucial in industrial production. Traditional quality control methods rely on manual inspection, which is not only time-consuming and labor-intensive, but also difficult to maintain consistent and accurate detection. With the development of computer vision technology, image anomaly detection has become a key tool for automated quality control. However, existing image anomaly detection techniques often struggle to accurately distinguish between normal and abnormal samples, especially those based on reconstruction. Therefore, a more efficient reconstruction-based image anomaly detection method is needed. Summary of the Invention

[0003] The present invention aims to provide an image anomaly detection method for industrial product quality control. This method utilizes a dual feature encoding mechanism to extract both global information and deep features, and selects local key features using a generated mask. Image reconstruction is then performed based on these key features, avoiding the problem of accurately reconstructing abnormal data. Furthermore, the integration of adversarial training improves the quality of the reconstructed image, effectively enhancing the accuracy of anomaly retrieval.

[0004] The technical solution adopted in the present invention is:

[0005] An image anomaly detection method for industrial product quality control includes the following steps:

[0006] Step 1: Standardize the input industrial product image to adapt to the subsequent feature extraction and reconstruction process;

[0007] Step 2: Map the normalized original input image into a potential feature map;

[0008] Step 3: Convert the latent feature map into a mask vector, use the mask vector to select local key features in the latent feature map, and use the deep feature encoder to perform secondary selection on the local key features to extract representative local key features;

[0009] Step 4: Reconstruct the image using local key features and use adversarial training to improve the quality of the reconstructed image;

[0010] Step 5: Obtain an anomaly score based on the difference between the original input image and the reconstructed image, and determine the abnormal result based on the anomaly score.

[0011] Furthermore, the standardization process includes resizing and normalizing the industrial product images.

[0012] Furthermore, the method further includes: Step 3 uses the Gumbel-Softmax method to perform binary calculation to handle discrete selection problems.

[0013] Furthermore, in step 3, a dual encoding mechanism is used to deeply select local key features. The specific steps are as follows:

[0014] Step 3-1, extract the feature map z of the original input image through the encoder pf ;

[0015] Step 3-2, the feature map z of the original input image pf Mapped to mask vector z mg ∈(0,1);

[0016] Step 3-3, the mask vector z mg With feature map z pf Perform weighting to obtain the activated feature map;

[0017] Step 3-4, use the encoder to further extract the activated feature map into deep features z df , and then use the depth feature z df With the mask vector z mg Perform weighting to obtain the local key feature z.

[0018] Furthermore, in step 4, a reconstruction decoder is used to reconstruct the image according to the selected local key features, and based on the idea of ​​adversarial training, a discriminator is used to evaluate the quality of the reconstructed image to improve the quality of the reconstructed image.

[0019] Furthermore, in step 4, the loss function is constructed with the goal of minimizing the reconstruction error. The specific steps are as follows:

[0020] Step 4-1, construct the adversarial loss function L adv , adversarial loss function L adv , L adv The calculation expression is as follows:

[0021]

[0022] Where D r Denotes the reconstruction decoder, D qe represents the quality enhancement discriminator, represents the expected value of a random variable x, where x is a sample drawn from the probability distribution p(x), and D qe (x) represents the result of identifying the random variable x, D r (E(x)) represents the mapping from sample space to sample space, D qe (D r(E(x))) represents the result of identifying the reconstructed sample;

[0023] Step 4-2, construct the reconstruction loss function L local , reconstruction loss function L local The calculation expression is as follows:

[0024]

[0025] in, Represents the probability distribution p of z under given conditions x mg,df (z|x) performs expected value calculation, z represents the key feature, p mg,df Indicates encoder F mg and E df The probability distribution of p(x|z) represents the probability distribution of data point x given feature z; KL divergence is used to measure the probability distribution of two probability distributions p mg,df , p θ the differences between;

[0026] Step 4-3, the formula for constructing the loss function L is expressed as:

[0027] L=λL adv +(1-λ)L local

[0028] Among them, L adv Denotes the adversarial loss function, L local represents the reconstruction loss function.

[0029] Furthermore, in step 5, the anomaly score is calculated based on the reconstruction error. When the anomaly score of the test sample is lower than the set score, it indicates that the test sample belongs to the normal range. The calculation formula of the anomaly score can be expressed as:

[0030]

[0031] Among them, x test For the test sample, D r (E(x test )) represents the reconstructed sample.

[0032] Furthermore, the score is set to 0.5.

[0033] The present invention adopts the above technical solution. Compared with the existing technology, the present invention has the following characteristics and beneficial effects: In the existing reconstruction-based image anomaly detection algorithm, abnormal data is often accurately reconstructed, resulting in large detection errors. The present invention uses a dual encoding mechanism to learn local key features. The preliminary feature encoder is responsible for extracting the overall features of the input image, including basic information such as edges and textures. The deep feature encoder further processes these features and focuses on extracting key local features that affect product quality. This method can not only capture the global information of the image, but also deeply explore local key features. The reconstruction based on key features effectively avoids the problem of accurate reconstruction of abnormal data and improves the accuracy of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments;

[0035] Figure 1 This is a schematic diagram of the network structure of an image anomaly detection method for industrial product quality control according to the present invention;

[0036] Figure 2 A sample diagram of the dataset. Implementation Method

[0037] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0038] like Figure 1 As shown in FIG2 , the present invention discloses an image anomaly detection method for industrial product quality control, which comprises the following steps:

[0039] Step 1: Standardize the input industrial product image, including adjusting the image size and normalization, to adapt to the subsequent feature extraction and reconstruction process;

[0040] Step 2: Map the normalized original input image into a potential feature map;

[0041] Step 3: Convert the latent feature map into a mask vector, use the mask vector to select local key features in the latent feature map, and use the deep feature encoder to perform secondary selection on the local key features to extract representative local key features;

[0042] Specifically, using the datasets in Table 1, we use the preliminary feature encoder E pf Perform feature extraction on the image after preprocessing to produce the potential feature map z pf ,The preliminary feature encoder consists of multiple convolutional layers with different kernel sizes and strides.mg ∈(0,1), the mask vector z mg With feature map z pf The activated feature map is weighted and the encoder is used to further extract the activated feature map into the depth feature z df , and then use the depth feature z df With the mask vector z mg Perform weighting to obtain the local key feature z.

[0043] Step 4: Reconstruct the image using local key features and use adversarial training to improve the quality of the reconstructed image;

[0044] Specifically, the reconstruction decoder is used to reconstruct the image based on the local key feature z, and based on the idea of ​​adversarial training, the discriminator is used to evaluate the quality of the reconstructed image to improve the quality of the reconstructed image. In order to minimize the reconstruction error and thus ensure the quality of anomaly detection, the loss function is constructed with the goal of minimizing the reconstruction error:

[0045] L=λL adv +(1-λ)L local

[0046] Among them L adv Denotes the adversarial loss function, L local represents the reconstruction loss function, L adv It can be expressed as:

[0047] The specific steps include:

[0048] Step 4-1, construct the adversarial loss function L adv , adversarial loss function L adv , L adv The calculation expression is as follows:

[0049]

[0050] Where D r Denotes the reconstruction decoder, D qe represents the quality enhancement discriminator, represents the expected value of a random variable x, where x is a sample drawn from the probability distribution p(x), and D qe (x) represents the result of identifying the random variable x, D r (E(x)) represents a mapping from sample space to sample space, not from noise space to sample space. qe (D r (E(x))) represents the result of identifying the reconstructed sample;

[0051] Step 4-2, construct the reconstruction loss function L local , reconstruction loss function Llocal The calculation expression is as follows:

[0052]

[0053] in, Represents the probability distribution p of z under given conditions x mg,df (Z|x) performs expected value calculation, z represents the key feature, p mg,df Indicates encoder E mg and E df The probability distribution of p(x|z) represents the probability distribution of data point x given feature z; KL divergence is used to measure the probability distribution of two probability distributions p mg,df , p θ the differences between;

[0054] Step 4-3, the formula for constructing the loss function L is expressed as:

[0055] L=λL adv +(1-λ)L local

[0056] Among them, L adv Denotes the adversarial loss function, L local represents the reconstruction loss function.

[0057] Step 5: Obtain an anomaly score based on the difference between the original input image and the reconstructed image, and determine the abnormal result based on the anomaly score.

[0058] Specifically, the anomaly score is calculated based on the reconstruction error. A high anomaly score of a test sample indicates that it is more likely to be an anomaly, while a low anomaly score indicates that the sample is likely to be normal. Specifically, when the anomaly score of a test sample is greater than or equal to 0.5, it indicates that it is an anomaly, and when the anomaly score is lower than the set score, it indicates that the test sample is normal. The calculation formula can be expressed as:

[0059]

[0060] Among them, x test For test samples.

[0061] Technical Effect: Here is a glossary: ​​Local_GAN - the image anomaly detection method for industrial product quality control described in the embodiment of the present invention. In this embodiment, an industrial image dataset is used for image anomaly detection. The image dataset is shown in Table 1:

[0062] Table 1

[0063]

[0064] The performance of anomaly detection algorithms is measured by comparing the AUROC scores obtained by different algorithms when performing anomaly detection on various image datasets.

[0065] Table 2 shows the AUROC scores of different anomaly detection methods on the real industrial anomaly detection dataset MVtecAD. It can be seen that the anomaly detection performance of Local-GAN (AUROC = 91.7%) is generally better than the compared reconstruction-based anomaly detection methods.

[0066] Table 2

[0067]

[0068] In summary, the method for detecting anomalies in product-quality images described in the embodiments of the present invention is applicable to anomaly detection in various image datasets and can effectively improve accuracy.

[0069] The present invention adopts the above technical solution. Compared with the existing technology, the present invention has the following characteristics and beneficial effects: In the existing reconstruction-based image anomaly detection algorithm, abnormal data is often accurately reconstructed, resulting in large detection errors. The present invention uses a dual encoding mechanism to learn local key features. The preliminary feature encoder is responsible for extracting the overall features of the input image, including basic information such as edges and textures. The deep feature encoder further processes these features and focuses on extracting key local features that affect product quality. This method can not only capture the global information of the image, but also deeply explore local key features. The reconstruction based on key features effectively avoids the problem of accurate reconstruction of abnormal data and improves the accuracy of anomaly detection.

[0070] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

Claims

1. A method for detecting anomalies in images for industrial product quality control, characterized by: It includes the following steps: Step 1: Standardize the input industrial product image to adapt to the subsequent feature extraction and reconstruction process; Step 2: Map the normalized original input image into a potential feature map; Step 3: Convert the latent feature map into a mask vector, use the mask vector to select local key features in the latent feature map, and use the deep feature encoder to perform secondary selection on the local key features to extract representative local key features; In step 4, the image is reconstructed using local key features, and adversarial training is used to improve the quality of the reconstructed image. In step 4, a loss function is constructed with the goal of minimizing the reconstruction error. The specific steps are as follows: Step 4-1, construct the adversarial loss function L adv , adversarial loss function L adv , L adv The calculation expression is as follows: Where D r Denotes the reconstruction decoder, D qe represents the quality enhancement discriminator, represents the expected value of a random variable x, where x is a sample drawn from the probability distribution p(x), and D qe (x) represents the result of identifying the random variable x, D r (E(x)) represents the mapping from sample space to sample space, D qe (D r (E(x))) represents the result of identifying the reconstructed sample; Step 4-2, construct the reconstruction loss function L local , reconstruction loss function L local The calculation expression is as follows: in, Represents the probability distribution p of z under given conditions x mg,df (z|x) performs expected value calculation, z represents the key feature, p mg,df Indicates encoder E mg and E df The probability distribution of p(x|z) represents the probability distribution of data point x given feature z; KL divergence is used to measure the probability distribution of two probability distributions p mg,df , p θ the differences between; Step 4-3, the formula for constructing the loss function L is expressed as: L=λL adv +(1-λ)L local Among them, L adv Denotes the adversarial loss function, L local represents the reconstruction loss function; Step 5: Obtain an anomaly score based on the difference between the original input image and the reconstructed image, and determine the abnormal result based on the anomaly score.

2. The image anomaly detection method for industrial product quality control according to claim 1, characterized in that: Standardization processing includes resizing and normalizing industrial product images.

3. The image anomaly detection method for industrial product quality control according to claim 1, characterized in that: Also includes: Step 3 uses the Gumbel-Softmax method to perform binary calculations to handle discrete choice problems.

4. The image anomaly detection method for industrial product quality control according to claim 1, characterized in that: In step 3, a dual encoding mechanism is used to deeply select local key features. The specific steps are as follows: Step 3-1, extract the feature map z of the original input image through the encoder pf ; Step 3-2, the feature map z of the original input image pf Mapped to mask vector z mg ∈(0,1); Step 3-3, the mask vector z mg With feature map z pf Perform weighting to obtain an activated feature map; Step 3-4, use the encoder to further extract the activated feature map into deep features z df , and then use the depth feature z df With the mask vector z mg Perform weighting to obtain the local key feature z.

5. The image anomaly detection method for industrial product quality control according to claim 1, characterized in that: In step 4, a reconstruction decoder is used to reconstruct the image based on the selected local key features, and based on the idea of ​​adversarial training, a discriminator is used to evaluate the quality of the reconstructed image to improve the quality of the reconstructed image.

6. The image anomaly detection method for industrial product quality control according to claim 1, characterized in that: In step 5, the anomaly score is calculated based on the reconstruction error. When the anomaly score of the test sample is lower than the set score, it indicates that the test sample belongs to the normal range. The calculation formula of the anomaly score is expressed as: Among them, x test For the test sample, D r (E(x test )) represents the reconstructed sample.

7. The image anomaly detection method for industrial product quality control according to claim 6, characterized in that: Set the score to 0.5.