Industrial image anomaly detection method and device and storage medium
By constructing a detection model with a multi-scale spatial-channel refinement module and a memory enhancement module, the problems of generalization of reconstruction models and feature bias in industrial image anomaly detection are solved, and efficient detection and localization of small targets and complex defects are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING UNIV
- Filing Date
- 2026-01-14
- Publication Date
- 2026-05-08
AI Technical Summary
Existing industrial image anomaly detection technologies suffer from problems such as overgeneralization of reconstruction models, large bias in pre-trained feature domains, and insufficient realism of synthetic anomalies, resulting in low accuracy and low training efficiency for small target detection.
A detection model is constructed, which combines an autoencoder reconstruction network with a discriminant network. Through the multi-scale spatial-channel refinement module MSCR and the memory enhancement module, realistic anomaly images are generated and accurately located.
It significantly improves the detection accuracy and localization capability of complex defects, enhances the model's ability to distinguish anomalies in small targets, reduces training computational overhead, and enhances training efficiency.
Smart Images

Figure CN121998923A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and deep learning technology, and relates to quality control technology in industrial intelligent manufacturing, specifically an industrial image anomaly detection method, device and storage medium. Background Technology
[0002] With the development of intelligent manufacturing, machine vision-based industrial image anomaly detection has become a key technology for ensuring product quality. In real-world industrial scenarios, anomaly samples (defective products) are typically extremely scarce and diverse, making it difficult for traditional supervised learning methods to obtain sufficient training data. Therefore, unsupervised anomaly detection methods that utilize only normal samples for training have become the mainstream research direction.
[0003] Currently, mainstream unsupervised methods are mainly divided into reconstruction-based methods and feature embedding-based methods, but both have limitations:
[0004] First, reconstruction-based methods, such as autoencoders, assume that the model cannot reconstruct unseen anomalous regions. However, deep neural networks often have excessively strong generalization capabilities, leading to good reconstruction of anomalous regions—a problem known as the "identity mapping"—which results in missed detections. Furthermore, simple pixel-level reconstruction errors are insufficient to capture complex structural defects.
[0005] Second, feature embedding-based methods rely on networks pre-trained on natural image datasets such as ImageNet to extract features. Since industrial images differ significantly from natural images in distribution, directly using pre-trained features introduces domain bias.
[0006] In addition, existing technologies have also studied methods for synthesizing anomalies, attempting to train discriminative models by generating simulated defects. However, existing synthesis methods, such as those using Perlin noise, produce anomaly shapes that are not natural enough, have many directional artifacts, and incur high computational costs, resulting in insufficiently compact decision boundaries learned by the model and inadequate detection capabilities for small target anomalies such as minor scratches.
[0007] Therefore, designing an anomaly detection method that can efficiently synthesize realistic anomalies, effectively combine the advantages of reconstruction and discrimination, and accurately locate multi-scale defects is a technical challenge that urgently needs to be solved. Summary of the Invention
[0008] The problem this invention aims to solve is: addressing the issues of low accuracy and low training efficiency in small target detection caused by overgeneralization of reconstruction models, large bias in pre-trained feature domains, and insufficient realism of synthetic anomalies in existing industrial image anomaly detection technologies. This invention proposes an anomaly detection method that combines the advantages of synthetic anomalies and reconstruction discrimination to accurately locate multi-scale defects.
[0009] The technical solution of this invention is: an industrial image anomaly detection method, which constructs a detection model for anomaly detection in industrial scene images. The construction of the detection model includes the following steps:
[0010] Step 1: Obtain normal images of products in industrial production scenarios and synthesize them with random noise images to generate simulated abnormal images;
[0011] Step 2: Use an autoencoder as a reconstruction network to reconstruct the simulated anomalous image to obtain the reconstructed image;
[0012] Step 3: The simulated anomaly image and the reconstructed image are concatenated along the channel dimension and input into the discriminant network branch. The discriminant network adopts a multi-level architecture based on U-net, replacing each skip connection of U-net with a multi-scale spatial-channel refinement module (MSCR). The multi-scale feature map output by the encoder is fused through the multi-scale spatial-channel refinement module (MSCR) and then input into the decoder of the corresponding layer to output the segmentation result of the anomaly.
[0013] The Multi-Scale Spatial-Channel Refining Module (MSCR) performs the following steps:
[0014] Step 3.1: Feature Fusion: Receive the feature maps of the current layer and adjacent layers from the encoder output, and stitch them together after unifying the resolution by upsampling or downsampling to form the initial fused features. Then, use 1×1 convolution to reduce the channel dimension.
[0015] Step 3.2: Spatial Path: For the dimensionality reduction features from Step 3.1, convolution operations are performed in parallel using three different sizes of convolution kernels: 3×3, 5×5, and 7×7. The results of the convolution operations are summed to fuse multi-scale spatial features. Then, through a spatial attention mechanism, the summed results are aggregated using mean pooling and max pooling to generate spatial attention weights to weight the features.
[0016] Step 3.3: Channel Path: Perform global average pooling and global max pooling operations on the dimensionality-reduced features from Step 3.1, generate channel attention weights through MLP, obtain channel attention graphs, and model the dependencies between channels;
[0017] Step 3.4: Add or fuse the features processed by the spatial path and the channel path element by element, and adjust them to the target number of channels through 1×1 convolution. Then, output the enhanced feature map and send it to the decoder corresponding to the current layer.
[0018] Step 4: The discriminant network outputs a pixel-level anomaly segmentation map. At the same time, local average pooling is first performed on the anomaly segmentation map to smooth the noise, and then the global maximum value is taken as the image-level anomaly score.
[0019] Step 5: Train the network end-to-end to obtain the detection model, input the product image to be detected for anomaly detection, locate the anomaly using the anomaly segmentation map, and determine the anomaly level using the anomaly score.
[0020] The present invention also provides a computer-readable storage medium storing at least one instruction or at least one program, wherein when the at least one instruction or at least one program is executed, the above-described industrial image anomaly detection method is implemented.
[0021] This invention can be widely applied to the detection of surface defects in products on industrial production lines, such as the automatic identification and location of abnormalities like scratches, cracks, stains, and structural defects. Through multi-scale spatial-channel refinement and memory enhancement mechanisms, this invention significantly improves the model's detection accuracy and location capability for various complex defects, offering the following advantages compared to existing technologies:
[0022] First, this invention proposes a multi-scale spatial-channel refinement module (MSCR). This module, through parallel multi-scale convolution and a dual attention mechanism (spatial + channel), not only captures the global contextual information of the image but also significantly enhances the ability to discriminate small target anomalies such as subtle scratches and complex defect boundaries. Compared to traditional U-net skip connections, MSCR effectively solves the semantic gap problem in feature fusion, balancing the different receptive fields required for detecting both minute flaws and macroscopic structural defects that may exist simultaneously in industrial product anomaly detection.
[0023] Second, the present invention introduces a memory enhancement module into the reconstruction network. The memory module forces the model to use the stored normal prototype to reconstruct the image, which effectively suppresses the model's overgeneralization of abnormal regions, that is, prevents the model from failing to "repair" abnormal regions, thereby producing a significant difference between the original image and the reconstructed image, which is convenient for subsequent discrimination.
[0024] Third, the present invention further designs a memory consistency loss function in the memory enhancement module to constrain the prediction behavior of the model in normal and abnormal regions respectively, so that the model produces low abnormal scores on normal samples and high abnormal scores on abnormal samples, thereby enhancing the sensitivity of the memory enhancement module to abnormalities during training.
[0025] Fourth, this invention uses a Simplex noise generator instead of traditional Perlin noise. The anomaly shapes generated by Simplex noise are visually more natural and smoother, reducing directional artifacts and making the synthesized anomalies closer to real industrial defects. At the same time, Simplex noise improves generation efficiency by approximately 39.3% compared to Perlin noise, while reducing memory usage by 14%, significantly improving model training efficiency and making it more suitable for industrial engineering applications. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the overall process of the present invention.
[0027] Figure 2 This is a schematic diagram of the overall network architecture of the present invention.
[0028] Figure 3 This is a schematic diagram of the discrimination network structure of the present invention.
[0029] Figure 4 This is a schematic diagram of the structure of the Multi-Scale Space-Channel Refining Module (MSCR) of the present invention.
[0030] Figure 5 This is a schematic diagram illustrating the process of synthesizing simulated abnormal images using the Simplex noise generator of the present invention. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] like Figure 1 and Figure 2 As shown, this embodiment provides an industrial image anomaly detection method. This method runs on an electronic device with image processing capabilities, such as an industrial control computer or server equipped with a GPU. The method specifically includes the following steps:
[0033] Step 1: Data Acquisition and Simulated Anomaly Synthesis. Acquire images of the industrial product to be detected. Due to the scarcity of abnormal samples, this invention employs a self-supervised learning strategy during the training phase. Acquire a normal image A of the product in an industrial production scenario, and synthesize it with a random noise image to generate a simulated abnormal image. In this embodiment, a Simplex noise generator is used to generate a random noise image to synthesize the simulated abnormal image. The specific process is as follows: Figure 5 As shown: Create a Simplex random noise image N, and generate an anomaly mask by random thresholding binarization. The white areas represent anomalies. Compared to Perlin noise, Simplex noise has lower computational complexity, requiring only 3 multiplications per pixel in 2D, while Perlin noise requires 4. It also generates more isotropic shapes with no obvious directional artifacts. Anomaly texture sources D are randomly sampled from a texture dataset (such as DTD) and randomly enhanced. The mixture is then uniformly sampled within the range [0.1, 1] using a semi-transparency parameter β to generate the final simulated anomaly image. .
[0034] Step 2: Reconstruction Network and Memory Enhancement. The synthesized simulated anomalous image is input into the reconstruction network. The reconstruction network is implemented based on an autoencoder (AE).
[0035] Furthermore, to prevent the reconstruction network model from directly copying anomalous features, this invention designs a memory enhancement module. In this embodiment, the reconstruction network includes an encoder, a memory enhancement module, and a decoder. The encoder extracts image features, and the decoder outputs the reconstructed image. The memory enhancement module introduces a learnable memory bank to learn and refine the features of all normal images in the training set. The encoder extracts normal image features, and the memory enhancement module automatically learns the commonalities among these features through backpropagation, obtaining a set of high-dimensional feature vectors, called normal pattern prototypes. The normal pattern prototypes are the memory terms, which are the "cluster centers" of all normal sample features. The memory enhancement module calculates the cosine similarity between each position vector in the features of the simulated anomalous image extracted by the encoder and all normal pattern prototypes in the memory bank. It obtains the weights through Softmax, and then uses the weighted sum of the memory terms to generate enhanced features, while simultaneously generating an anomalous score map of the latent space. The encoder receives the residual fusion features of the generated enhanced features and the encoder output features. The reconstructed image tends to be restored to a "defect-free" normal state.
[0036] Specifically, the memory enhancement module maintains a learnable memory matrix. Where N is the number of normal pattern prototypes stored, and D is the dimensional feature. First, the feature map... Remodeling This separates spatial location from feature dimension, and then calculates the cosine similarity between the feature vector of each spatial location and all memory terms:
[0037]
[0038] in It is the flattened representation of the spatial dimension of feature map Z; i represents the spatial position index in the feature map, with a value range of [1, H×W]; j represents the memory item index in the memory bank, with a value range of [1, N]. The dimensions are actually B×HW×N, with the last dimension C corresponding to the number of memory items N.
[0039] Next, Softmax is applied along the memory dimension to the similarity matrix constructed from cosine similarity to obtain the attention distribution. This represents the association strength between each position and the memory item. Then, the enhanced features are generated by weighted summation of the memory items.
[0040]
[0041] The output memory-enhanced features are fused with the original encoded features through residual connections and then fed into the decoder.
[0042] Step 3: Feature Concatenation and Input to the Discriminator Network. The simulated anomalous image and the reconstructed image that tends to be normal are concatenated along the channel dimension and used as input to the discriminator network. This design allows the discriminator network to directly compare the differences between the two.
[0043] like Figure 3 As shown, the discriminant network is based on the U-net architecture, but at the connection between the encoder and decoder, this invention uses a multi-scale spatial-channel refinement (MSCR) module instead of a simple skip connection. During feature extraction and fusion, the features are processed by the MSCR module to enhance the ability to discriminate small target anomalies and complex boundaries, resulting in refined features.
[0044] MSCR module structure as follows: Figure 4 As shown, this method aims to solve the challenge of detecting small targets and complex boundaries. MSCR execution steps:
[0045] Step 3.1: Multi-scale fusion: Features from the current layer, the previous layer (downsampling), and the next layer (upsampling) of the encoder are received, concatenated, and then dimensionality reduced by 1×1 convolution. That is, MSCR receives features from the current layer and adjacent layers and performs multi-scale fusion on features from different layers.
[0046] Step 3.2: Spatial Path: The spatial features from the dimensionality-reduced features in Step 3.1 are extracted and summed using convolutional kernels of different sizes (3×3, 5×5, and 7×7) in parallel. The parallel use of these kernels aims to capture local details and contextual information within different receptive fields, enabling the model to focus on both minute scratches (small kernels) and structural defects (large kernels). Subsequently, spatial attention (mean + max pooling) is used to generate a weight map, which weights the spatial features.
[0047] Step 3.3: Channel Path: Global average pooling and max pooling are applied in parallel to the dimensionality-reduced features from Step 3.1. Channel attention weights are generated through MLP to strengthen key feature channels and suppress noisy channels.
[0048] Step 3.4: Output the features of the fusion space and channel paths, add or fuse them element by element, and adjust them to the target number of channels through 1×1 convolution. The enhanced feature map is then sent to the decoder.
[0049] This invention's discriminant network is an improvement on the U-net architecture. The original skip connections in the middle of the U-net are replaced with an MSCR module to refine features at different scales spatially and in channels. The MSCR module is not only a fusion of features from the multi-scale encoder but also a "feature refiner." After feature input, the MSCR first designs parallel spatial paths, using three different sizes of convolutional kernels (3×3, 5×5, and 7×7) to process the same feature simultaneously. This addresses the problem of small scratches (requiring small receptive fields) and large areas of stains / structural defects (requiring large receptive fields) existing simultaneously in industrial defects and being difficult for a single network to capture. Combined with channel path enhancement, the output features, refined through multi-scale fusion, are residually connected to the corresponding layer input and then input to the right-side decoder for concatenation and upsampling to obtain the final segmentation result output by the discriminant network.
[0050] To address the challenge of handling industrial defects with extremely wide scales, ranging from minute surface scratches to large-area structural defects, and the difficulty of capturing features at a single scale, this invention proposes a Multi-Scale Spatial-Channel Refinement (MSCR) module. This module comprises two key components: multi-kernel feature fusion and a dual attention mechanism. The multi-kernel feature fusion part uses convolutional kernels of three different sizes (3×3, 5×5, and 7×7) in parallel to extract features. Smaller kernels focus on minute imperfections (such as pinholes), while larger kernels capture macroscopic structures (such as cracks). This invention uses solid / dense convolutional kernels of different sizes (3×3, 5×5, and 7×7) to ensure dense coverage of subtle textures and prevent the loss of defect information due to sampling gaps. The MSCR module designed in this invention captures features from different receptive fields simultaneously at the same layer, effectively solving the challenge of multi-scale defect detection. Channel attention utilizes global averaging and max pooling to calibrate channel weights and suppress channels that strongly respond to background noise. Spatial attention primarily generates spatial masks based on channel compressed features, focusing on regions with abrupt texture changes. The introduction of the attention mechanism aims to simulate the visual focusing process during manual quality inspection, suppressing interference from background textures and other factors.
[0051] Step 4: Output detection results. The discrimination network outputs pixel-level anomaly segmentation maps, which are then aggregated through operations such as max pooling to obtain image-level anomaly scores. Specifically, local average pooling is first performed on the anomaly segmentation maps to smooth noise, and then the global maximum value is taken as the image-level anomaly score.
[0052] Step 5: Train the network end-to-end to obtain the detection model, input the product image to be detected for anomaly detection, locate the anomaly using the anomaly segmentation map, and determine the anomaly level using the anomaly score.
[0053] As an example, during end-to-end training, reconstruction loss is used. Focal Loss The detection model is trained to obtain the parameters of the reconstruction network and the discriminant network.
[0054] Furthermore, this invention optimizes the loss function based on the memory enhancement module, designing a memory consistency loss function. The detection model is trained using reconstruction loss, focus loss, and the memory consistency loss function. Since the cost of missed detections is usually higher than false detections in industrial scenarios, appropriately increasing the weight of abnormal regions helps force the memory enhancement module to generate significant reconstruction errors in these regions. The memory enhancement module of this invention outputs an anomaly score map of the latent space while performing memory enhancement. , Therefore, a memory consistency loss function is constructed. By separately constraining the prediction behavior in normal and abnormal regions, the model produces low abnormal scores on normal samples and high abnormal scores on abnormal samples. Specifically, the memory consistency loss... for:
[0055]
[0056] Among them, is the weighting coefficient for the loss in the normal region, and This is used to balance the loss contribution between normal and abnormal regions. To reconstruct the outlier score map obtained in the network. ,in For batch size, and For spatial dimensions. The process includes a max operation, which is performed along the memory item dimension. After the max operation, the dimension of E changes from B×HW×C to B×HW. In order to turn it into a "graph" for calculation or visualization with the original image, HW is restored back to H×W, and a channel dimension of 1 is added to correspond to the calculation of the loss function. This is a numerical stability constant to prevent division-by-zero errors. It is also defined as follows: This is the actual anomaly mask, where 0 represents a normal region and 1 represents an anomaly region. From the anomaly mask... The normal area is derived from the middle. and abnormal areas ,in This is an indicator function that returns 1 when the condition is true and 0 otherwise. Here, 0.5 is used as a threshold to binarize the continuous anomaly mask; specifically... The binary mask generated by Simplex noise is used as a supervisory signal to make the judgment. The loss uses the true mask generated by Simplex as supervision, forcing the model to output low scores in normal regions and high scores in abnormal regions, further widening the discrimination distance between normal and abnormal regions.
[0057] Most existing memory networks implicitly update memory terms by minimizing reconstruction errors. The memory consistency loss function designed in this invention provides an explicit supervision mechanism, forcing the model to "pull" normal samples closer to the memory prototype (E→0) and "push" abnormal samples away (E→1) in the feature space. This explicit boundary constraint enhances the sensitivity of the memory enhancement module to anomalies and reduces the confusion of potential features.
[0058] To verify the effectiveness of the method of this invention, experiments were conducted on MVTec AD, a leading dataset in the field of industrial anomaly detection. This dataset contains 15 categories of objects and textures. Experimental results show that the present invention achieves 99.4% AUROC (I-AUROC) for image-level anomaly detection and 98.3% for pixel-level localization AUROC (P-AUROC). Specifically, compared with benchmark models, such as the simple reconstruction network Recon-AE, the performance is improved by about 15% after adding the MSCR module; adding the memory module further improves robustness. In terms of efficiency, using the Simplex noise generator compared to Perlin noise reduces the single generation time from 2.8ms to 1.7ms, an improvement of 39.3%, and reduces memory usage by 14%, while maintaining or even slightly improving detection accuracy by 0.2%, demonstrating its practical engineering value.
[0059] The present invention also provides an electronic device, including a processor (such as a Graphics Processing Unit, GPU), a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the various steps of the industrial image anomaly detection method in Embodiment 1 described above.
[0060] The present invention also provides a computer-readable storage medium, such as a hard disk, an SSD, an optical disk, etc., wherein the storage medium stores computer instructions, which, when executed by a processor, implement the industrial image anomaly detection method in Embodiment 1 above.
[0061] The above description is merely a preferred embodiment of the present invention and does not limit the scope of the patent. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., 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 detecting anomalies in industrial images, characterized in that, A detection model is built for anomaly detection in industrial scene images. The model construction includes the following steps: Step 1: Obtain normal images of products in industrial production scenarios and synthesize them with random noise images to generate simulated abnormal images; Step 2: Use an autoencoder as a reconstruction network to reconstruct the simulated anomalous image to obtain the reconstructed image; Step 3: The simulated anomaly image and the reconstructed image are concatenated along the channel dimension and input into the discriminant network branch. The discriminant network adopts a multi-level architecture based on U-net, replacing each skip connection of U-net with a multi-scale spatial-channel refinement module (MSCR). The multi-scale feature map output by the encoder is fused through the multi-scale spatial-channel refinement module (MSCR) and then input into the decoder of the corresponding layer to output the segmentation result of the anomaly. The Multi-Scale Spatial-Channel Refining Module (MSCR) performs the following steps: Step 3.1: Feature Fusion: Receive the feature maps of the current layer and adjacent layers from the encoder output, and stitch them together after unifying the resolution by upsampling or downsampling to form the initial fused features. Then, use 1×1 convolution to reduce the channel dimension. Step 3.2: Spatial Path: For the dimensionality reduction features from Step 3.1, convolution operations are performed in parallel using three different sizes of convolution kernels: 3×3, 5×5, and 7×7. The results of the convolution operations are summed to fuse multi-scale spatial features. Then, through a spatial attention mechanism, the summed results are aggregated using mean pooling and max pooling to generate spatial attention weights to weight the features. Step 3.3: Channel Path: Perform global average pooling and global max pooling operations on the dimensionality-reduced features from Step 3.1, generate channel attention weights through MLP, obtain channel attention graphs, and model the dependencies between channels; Step 3.4: Add or fuse the features processed by the spatial path and the channel path element by element, and adjust them to the target number of channels through 1×1 convolution. Then, output the enhanced feature map and send it to the decoder corresponding to the current layer. Step 4: The discriminant network outputs a pixel-level anomaly segmentation map. At the same time, local average pooling is first performed on the anomaly segmentation map to smooth the noise, and then the global maximum value is taken as the image-level anomaly score. Step 5: Train the network end-to-end to obtain the detection model, input the product image to be detected for anomaly detection, locate the anomaly using the anomaly segmentation map, and determine the anomaly level using the anomaly score.
2. The industrial image anomaly detection method according to claim 1, characterized in that, In Step 1, a Simplex noise generator is used to generate a random noise image. The process of generating a simulated abnormal image includes: generating a Simplex noise image and performing binarization to obtain an abnormal mask; randomly sampling texture source images from the texture dataset and combining them with the abnormal mask to extract abnormal texture features; and using the semi-transparency parameter to overlay the abnormal texture features onto the original normal image.
3. The industrial image anomaly detection method according to claim 1, characterized in that, In Step 2, a memory enhancement module is set in the reconstruction network. The encoder of the reconstruction network extracts features from the normal image in advance, and the memory enhancement module maintains a learnable memory matrix. The commonalities in the features of normal images are automatically learned through the backpropagation algorithm to obtain normal pattern prototypes. N is the number of normal pattern prototypes stored, and D is the dimensional feature. The memory enhancement module enhances the features Z of the simulated anomalous image using stored normal pattern prototypes. First, it enhances the feature map... Remodeling This separates spatial location from feature dimension. Then, the cosine similarity between the feature vector of each spatial location and all memory terms is calculated. in It is the flattened representation of the spatial dimension of feature map Z; i represents the spatial position index in the feature map, with a value range of [1, H×W]; j represents the memory item index in the memory bank, with a value range of [1, N]; Next, Softmax is applied along the memory dimension to the similarity matrix constructed from cosine similarity to obtain the attention distribution. This represents the association strength between each position and the memory item. Then, the enhanced features are generated by weighted summation of the memory items. The memory-enhanced features are fused with the residual features from the original encoder output, and then reconstructed into a reconstructed image by the decoder.
4. The industrial image anomaly detection method according to claim 3, characterized in that, The memory enhancement module outputs the memory-enhanced features and also outputs an anomaly score map of the latent space. , Step 6 involves constructing a combination of loss functions to perform end-to-end training of the network. This combination includes reconstruction loss, focus loss, and memory consistency loss. The score used to constrain the normal and abnormal regions is defined as follows: Among them, is the weighting coefficient for the loss in the normal region, and This is used to balance the loss contribution between normal and abnormal regions. To reconstruct the anomaly score map obtained in the network, providing a direct supervisory signal for memory consistency loss; This is a numerical stability constant to prevent division by zero errors; it is also defined as follows: This is the true anomaly mask, where 0 represents a normal region and 1 represents an anomaly region. (From the anomaly mask...) The normal area is derived from the middle. and abnormal areas ,in This is an indicator function that returns 1 when the condition is true and 0 otherwise. It uses a threshold of 0.5 to binarize continuous anomaly masks. As a judgment condition, a binary mask generated by random noise is used as a monitoring signal; The constraint on the normal region outputs a low outlier score. The constraint on abnormal regions outputs high abnormality scores, thereby strengthening the model's discrimination boundary between normal and abnormal regions.
5. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the industrial image anomaly detection method according to any one of claims 1-4.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, which, when executed, implements the industrial image anomaly detection method as described in any one of claims 1-4.