Construction method of anomaly detection model driven by soft label, and composite self-supervision anomaly detection method and system

By generating a defect simulator using Bézier curves and optimizing the discriminator using a soft-label-driven self-supervised loss, the problems of low detection accuracy and unstable training in industrial anomaly detection are solved, achieving efficient and highly generalizable defect detection.

CN121746772APending Publication Date: 2026-03-27HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-03
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing industrial anomaly detection methods have low detection accuracy when defect samples are scarce, and hard labels lead to unstable training, weak generalization ability, high memory consumption, and slow inference speed.

Method used

A defect simulator is generated using Bézier curves. Combined with a frozen Wide ResNet V2 backbone network and a multi-scale window feature aggregator, the discriminator is optimized using soft-label driven self-supervised loss. Through joint supervision of global positive sample, local negative sample and global negative sample features, memory consumption is reduced and training efficiency is improved.

Benefits of technology

Achieving high-precision detection with few defect samples reduces training costs, improves the model's generalization and anti-interference capabilities, and enhances detection performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121746772A_ABST
    Figure CN121746772A_ABST
Patent Text Reader

Abstract

The invention belongs to the related technical field of image processing, and discloses a soft label driven anomaly detection model construction method, a composite self-supervision anomaly detection method and a composite self-supervision anomaly detection system.The method comprises the steps that (1) a defect simulator is adopted to simulate defects on a normal sample image to obtain a simulated anomaly image, the frozen Wide ResNet V2 backbone network is used for extracting the multi-scale features of the normal image and simulating the multi-scale features of the abnormal image; (2) adopting a multi-scale window feature aggregator to aggregate the normal image multi-scale features and the simulated abnormal image multi-scale features into a single layer in channel dimensions, namely global positive sample features and local negative sample features, so as to obtain global negative sample features; and (3) performing weighted sum on the self-supervision loss driven by the soft labels corresponding to the three features to obtain a total loss function, and optimizing parameters of the discriminator based on the total loss function to obtain an anomaly detection model. According to the invention, the anomaly detection precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing technology, and more specifically, relates to a method for constructing a soft-label driven anomaly detection model, a composite self-supervised anomaly detection method and system. Background Technology

[0002] In the industrial manufacturing sector, product quality is a core competitive advantage for enterprises. To ensure that the quality of products leaving the factory meets certain standards, full inspection or high-throughput sampling inspection of product defects caused by the complexity of production line processes has become an essential step. This prevents defective products from entering the market, thereby ensuring the yield rate of the production line. Among these technologies, vision-based automated optical inspection is widely used in modern industry, including circuit boards, electronic components, precision manufacturing, and pharmaceuticals.

[0003] Automatic Optical Inspection (AOI) is a non-contact, non-destructive testing technology with advantages such as high speed and high accuracy, and is therefore widely used in industrial product inspection. The theoretical basis of AOI technology is machine vision, and it mainly includes four steps: image acquisition, Region of Interest (ROI) selection, algorithm processing, and post-processing. Among these, the algorithm processing stage primarily affects the detection accuracy.

[0004] Anomaly detection algorithms are a class of efficient defect detection and localization algorithms. They possess class-independent properties, addressing the challenges of uncertain defect types and the difficulty of defining all defect types at once in real-world industrial production lines. Furthermore, they do not require extensive training with numerous defect samples, effectively alleviating the pressure of collecting large numbers of defect samples in actual industrial production lines. Therefore, they are used for defect location localization and evaluating the corresponding anomaly scores, such as detecting misplaced or missing components on PCBA products and detecting screen defects. Typical anomaly detection methods in industrial scenarios mainly include unsupervised and self-supervised methods.

[0005] Unsupervised methods typically rely on high-quality feature embeddings. During the training phase, the model is guided to learn the feature distribution of normal samples. During the inference phase, anomaly scores are obtained by calculating the distance between the features of the test sample and the features of normal samples. This approach usually has short training time and high interpretability, but it is highly dependent on the quality of normal samples, requires high alignment of normal samples, and typically needs to store a large amount of normal sample feature data, resulting in high memory requirements and difficulty in optimizing inference speed.

[0006] Self-supervised methods typically employ anomaly simulation to disrupt normal samples, obtaining labeled simulated anomalous samples as supervisory signals to train the discriminative model. Existing methods often use two-dimensional Berlin noise masks and random textures to generate anomalous features with sharp edges, using hard-labeled masks as supervisory targets. This approach generally offers better generalization, is more lenient in its requirements for sample alignment, and has a simple and direct training process. However, simulated samples still differ somewhat from real samples, and overly rigid supervisory labels can lead to unstable parameter optimization, slow training convergence, or even failure to converge.

[0007] To address the aforementioned issues, a novel anomaly detection method for practical industrial scenarios needs to be proposed, reducing memory consumption, improving inference speed, and exhibiting generalization capabilities to enhance training efficiency. To address the significant discrepancy between simulated anomalies and real defects, a high-quality anomaly simulation method is required to improve the model's detection performance when dealing with unknown real defects. Furthermore, to address the instability in parameter optimization caused by hard labels, a more reasonable supervised signal processing method needs to be designed to prevent model overconfidence and improve its robustness against interference. Summary of the Invention

[0008] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides a method for constructing a soft label-driven anomaly detection model, a composite self-supervised anomaly detection method and system, which aims to solve the problem of low detection accuracy caused by the lack of defect samples in the existing methods.

[0009] To achieve the above objectives, according to one aspect of the present invention, a method for constructing a soft-label-driven anomaly detection model is provided, comprising the following steps: (1) A defect simulator based on Bézier curves is used to simulate defects on the collected normal sample images to obtain simulated abnormal images. The frozen Wide ResNet V2 backbone network is used to extract the normal image multi-scale features and simulated abnormal image multi-scale features of the normal sample images and simulated abnormal images. (2) A multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and the multi-scale features of simulated abnormal images into a single layer in the channel dimension, namely global positive sample features and local negative sample features. A noise generator is used to superimpose noise on the aggregated global normal features to obtain global negative sample features. (3) The self-supervised loss driven by soft labels corresponding to the global positive sample features, local negative sample features and global negative sample features are weighted and summed to obtain the total loss function. The parameters of the discriminator are optimized based on the total loss function to obtain the anomaly detection model. The anomaly detection model includes the defect simulator, the WideResNet V2 backbone network, the multi-scale window feature aggregator, the discriminator and the noise generator.

[0010] Furthermore, the defect simulator uses a distance-aware white-warmth smoothing method to overlay random textures onto normal sample images to obtain simulated abnormal images, the corresponding formula being:

[0011]

[0012] In the formula, Represents a point inside the curve The minimum distance to the mask outline. For temperature coefficient, For a smooth mask, This represents a texture image.

[0013] Furthermore, a multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and simulated abnormal images into a single layer along the channel dimension, with the corresponding formula being:

[0014] In the formula, This indicates an adaptive average pooling operation. For input features, This is the output feature dimension.

[0015] Furthermore, during training, the noise generator superimposes Gaussian noise onto global positive samples, transforming them into global negative sample features. The corresponding formula is:

[0016] In the formula, The standard deviation is expressed as Gaussian noise.

[0017] Furthermore, for global negative sample feature points or local negative sample feature points, soft labels are assigned to them based on their maximum similarity to all positive sample features:

[0018]

[0019] in Represents the feature points of the simulated sample. Indicates positive sample features. Indicates the scaling factor for soft tags. For temperature coefficient, This represents the similarity score between the features of the simulated sample and the features of the positive sample. This represents the ground truth label corresponding to the features of the simulated sample. This represents the calculated soft tag.

[0020] Furthermore, a soft-label-driven self-supervised loss is used to optimize the discriminator parameters. This self-supervised loss consists of three parts: global positive sample loss, global negative sample loss, and local negative sample loss. The global positive sample loss is the binary cross-entropy loss between the feature output score and the positive sample label; the global negative sample loss and the local negative sample loss are the binary cross-entropy losses between the feature output score and the corresponding soft label. The total loss function is:

[0021] in Weights are assigned to local negative samples for loss. The loss is for global positive samples; The loss is the global negative sample loss. This is the loss for local negative samples.

[0022] Furthermore, the discriminator is composed of a multilayer perceptron consisting of three linear layers, wherein the normalization layer uses one-dimensional Batch Normalization, the activation function uses Leaky ReLU, the input is aggregated image features with a downsampling size of 4, and the output is a score heatmap.

[0023] The present invention also provides a composite self-supervised anomaly detection method, wherein the detection method uses an anomaly detection model constructed by the soft tag-driven anomaly detection model construction method described above to perform anomaly detection on the product under test.

[0024] The present invention also provides a system for constructing a soft-label-driven anomaly detection model. The system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the soft-label-driven anomaly detection model construction method as described above.

[0025] The present invention also provides a computer-readable storage medium storing machine-executable instructions, which, when called and executed by a processor, cause the processor to implement the soft-label-driven anomaly detection model construction method described above or the composite self-supervised anomaly detection method described above.

[0026] In summary, compared with the prior art, the method for constructing a soft-label-driven anomaly detection model, the composite self-supervised anomaly detection method, and the system provided by this invention have the following advantages: 1. This invention employs a defect simulator based on Bézier curves, which can simulate defects by generating masks and smoothing edges using Bézier curves. It can quickly simulate a large number of local defect images, solving the problems of low detection accuracy, high annotation costs, and weak generalization ability caused by the scarcity of defect samples in industrial quality inspection scenarios. Simultaneously, by adding Gaussian noise to normal features, it quickly simulates global anomaly features. Through training an anomaly detection model using a network that jointly supervises local and global anomalies, the model learns how to distinguish between normal and anomaly features, improving the model's defect detection accuracy.

[0027] 2. This invention employs a soft-label-driven self-supervised loss, dynamically processing label strength through feature similarity measurement to prevent overconfidence during model training, reduce interference from potential low-quality simulation defects, and minimize overfitting and training instability.

[0028] 3. This invention employs a multi-scale window feature aggregator that does not require training and a lightweight anomaly discriminator, which improves feature representation ability, reduces the risk of overfitting, and improves the inference efficiency of the model while reducing the number of parameters.

[0029] 4. This invention employs a simple and efficient anomaly detection network framework, achieving high-precision industrial defect detection without the need for real defect samples. The model has high running efficiency, is easy to train, and has strong generalization ability. It solves the problem of difficulty in collecting defect samples for model training in real industrial scenarios, reduces the requirements for sample alignment quality, and thus improves detection accuracy. Attached Figure Description

[0030] Figure 1 This is a flowchart of the workflow of the anomaly detection model constructed by the soft tag-driven anomaly detection model construction method provided in this embodiment of the invention. Figure 2 This is a schematic diagram of a defect simulator based on Bézier curves constructed according to an embodiment of the present invention; Figure 3 This is a schematic diagram of a similarity soft tagging strategy constructed according to an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the detection performance of the algorithm involved in this embodiment of the invention on the MVTEC dataset; Figure 5 This is a schematic diagram illustrating the application effect of the algorithm involved in the embodiments of the present invention on a real PCBA production line. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.

[0032] This invention provides a method for constructing a soft-label-driven anomaly detection model, which can quickly train a high-precision anomaly detection model even with scarce training data, reducing training costs and effectively addressing the problem of low detection accuracy caused by scarce training samples in industrial scenarios. Simultaneously, this invention solves the problems of scarce defect samples, high annotation costs, weak generalization ability, and overfitting in industrial quality inspection scenarios. Compared with existing anomaly detection methods, it exhibits superior generalization, reduces the requirements for training data quality, and improves the model's detection performance when dealing with unknown real-world defects.

[0033] The construction method mainly includes the following steps: Step 1: Collect normal sample images and texture images as the training dataset and auxiliary dataset, respectively.

[0034] Step 2: A defect simulator based on Bézier curves is used to simulate defects on the acquired normal sample images to obtain simulated abnormal images. Then, the frozen Wide ResNet V2 backbone network is used to extract the multi-scale features of the normal sample images and the multi-scale features of the simulated abnormal images.

[0035] The defect simulator can generate a binary mask with the same size as the image input. The shape of the binary mask is controlled by a third-order Bézier curve, and the corresponding formula is:

[0036] In the formula, These are Bernstein basis functions. These are control points. Specifically, a series of initial data points are first randomly generated on the image. For a line segment formed by two adjacent points Calculate its midpoint It dynamically calculates the segmentation ratio to generate segmentation points. :

[0037]

[0038]

[0039] Translate the dividing line segment to the current vertex. And calculate additional control points. :

[0040]

[0041]

[0042] After generating control points, for each quadruple Calculate the third-order Bézier curve and fill the region enveloped by the obtained curve with a mask:

[0043]

[0044] in For the Bézier curve The enclosed area It is an indicator function.

[0045] The defect simulator uses a distance-aware white-warm smoothing method to overlay random textures onto normal sample images to obtain simulated anomalous images. The corresponding formula is:

[0046]

[0047] In the formula, Represents a point inside the curve The minimum distance to the mask outline. For temperature coefficient, For a smooth mask, This represents a texture image.

[0048] Step 3: A multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and the multi-scale features of simulated abnormal images into a single layer in the channel dimension, namely global positive sample features and local negative sample features. Then, a noise generator is used to superimpose noise on the aggregated global normal features to obtain global negative sample features.

[0049] A multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and simulated abnormal images into a single layer along the channel dimension, respectively. The corresponding formula is:

[0050] In the formula, This indicates an adaptive average pooling operation. For input features, This is the output feature dimension.

[0051] During training, the noise generator adds Gaussian noise to all positive samples to transform them into global negative sample features. The corresponding formula is:

[0052] In the formula, The standard deviation is expressed as Gaussian noise.

[0053] Step four: The self-supervised losses driven by soft labels corresponding to the global positive sample features, local negative sample features, and global negative sample features are weighted and summed to obtain the total loss function. The parameters of the discriminator are optimized based on the total loss function to obtain the anomaly detection model. The anomaly detection model includes the defect simulator, the Wide ResNet V2 backbone network, the multi-scale window feature aggregator, the discriminator, and the noise generator.

[0054] The discriminator consists of a multilayer perceptron with three linear layers, where the normalization layer uses one-dimensional Batch Normalization, the activation function uses Leaky ReLU, the input is aggregated image features with a downsampling size of 4, and the output is a score heatmap.

[0055] The discriminator uses the Sigmoid function to map the output features of the multilayer perceptron into a score heatmap, and uses bilinear interpolation to enlarge the output to the original image size. The heatmap is then smoothed using a Gaussian filter with a standard deviation of 4. A certain segmentation threshold is set to segment the score heatmap into a binary mask, which is used to indicate the location of defects.

[0056] In this implementation, a similarity-based soft-labeling strategy is used to process training labels. For simulated sample feature points (i.e., global negative sample feature points or local negative sample feature points), soft labels are assigned based on their maximum similarity to all positive sample features:

[0057]

[0058] in Represents the feature points of the simulated sample. Indicates positive sample features. Indicates the scaling factor for soft tags. For temperature coefficient, This represents the similarity score between the features of the simulated sample and the features of the positive sample. This represents the ground truth label corresponding to the features of the simulated sample. This represents the calculated soft tag.

[0059] The discriminator parameters are optimized using a soft-label-driven self-supervised loss, which consists of three parts: global positive sample loss, global negative sample loss, and local negative sample loss, corresponding to the three types of features mentioned above. Specifically, the global positive sample loss is the binary cross-entropy loss between the feature output score and the positive sample label (i.e., the 0 label); the global negative sample loss and the local negative sample loss are the binary cross-entropy losses between the feature output score and the corresponding soft label. The final loss function is a weighted sum of the three:

[0060] in The weights are for the loss of local negative samples.

[0061] The present invention will be further described in detail below with reference to a specific embodiment.

[0062] The present invention provides a soft-label-driven composite self-supervised anomaly detection method comprising two stages: model training and online inference. Figure 1 As shown, the network exhibits multi-branch joint supervision during the training phase, while it merges into a single branch during the testing phase, resulting in lightweight design and high detection efficiency.

[0063] 1. Model Training Phase This stage trains the model on normal (defect-free) samples, enabling it to learn how to distinguish between positive and negative samples, thus acquiring the ability to detect defects. The specific steps are as follows: S101: Data Preparation Obtain defect-free image samples of products to be inspected in industrial settings as a training dataset. Simultaneously, a texture image dataset for defect simulation was acquired. .

[0064] This invention provides an efficient defect simulation method that simulates diverse product defects in industrial scenarios by overlaying texture samples onto normal samples. The process is as follows: Figure 2 As shown, specifically: (1) Mask generation A binary defect mask with a random shape is generated using a Bézier curve-based mask generator. First, a series of initial data points are randomly generated on the image. For a line segment formed by two adjacent points Calculate its midpoint It dynamically calculates the segmentation ratio to generate segmentation points. :

[0065]

[0066]

[0067] Translate the dividing line segment to the current vertex. And calculate additional control points. :

[0068]

[0069]

[0070] After generating control points, for each quadruple Calculate the third-order Bézier curve and fill the region enveloped by the obtained curve with a mask:

[0071]

[0072] in For the Bézier curve The enclosed area It is an indicator function.

[0073] (2) Texture overlay Randomly from the training dataset Extract a positive sample image from the middle The Segment Anything model is used to obtain the foreground region (i.e., the effective industrial product region) mask. A seed point is selected from the foreground region mask, and the center of the outer rectangle of the defect mask is translated to the seed point by translation and scaling, ensuring that the long side of the outer rectangle of the defect mask does not exceed half the long side of the foreground mask.

[0074] A distance-aware edge smoothing method is used to process the defect mask to prevent the simulated defects from being too harsh. This process can be represented as follows:

[0075] in Represents a point inside the curve The minimum distance to the mask outline. For temperature coefficient, For smoothing masking.

[0076] Randomly selected from texture image datasets Get a texture image By using image weighting, the texture is superimposed onto the corresponding position of the defect mask to obtain a simulated defect image. :

[0077] By repeatedly repeating processes (1) and (2) above, a batch of simulated defect datasets can be obtained. .

[0078] S102: Feature-level processing (1) Feature extraction training dataset and simulated defect dataset Divide into mini-batches. For each positive sample image in each batch... and simulated negative sample images A pre-trained Wide ResNet V2 backbone network was used as the feature extractor to extract features from layers 1, 2, and 3 (i.e., downsampled features by 4, 8, and 16 times, respectively). The pre-trained Wide ResNet V2 model possesses a certain ability to handle unknown data, providing high-quality multi-scale semantic information for feature discrimination. The Wide ResNet V2 model was frozen throughout the training phase and set to Eval mode to prevent parameter updates from corrupting high-quality features.

[0079] (2) Feature fusion The multi-scale features extracted by WideResNet V2 exhibit a clear hierarchical structure. Features closer to the bottom layer tend to contain fine-grained information (such as texture, color, and shape), while features closer to the top layer tend to contain global semantic information (such as abstract concepts like category). Typical multi-scale feature aggregation modules require layer-by-layer top-down and bottom-up fusion, introducing a large number of trainable parameters. This can easily lead to overfitting in anomaly detection tasks, resulting in a significant drop in model accuracy. To ensure the stability of the fused features, this invention proposes a training-free window feature aggregator that aggregates the multi-scale features output from the WideResNet V2 backbone network into single-scale features.

[0080] Specifically, for each feature layer, a 3×3 sliding window is used to expand each feature point and its eight neighboring features, and these features are cascaded along the channel dimension. Adaptive average pooling is then used to compress the channels to a specified dimension. The spatial scale of the processed three-layer features is aligned to a 4x downsampling using bilinear interpolation, and then summed to obtain the aggregated single-layer features. This process can be represented as:

[0081] in This indicates an adaptive average pooling operation. For input features, This is the output feature dimension.

[0082] (3) Noise superposition Besides simulating defects at the image level, superimposing Gaussian noise on positive sample features can also simulate feature-level defects (i.e., global negative sample features), thereby supervising model training. This process can be represented as:

[0083] in The standard deviation is expressed as Gaussian noise in practical applications .

[0084] S103: Feature discrimination Global positive sample features, global negative sample features, and local negative sample features are input into the lightweight anomaly discriminator to jointly supervise its training. The discriminator consists of a three-layer linear perceptron, where the normalization layer uses one-dimensional batch normalization and the activation function is Leaky ReLU. For a feature input downsampled by 4 times, the discriminator's multilayer perceptron outputs a single-channel feature downsampled by 4 times, which is then mapped to a score heatmap using a sigmoid function.

[0085] S104: Loss Calculation and Parameter Update This method uses a similarity-based soft-labeling strategy to process training labels. For example... Figure 3 As shown, for simulated sample feature points (i.e., global negative sample feature points or local negative sample feature points), soft labels are assigned to them based on their maximum similarity to all positive sample features:

[0086]

[0087] in Represents the feature points of the simulated sample. Indicates positive sample features. Indicates the scaling factor for soft tags. For temperature coefficient, This represents the similarity score between the features of the simulated sample and the features of the positive sample. This represents the ground truth label corresponding to the features of the simulated sample. This represents the calculated soft tag.

[0088] The loss function is calculated for the three features obtained in S103. The global positive sample loss is the binary cross-entropy loss between the feature output score and the positive sample label (i.e., the 0 label); the global negative sample loss and the local negative sample loss are the binary cross-entropy losses between the feature output score and the corresponding soft label. The final loss function is the weighted sum of the three:

[0089] in The weights are for the loss of local negative samples.

[0090] During training, the Wide ResNet V2 backbone network is frozen, and the discriminator parameters are updated only through backpropagation. The AdamW optimizer is used during training, and the network is trained to the preset number of iterations.

[0091] 2. Online Reasoning Stage In this stage, the trained model will be applied to real-world industrial quality inspection scenarios.

[0092] S201: Forward Propagation Image to be detected Input the model. The model sequentially passes through a Wide ResNet V2 backbone network, a multi-scale window feature aggregator, and a lightweight anomaly discriminator to obtain a feature anomaly score heatmap.

[0093] S202: Post-processing The score heatmap is scaled to the original image size using bilinear interpolation and then smoothed using a Gaussian filter with a standard deviation of 4. A segmentation threshold is set to adjust the heatmap... Figure 2 The value is converted into a segmentation mask, and the position indicated by the segmentation mask is the defect location identified by the model.

[0094] The test results using the detection method provided in this embodiment on the publicly available industrial product quality inspection dataset MVTec are as follows: Figure 4 As shown, the method exhibits excellent detection performance across multiple product categories in the MVTec dataset, with clear heatmaps and high overlap between the segmentation mask and the ground truth.

[0095] The testing method provided in this embodiment demonstrates the following testing results for PCBA products in an actual PCB production line: Figure 5 As shown, the method, even when trained using only normal sample data, maintains good detection performance for PCBA products with complex backgrounds. It can clearly identify defects such as missing components, scratches, dirt, and incorrect component orientation in the product. This proves that the model can effectively solve the problem of low detection accuracy caused by the scarcity of defect samples in industrial scenarios, and can efficiently screen defective products, ensure the yield rate of the production line, and improve production efficiency and stability.

[0096] The present invention also provides a composite self-supervised anomaly detection method, wherein the detection method uses an anomaly detection model constructed by the soft tag-driven anomaly detection model construction method described above to perform anomaly detection on the product under test.

[0097] The present invention also provides a system for constructing a soft-label-driven anomaly detection model. The system includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the soft-label-driven anomaly detection model construction method as described above.

[0098] The present invention also provides a computer-readable storage medium storing machine-executable instructions, which, when called and executed by a processor, cause the processor to implement the soft-label-driven anomaly detection model construction method or the composite self-supervised anomaly detection method as described above.

[0099] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for constructing a soft-label-driven anomaly detection model, characterized in that, The steps are as follows: (1) A defect simulator based on Bézier curves is used to simulate defects on the collected normal sample images to obtain simulated abnormal images. The frozen Wide ResNet V2 backbone network is used to extract the normal image multi-scale features and simulated abnormal image multi-scale features of the normal sample images and simulated abnormal images. (2) A multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and the multi-scale features of simulated abnormal images into a single layer in the channel dimension, namely global positive sample features and local negative sample features. A noise generator is used to superimpose noise on the aggregated global normal features to obtain global negative sample features. (3) The self-supervised loss driven by soft labels corresponding to the global positive sample features, local negative sample features and global negative sample features are weighted and summed to obtain the total loss function. The parameters of the discriminator are optimized based on the total loss function to obtain the anomaly detection model. The anomaly detection model includes the defect simulator, the WideResNet V2 backbone network, the multi-scale window feature aggregator, the discriminator and the noise generator.

2. The method for constructing a soft-tag-driven anomaly detection model as described in claim 1, characterized in that: The defect simulator uses a distance-aware white-warm smoothing method to overlay random textures onto normal sample images to obtain simulated anomalous images. The corresponding formula is: In the formula, Represents a point inside the curve The minimum distance to the mask outline. For temperature coefficient, For a smooth mask, This represents a texture image.

3. The method for constructing a soft-tag-driven anomaly detection model as described in claim 1, characterized in that: A multi-scale window feature aggregator is used to aggregate the multi-scale features of normal images and simulated abnormal images into a single layer along the channel dimension, respectively. The corresponding formula is: In the formula, This indicates an adaptive average pooling operation. For input features, This is the output feature dimension.

4. The method for constructing a soft-tag-driven anomaly detection model as described in claim 1, characterized in that: During training, the noise generator adds Gaussian noise to all positive samples to transform them into global negative sample features. The corresponding formula is: In the formula, The standard deviation is expressed as Gaussian noise.

5. The method for constructing a soft-tag-driven anomaly detection model as described in claim 1, characterized in that: For global negative sample feature points or local negative sample feature points, assign soft labels based on their maximum similarity to all positive sample features: in Represents the feature points of the simulated sample. Indicates positive sample features. Indicates the scaling factor for soft tags. For temperature coefficient, This represents the similarity score between the features of the simulated sample and the features of the positive sample. This represents the ground truth label corresponding to the features of the simulated sample. This represents the calculated soft tag.

6. The method for constructing a soft-tag-driven anomaly detection model as described in claim 1, characterized in that: The discriminator parameters are optimized using a soft-label-driven self-supervised loss, which consists of three parts: global positive sample loss, global negative sample loss, and local negative sample loss. The global positive sample loss is the binary cross-entropy loss between the feature output score and the positive sample label; the global negative sample loss and the local negative sample loss are the binary cross-entropy losses between the feature output score and the corresponding soft label. The total loss function is: in Weights are assigned to local negative samples for loss. The loss is for global positive samples; The loss is the global negative sample loss. This is the loss for local negative samples.

7. The method for constructing a soft-label-driven anomaly detection model as described in any one of claims 1-6, characterized in that: The discriminator consists of a multilayer perceptron with three linear layers, where the normalization layer uses one-dimensional BatchNormalization, the activation function uses Leaky ReLU, the input is aggregated image features with a downsampling size of 4, and the output is a score heatmap.

8. A composite self-supervised anomaly detection method, characterized in that: The detection method described herein uses an anomaly detection model constructed by the method of constructing a soft tag-driven anomaly detection model according to any one of claims 1-7 to perform anomaly detection on the product under test.

9. A system for constructing a soft-label-driven anomaly detection model, characterized in that: The system includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it performs the method for constructing the soft tag-driven anomaly detection model according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for constructing the soft-label-driven anomaly detection model according to any one of claims 1-7 or the composite self-supervised anomaly detection method according to claim 8.