High-quality industrial abnormal data synthesis method
By combining a hybrid anomaly decoupling module and an automatic anomaly dataset generation module, high-quality anomaly images and mask pairs are generated, solving the problem of poor quality in generating complex anomaly images and mask pairs in existing methods, and improving the performance of industrial anomaly detection and classification.
Patent Information
- Application Number
- CN202411811506.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-12-10
AI Technical Summary
Existing methods for synthesizing industrial anomaly data struggle to generate high-quality, complex anomaly images and mask pairs, and the uncertainty of the generation model necessitates labor-intensive screening, which fails to meet practical needs.
A hybrid anomaly decoupling module, a high-quality anomaly mask generation module, and an automatic anomaly dataset generation module are employed. Anomaly categories are decoupled through multi-turn dialogue using a visual language model, generating high-quality anomaly masks aligned with attributes. Anomaly image and mask pairs are then filtered using the Textual Inversion method.
It significantly improves the performance of industrial anomaly detection, localization and classification tasks, and the generated anomaly data achieves excellent results on the MvTec-AD dataset, solving the generation quality and efficiency problems of existing methods.
Smart Images

Figure CN119762908B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of computer vision and artificial intelligence, and particularly relates to a high-quality industrial abnormal data synthesis method. BACKGROUND
[0002] Abnormality detection algorithms play a key role in industrial manufacturing, which usually involves tasks such as abnormality detection, localization and classification. Due to the scarcity of abnormal data, most industrial abnormality detection methods rely on unsupervised learning methods, in which a single-class classifier is trained using only normal data, or supervised learning methods that utilize a small amount of abnormal data. Although these algorithms perform well in abnormality detection, they often have limitations in abnormality localization tasks and cannot handle abnormality classification tasks. Therefore, it has become increasingly urgent to address the problem of abnormal data scarcity. The emergence of abnormal data synthesis methods provides a new approach to alleviating this problem by expanding the abnormal data set to enhance the robustness of supervised models. Currently, researchers have proposed various abnormal data synthesis techniques, including traditional model-free methods, generative adversarial network (GAN) based methods, and diffusion model based methods.
[0003] Although these methods have great potential, existing methods face several major challenges: (1) Existing methods mainly focus on generating simple structural abnormal images, such as object damage or surface scratches; however, for more complex abnormal image generation tasks, especially those involving logical relationships or containing multiple types of combined abnormalities, they often perform poorly. (2) Existing methods mostly focus on generating abnormal images, ignoring the key task of generating image and mask pairs, and some methods have difficulty in accurately aligning abnormal parts with their corresponding masks, while others generate irregularly shaped masks that are not properly positioned with abnormal parts. (3) Due to the inherent uncertainty of the generation model, the quality of the generated abnormal images and mask pairs is poor, and relies on labor-intensive manual screening to address. Therefore, existing industrial abnormal data synthesis methods are difficult to meet the actual use requirements. SUMMARY
[0004] To solve the above problems, the application provides a high-quality industrial abnormal data synthesis method, which realizes the synthesis of high-quality abnormal images and mask pairs through a mixed abnormality decoupling module, a high-quality abnormal mask generation module and an automatic abnormal data set generation module, and the synthesized abnormal data significantly improves the performance in downstream tasks such as industrial abnormality detection, localization and classification.
[0005] To achieve the above purpose, the application adopts the following technical solutions:
[0006] A high-quality industrial abnormal data synthesis method, comprising the following steps:
[0007] S1, adopt a mixed abnormality decoupling module, carry out multi-round dialogue through a visual language model, decouple the coupled abnormality categories in the abnormality data set, and convert the coupled abnormality categories into more fine-grained categories and attributes;
[0008] S2, adopt a high-quality abnormality mask generation module, generate abnormality masks that are aligned with various attributes, positionally accurate and normally shaped through an abnormality mask generator, a guided region Printer and an abnormality mask locator;
[0009] S3, adopt an automatic abnormality data set generation module, synthesize and filter out high-quality abnormality image and mask pairs through a Textual Inversion method and an automatic filter.
[0010] Preferably, the specific process of step S1 is as follows:
[0011] S11, input the abnormality image I a and its corresponding mask M a sampled from the abnormality data set into the mixed abnormality decoupling module,
[0012] S12, based on the abnormality categories in the abnormality image I a , design K sets of tailor-made prompts, each set of prompts containing two different questions, each question being personalized according to the specific abnormality category and attribute, the i-th prompt set being defined as:
[0013]
[0014] wherein P i represents the i-th prompt set; represents the first round of prompts in the i-th prompt set; T1 represents the description of the category refinement task; C1, …, C N represent the fine-grained abnormality categories obtained by analyzing the mixed abnormality categories; S c represents the category selection constraint; represents the second round of prompts in the i-th prompt set; T2 represents the description of the attribute refinement task; A1, A2 and A3 represent the descriptions of abnormal attributes, respectively, for representing structural abnormalities, logical abnormalities and combined abnormalities; S a represents the attribute selection constraint;
[0015] S13, input the abnormality image I a and the mask M aand prompt set P input visual language model GPT-4, K rounds of independent two-stage dialogue are carried out; in each round of dialogue, the visual language model GPT-4 outputs the category and attribute corresponding to the abnormal area in the mask; then through the voting mechanism, the most frequent result is selected as the final category C and attribute A, and all mixed abnormal categories are disassembled into fine-grained categories and abnormal attributes;
[0016] S14, output dictionary D a ={I a :(M a ,C,A)} i , dictionary D a is used for high-quality abnormal mask generation module and automatic abnormal data set generation module.
[0017] Preferably, the high-quality abnormal mask generation module in step S2 includes an AM-Generator component, a GA-RegionPrinter component and an AM-Locator component, and the specific process of step S2 is as follows:
[0018] S21, the AM-Generator component is used as a mask generator based on a morphological conversion method, for generating diverse structural abnormal masks;
[0019] S22, the GA-RegionPrinter component is used to segment the guided abnormal area of the normal sample, for solving the misalignment problem between the abnormal mask and the object;
[0020] S23, the AM-Locator component is used to synthesize high-quality abnormal masks based on the abnormal category and attribute dictionary D a obtained from the mixed abnormal decoupling module using different region guiding strategies.
[0021] Preferably, the specific process of step S21 is as follows:
[0022] S211, mask structure optimization: for the input structural abnormal mask M, first perform a preliminary closing operation to optimize the mask, including inflation operation to fill small holes and connect broken areas, then smooth the boundary by erosion operation and remove tiny noise points, extract the external contour of the mask and apply polygon approximation and random disturbance to generate new shape variants, for enhancing the diversity of mask data, the mask structure optimization process is represented as:
[0023]
[0024] Wherein, M opt represents the optimized structural mask; B1 represents the structural element used for inflation operation; B2 represents the structural element used for erosion operation; M represents the structural abnormal mask; represents an inflation operation; represents an erosion operation; ε represents an approximation accuracy; F(·) represents a contour extraction function; P(·,ε) represents a polygon approximation function; ΔP represents a random perturbation vector within a perturbation range;
[0025] S212, mask distribution optimization: the generated abnormal mask M opt is adaptively adjusted to correct the deviation, for making the generated abnormal mask M opt The area A M of the abnormal region distribution consistent with its corresponding category; for the abnormal mask M avg whose area is much smaller than the average abnormal area A opt of the corresponding category, optimization is carried out by applying a scaling factor to obtain the distribution-optimized abnormal mask M G , and the mask distribution optimization process is represented as:
[0026]
[0027] wherein M G represents the distribution-optimized abnormal mask; M opt represents the generated abnormal mask; α represents an adjustment parameter; A avg represents the average abnormal area of the corresponding category; A M represents the area of the generated abnormal mask M opt .
[0028] Preferably, the specific process of step S22 is:
[0029] S221, set a predefined guide abnormal region for each object category by analyzing the distribution of abnormal patterns in different object categories
[0030] S222, use SAM segmentation all models to segment the guide abnormal region R j from 3 to 5 normal samples of the same object category.
[0031] S223, take the segmented guide abnormal region R j as the prompt of the SegGPT segmentation context content model, which is used to infer the guide abnormal region R j in the remaining normal samples of the object category, and generate the mask j of each guide abnormal region R
[0032] S224, all masks are collectively formed into a set M regions , which is used for subsequent abnormal mask positioning in the AM-Locator component.
[0033] Preferably, the specific process of step S23 is as follows:
[0034] S231. For structural anomaly attribute A, select from set M according to its anomaly category C. regions Retrieve the corresponding guide abnormal region mask MR in the middle j Then from the anomaly mask M G Randomly select an anomaly mask M g And adjust the exception mask M using different region guidance strategies according to the exception category C. g The location; where the region guidance strategy includes using the anomaly mask M g Randomly placed in the boot error region mask MR j Internally, randomly assign an anomaly mask M g Embedded in the boot error region mask MR j Internal or abnormal mask M g and guide abnormal region mask MR j Align the center point to generate a position-aligned structural anomaly mask M. struct ;
[0035] S232. For logical exception attribute A, directly use the bootstrap exception region mask MR. j As a logical exception mask M logic ;
[0036] S233. For combined abnormal attribute A, according to dictionary D... a Obtain all decoupled fine-grained categories; randomly extract and construct different anomaly combinations from the decoupled fine-grained categories, and then merge non-overlapping mask combinations to generate a combined anomaly mask M. combined .
[0037] Preferably, the specific process of step S3 is as follows:
[0038] S31, Anomaly Image Generation: For each decoupled fine-grained anomaly category C j Using exception embedding Appearance information of anomalous samples is extracted using a masked texture inversion method; all fine-grained anomaly categories C j Share a common position encoder E; for a pair of image masks (G) in the training data j M j ), and the exception mask M j The input is fed into the position encoder E to obtain the position embedding e. L =E(M j Then embed the exception and position embedding e L Fusion forms fusion anomaly embedding Embedding the fusion anomaly as a text condition of the diffusion model to guide the anomaly image generation process;
[0039] S32, automatic anomaly filtering: using the feature extractor F β Normal features are extracted from normal samples, and a binary anomaly discriminator B is trained by adding Gaussian noise to these normal features to simulate abnormal features D ; then extract features from the generated abnormal image-mask pair (I G , M G ) and input the extracted features into the binary anomaly discriminator B D to obtain an anomaly score map S; the quality of the generated abnormal image-mask pair is evaluated by the anomaly region score, and the calculation formula is:
[0040]
[0041] Where ARS represents the anomaly region score; i represents the horizontal coordinate in the anomaly score map; j represents the vertical coordinate in the anomaly score map; H represents the height of the image; W represents the width of the image; U(·) represents up-sampling; B D (·) represents the binary anomaly discriminator; F β (·) represents the feature extractor; I G represents the abnormal image; represents dot multiplication; M G represents the abnormal mask; (i,j) represents the horizontal and vertical coordinates of each position in the anomaly score map; and the top K aligned high-quality abnormal image-mask pairs are automatically filtered based on the anomaly region score.
[0042] After adopting the above technical solution, the present application has the following beneficial effects: the present application realizes the synthesis of high-quality abnormal images and mask pairs through the mixed anomaly decoupling module, the high-quality abnormal mask generation module and the automatic abnormal dataset generation module. The synthesized abnormal data significantly improves the performance in downstream tasks such as industrial anomaly detection, positioning and classification. Specifically, the mixed anomaly decoupling module can decouple the coupled abnormal dataset into more fine-grained categories and attributes, thereby enhancing the model's ability to generate complex abnormal image and mask pairs; the high-quality abnormal mask generation module can synthesize a large number of high-quality abnormal masks through the abnormal mask generator, the guided region Printer and the abnormal mask locator; the automatic abnormal dataset generation module can synthesize and select a large number of high-quality abnormal image and mask pairs through the Textual Inversion method and an automatic filter. The high-quality industrial abnormal data synthesis method (GAA) proposed by the present application achieves excellent results in classification, positioning and detection tasks on the MvTec-AD dataset. BRIEF DESCRIPTION OF DRAWINGS
[0043] Fig. 1 A flowchart of the present application;
[0044] Fig. 2 A schematic diagram of the flowchart framework of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical scheme and advantages of the present application more clear, the present application will be further described in detail below in combination with embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0046] As shown in Figs. 1-2 , a high-quality industrial abnormal data synthesis method comprises the following steps:
[0047] S1, a mixed abnormal decoupling module is used to perform multi-round dialogue through a visual language model to decouple the coupled abnormal categories in the abnormal data set, so that the coupled abnormal categories are converted into more fine-grained categories and attributes;
[0048] The specific process of step S1 is as follows:
[0049] S11, the abnormal image I a and its corresponding mask M a sampled from the abnormal data set are input into the mixed abnormal decoupling module,
[0050] S12, based on the abnormal categories in the abnormal image I a , K sets of tailor-made prompt sentences are designed, each set of prompt sentences contains two different questions, each question is personalized according to the specific abnormal category and attribute, and the i th prompt set is defined as:
[0051]
[0052] Wherein, P i represents the i th prompt set; represents the first round of prompts in the i th prompt set; T1 represents the description of the category refinement task; C1, …, C N represents the fine-grained abnormal category obtained by analyzing the mixed abnormal category; S c represents the category selection constraint; represents the second round of prompts in the i th prompt set; T2 represents the description of the attribute refinement task; A1, A2, A3 respectively represent the description of the abnormal attribute, which are respectively used to represent structural abnormality, logical abnormality and combined abnormality; S a represents the attribute selection constraint;
[0053] S13, the abnormal image I a , the mask M aand prompt set P input visual language model GPT-4, K rounds of independent two-stage dialogue are carried out; in each round of dialogue, the visual language model GPT-4 outputs the category and attribute corresponding to the abnormal area in the mask; then through the voting mechanism, the most frequent result is selected as the final category C and attribute A, and all mixed abnormal categories are disassembled into fine-grained categories and abnormal attributes;
[0054] S14, output dictionary D a ={I a :(M a ,C,A)} i , dictionary D a is used for high-quality abnormal mask generation module and automatic abnormal data set generation module;
[0055] S2, adopt high-quality abnormal mask generation module, generate abnormal mask with various attributes, accurate position and normal shape through abnormal mask generator, guide region Printer and abnormal mask locator;
[0056] The high-quality abnormal mask generation module in step S2 includes AM-Generator component, GA-RegionPrinter component and AM-Locator component, and the specific process of step S2 is:
[0057] S21, the AM-Generator component is used as a mask generator based on morphological conversion method, which is used to generate various structural abnormal masks;
[0058] The specific process of step S21 is:
[0059] S211, mask structure optimization: for the input structural abnormal mask M, first perform preliminary closing operation to optimize the mask, including inflation operation to fill small holes and connect broken areas, then smooth the boundary and remove small noise points through erosion operation, and then extract the external contour of the mask and apply polygon approximation and random disturbance to generate new shape variants, which is used to enhance the diversity of mask data, and the mask structure optimization process is represented as:
[0060]
[0061] Wherein, M opt represents the optimized structural mask; B1 represents the structural element used for inflation operation; B2 represents the structural element used for erosion operation; M represents the structural abnormal mask; represents inflation operation; represents erosion operation; ε represents approximation accuracy; F(·) represents contour extraction function; P(·,ε) represents polygon approximation function; ΔP represents random disturbance vector within disturbance range;
[0062] S212, Mask distribution optimization: optimizing the generated anomaly mask M opt to correct the bias for making the generated anomaly mask M opt with area A M consistent with the distribution of abnormal regions of its corresponding category; for the anomaly mask M avg with area much smaller than the average abnormal area A opt of the corresponding category, optimization is performed by applying a scaling factor to obtain the distribution-optimized anomaly mask M G , and the mask distribution optimization process is represented as:
[0063]
[0064] where M G represents the distribution-optimized anomaly mask; M opt represents the generated anomaly mask; α represents the adjustment parameter; A avg represents the average abnormal area of the corresponding category; A M represents the area of the generated anomaly mask M opt .
[0065] S22, using the GA-RegionPrinter component to segment the guided abnormal regions of normal samples, for solving the misalignment problem between the anomaly mask and the object;
[0066] The specific process of step S22 is:
[0067] S221, by analyzing the distribution of abnormal patterns in different object categories, set a pre-defined guided abnormal region for each object category
[0068] S222, use SAM segmentation all models to segment the guided abnormal region R j from 3 to 5 normal samples of the same object category;
[0069] S223, take the segmented guided abnormal region R j as the prompt of the SegGPT segmentation context content model, for inferring the guided abnormal region R j in the remaining normal samples of the object category, and generating the mask j of each guided abnormal region R
[0070] S224, all masks form a set M regions together, which is used for subsequent anomaly mask positioning in the AM-Locator component;
[0071] S23. Employ the AM-Locator component based on the exception category and attribute dictionary D obtained from the hybrid exception decoupling module. a High-quality anomaly masks are synthesized using different region guidance strategies;
[0072] The specific process of step S23 is as follows:
[0073] S231. For structural anomaly attribute A, select from set M according to its anomaly category C. regions Retrieve the corresponding guide abnormal region mask MR in the middle j Then from the anomaly mask M G Randomly select an anomaly mask M g And adjust the exception mask M using different region guidance strategies according to the exception category C. g The location; where the region guidance strategy includes using the anomaly mask M g Randomly placed in the boot error region mask MR j Internally, randomly assign an anomaly mask M g Embedded in the boot error region mask MR j Internal or abnormal mask M g and guide abnormal region mask MR j Align the center point to generate a position-aligned structural anomaly mask M. struct ;
[0074] S232. For logical exception attribute A, directly use the bootstrap exception region mask MR. j As a logical exception mask M logic ;
[0075] S233. For combined abnormal attribute A, according to dictionary D... a Obtain all decoupled fine-grained categories; randomly extract and construct different anomaly combinations from the decoupled fine-grained categories, and then merge non-overlapping mask combinations to generate a combined anomaly mask M. combined ;
[0076] S3. An automatic anomaly dataset generation module was used to synthesize and filter high-quality anomaly images and mask pairs through the Textual Inversion method and automatic filters.
[0077] The specific process of step S3 is as follows:
[0078] S31, Anomaly Image Generation: For each decoupled fine-grained anomaly category C j Using exception embedding Appearance information of anomalous samples is extracted using a masked texture inversion method; all fine-grained anomaly categories C jshare a common position encoder E; for a pair of image-mask (I j , M j ) in the training data, the abnormal mask M j is input into the position encoder E to obtain the position embedding e L = E(M j ), and the abnormal embedding e and the position embedding e L are fused to form a fused abnormal embedding e The fused abnormal embedding e is used as the text condition of the diffusion model to guide the abnormal image generation process.
[0079] S32, automatic abnormal filtering: using the feature extractor F β , normal features are extracted from normal samples, and a binary abnormality discriminator B D is trained by adding Gaussian noise to these normal features to simulate abnormal features; then features are extracted from the generated abnormal image-mask pairs (I G , M G ) and input into the binary abnormality discriminator B D to obtain an abnormal score map S; the quality of the generated abnormal image-mask pair is evaluated by the abnormal region score, and the calculation formula is:
[0080]
[0081] Where ARS represents the abnormal region score; i represents the horizontal coordinate in the abnormal score map; j represents the vertical coordinate in the abnormal score map; H represents the height of the image; W represents the width of the image; U(·) represents up-sampling; B D (·) represents the binary abnormality discriminator; F β (·) represents the feature extractor; I G represents the abnormal image; represents dot multiplication; M G represents the abnormal mask; (i,j) represents the horizontal and vertical coordinates of each position in the abnormal score map; and the top K aligned high-quality abnormal image-mask pairs are automatically filtered based on the abnormal region score.
[0082] The effects of the present application are further illustrated by the following simulation experiments.
[0083] 1) Simulation conditions
[0084] The present application is developed on the Ubuntu platform, and the developed deep learning framework is based on Pytorch. The main language used in the present application is Python.
[0085] 2) Simulation content
[0086] The experimental setup is as follows: a. the initial learning rate of the generation model is 5e-3 , the batch size is 4, and the number of training steps is more than 310000.
[0087] The MVTec-AD dataset is taken, the network is trained according to the above steps and experimental settings, and the test set is used for testing. In order to verify the effectiveness of the method, multiple metrics are used: (1) For the evaluation of anomaly generation, Inception Score (IS) and Intra-cluster Pairwise LPIPS Distance (IC-LPIPS) are used to evaluate the authenticity and diversity of the generated abnormal images. The quality of the synthesized image-mask pairs is evaluated using the Abnormal Region Score (ARS). (2) For the evaluation of anomaly detection, the area under the receiver operating characteristic curve (AUROC), the average precision (AP), and the maximum F1 score (F1-max) are used to evaluate the accuracy of detection and positioning. The accuracy (ACC) of the classification task is also used to evaluate the accuracy of the classification.
[0088] Table 1 is the test results of the high-quality industrial anomaly data synthesis method (GAA) of the present application and the three other methods Cut-Pastc, DFMGAN, and Anodiff on the MVTec-AD dataset.
[0089] Table 1: Test results of GAA, Cut-Pastc, DFMGAN, and Anodiff on the MVTec-AD dataset
[0090]
[0091] From the test results in Table 1, it can be seen that the high-quality industrial anomaly data synthesis method (GAA) of the present application is the best among the three other methods Cut-Pastc, DFMGAN, and Anodiff.
[0092] Table 2: Performance comparison results on the anomaly detection task of the image set
[0093]
[0094] Table 2 is the performance comparison of the U-Net segmentation model trained on the downstream task of the abnormal data synthesized by the high-quality industrial anomaly data synthesis method (GAA) of the present application and the data generated by other abnormal synthesis methods on the anomaly detection task of the image set. Compared with other methods, GAA is the best.
[0095] Table 3: Performance comparison results on the pixel-level anomaly localization task
[0096]
[0097] Table 3 is the performance comparison of the U-Net segmentation model trained on the downstream task of the abnormal data synthesized by the high-quality industrial abnormal data synthesis method (GAA) of the present application and the data generated by other abnormal synthesis methods on the pixel-level anomaly localization task.
[0098] Table 4: Performance comparison results on the anomaly classification task
[0099]
[0100] Table 4 is the performance comparison of the ResNet-18 segmentation model trained on the downstream task of the abnormal data synthesized by the high-quality industrial abnormal data synthesis method (GAA) of the present application and the data generated by other abnormal synthesis methods on the anomaly classification task.
[0101] Table 5: Performance comparison results on the anomaly localization downstream task
[0102]
[0103] Table 5 is the performance comparison (AUROC-Pixel / AP) of the U-Net model trained on the abnormal data synthesized by the high-quality industrial abnormal data synthesis method (GAA) of the present application and other abnormal detection methods on the anomaly localization downstream task.
[0104] The above description is only a preferred embodiment of the present application, but the protection scope of the present application is not limited thereto, any changes or replacements within the technical range disclosed by the present application can be easily thought by those skilled in the art, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for synthesizing high-quality industrial anomaly data, characterized in that, Includes the following steps: S1. A hybrid anomaly decoupling module is adopted, which uses a visual language model to conduct multi-turn dialogues to decouple the anomaly categories that are coupled in the anomaly dataset, so that the coupled anomaly categories are transformed into more granular categories and attributes. S2. A high-quality anomaly mask generation module is adopted, which generates anomaly masks that are aligned with various attributes, have precise positions, and normal shapes through an anomaly mask generator, a guide area Printer, and an anomaly mask locator. The high-quality anomaly mask generation module mentioned in step S2 includes the AM-Generator component, the GA-RegionPrinter component, and the AM-Locator component. The specific process of step S2 is as follows: S21. The AM-Generator component is used as a mask generator based on the morphological transformation method to generate various structural anomaly masks. S22. The GA-RegionPrinter component is used to segment the abnormal region of normal samples to solve the misalignment problem between the abnormal mask and the object. S23. Employ the AM-Locator component based on the exception category and attribute dictionary D obtained from the hybrid exception decoupling module. a High-quality anomaly masks are synthesized using different region guidance strategies; S3. An automatic anomaly dataset generation module was used to synthesize and filter high-quality anomaly images and mask pairs through the Textual Inversion method and automatic filters. The specific process of step S3 is as follows: S31, Anomaly Image Generation: For each decoupled fine-grained anomaly category C j Using exception embedding Extracting appearance information of anomalous samples using a masked texture inversion method; All fine-grained anomaly categories C j Share a common position encoder E; for a pair of image masks (G) in the training data j M j ), and the exception mask M j The input is fed into the position encoder E to obtain the position embedding e. L =E(M j Then embed the exception and position embedding e L Fusion forms fusion anomaly embedding The fusion anomaly embedding e is used as a textual condition for the diffusion model to guide the anomaly image generation process; S32. Automatic Anomaly Filtering: Using Feature Extractor F β Normal features are extracted from normal samples, and Gaussian noise is added to these normal features to simulate abnormal features, thereby training a binary anomaly discriminator B. D Then from the generated abnormal image-mask pair (I G M G Features are extracted and input into the binary anomaly discriminator B. D In order to obtain the anomaly score map S; The quality of the generated anomaly image-mask pair is evaluated using anomaly region scores, calculated as follows: Where ARS represents the anomaly score; i represents the x-coordinate of the anomaly score map; j represents the y-coordinate of the anomaly score map; H represents the image height; W represents the image width; U(·) represents upsampling; B D (·) indicates a binary anomaly discriminant; F β (·) indicates a feature extractor; I G Represents an anomalous image; ⊙ represents a dot product; M G The mask represents the anomaly; (i,j) represents the x and y coordinates of each position in the anomaly score map; then, based on the anomaly region score, the top K aligned high-quality anomaly image-mask pairs are automatically filtered out.
2. The method for synthesizing high-quality industrial anomaly data as described in claim 1, characterized in that, The specific process of step S1 is as follows: S11, Anomaly images I sampled from the anomaly dataset. a and its corresponding mask M a The input is fed into the hybrid exception decoupling module. S12, Based on anomaly image I a For each anomaly category, design K sets of customized prompts. Each set of prompts contains two different questions, and each question is personalized based on the specific anomaly category and attributes. The i-th set of prompts is defined as follows: Among them, P i This represents the i-th set of prompts; T1 represents the first round of prompts in the i-th prompt set; T1 represents the description of the category refinement task; C1,…,C N This represents a fine-grained anomaly category derived from the analysis of mixed anomaly categories; S c Indicates category selection constraints; T1 represents the second round of prompts in the i-th prompt set; T2 represents the description of the attribute refinement task; A1, A2, and A3 represent the descriptions of the exception attributes, respectively used to represent structural exceptions, logical exceptions, and composite exceptions; S a This indicates attribute selection constraints; S13, Transfer the abnormal image I a Mask M a The visual language model GPT-4 is input with a set of prompts P and K independent two-stage dialogues are conducted. In each dialogue, the visual language model GPT-4 outputs the category and attribute corresponding to the abnormal region within the mask. Then, through a voting mechanism, the most frequently occurring result is selected as the final category C and attribute A, and all mixed abnormal categories are decomposed into fine-grained categories and abnormal attributes. S14, Output dictionary D a ={I a :(M a ,C,A)} i Dictionary D a Used for high-quality anomaly mask generation module and automatic anomaly dataset generation module.
3. The method for synthesizing high-quality industrial anomaly data as described in claim 1, characterized in that, The specific process of step S21 is as follows: S211, Mask Structure Optimization: For the input structurally anomalous mask M, a preliminary closure operation is first performed to optimize the mask, including dilation to fill small holes and connect broken areas. Then, erosion is used to smooth boundaries and remove minor noise. Next, the outer contour of the mask is extracted and polygon approximation and random perturbation are applied to generate new shape variants to enhance the diversity of the mask data. The mask structure optimization process is represented as follows: Among them, M opt B1 represents the optimized structure mask; B2 represents the structure element used for the dilation operation; M represents the structure anomalous mask. Indicates an expansion operation; ε represents the erosion operation; F(·) represents the approximation accuracy; P(·,ε) represents the contour extraction function; ΔP represents the polygon approximation function; ΔP represents the random perturbation vector within the perturbation range. S212, Mask Distribution Optimization: Optimize the generated abnormal mask M opt Adaptive adjustments are made to correct deviations, used to make the generated anomaly mask M opt Area A M The distribution of abnormal regions is consistent with that of their corresponding categories; for abnormal regions with an area much smaller than the average abnormal area A of the corresponding category... avg The anomaly mask M opt By applying a scaling factor for optimization, the distribution-optimized anomaly mask M is obtained. G The mask distribution optimization process is represented as follows: Among them, M G M represents the anomaly mask after distribution optimization; opt Indicates the generated anomaly mask; α represents the adjustment parameter; A avg A represents the average area of anomalies in the corresponding category; M The generated anomaly mask M opt The area.
4. The method for synthesizing high-quality industrial anomaly data as described in claim 1, characterized in that, The specific process of step S22 is as follows: S221. By analyzing the distribution of abnormal patterns in different object categories, predefined guided abnormal regions are set for each object category. S222. Use the SAM segmentation model to segment the abnormal region R from 3 to 5 normal samples of the same object category. j ; S223, the segmented abnormal guidance region R j As a hint for the SegGPT segmentation context content model, it is used to infer the guided anomalous region R in the remaining normal samples of the object category. j And generate R for each guided abnormal region in all normal samples. j mask S224, Mask all Together they form a set M regions This is used for anomaly masking in subsequent AM-Locator components.
5. The method for synthesizing high-quality industrial anomaly data as described in claim 1, characterized in that, The specific process of step S23 is as follows: S231. For structural anomaly attribute A, select from set M according to its anomaly category C. regions Retrieve the corresponding guide abnormal region mask MR in the middle j Then from the anomaly mask M G Randomly select an anomaly mask M g And adjust the exception mask M using different region guidance strategies according to the exception category C. g The location; where the region guidance strategy includes using the anomaly mask M g Randomly placed in the boot error region mask MR j Internally, randomly assign an anomaly mask M g Embedded in the boot error region mask MR j Internal or abnormal mask M g and guide abnormal region mask MR j Align the center point to generate a position-aligned structural anomaly mask M. struct ; S232. For logical exception attribute A, directly use the bootstrap exception region mask MR. j As a logical exception mask M logic ; S233. For combined abnormal attribute A, according to dictionary D... a Obtain all decoupled fine-grained categories; randomly extract and construct different anomaly combinations from the decoupled fine-grained categories, and then merge non-overlapping mask combinations to generate a combined anomaly mask M. combined .
Citation Information
Patent Citations
Method for constructing image anomaly detection model based on mask multi-modal generative adversarial network
CN116994044A
Anomaly detection method and device based on large visual language model
CN117745680A