Industrial image anomaly detection system based on double-branch prototype residual network
By combining image generation and an improved ResNet-18 network with a multi-scale prototype library and a reversible self-attention module, the problems of sample scarcity and feature decoupling difficulties in industrial visual anomaly detection are solved, achieving high-precision and robust anomaly detection.
Patent Information
- Application Number
- CN202510829992.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-28
AI Technical Summary
Industrial visual anomaly detection faces challenges such as the scarcity and skewed distribution of defect samples, leading to overfitting of supervised models. Furthermore, traditional methods struggle with feature decoupling during fine-grained localization, particularly performing poorly on weakly visually significant defects such as micron-level scratches, texture distortions, and structural deformations.
The data is expanded by using an image-based anomaly generator module, the ResNet-18 network is improved to enhance feature extraction capabilities, and a multi-scale prototype library and a multi-scale reversible self-attention module are introduced to capture local feature deviations caused by anomalies and identify and locate surface defects of objects.
It improves the accuracy and robustness of industrial image anomaly detection, enabling accurate location of abnormal areas in complex environments and enhancing the model's adaptability and real-time performance.
Smart Images

Figure CN120852289A_ABST
Abstract
Description
Technical Field
[0002] This invention belongs to the field of industrial image anomaly detection. It uses an anomaly generator to expand the image database and modifies the ResNet-18 network as a pre-trained network to extract image features. It introduces a multi-scale prototype sample library to improve the accuracy and robustness of anomaly detection. Finally, it uses a multi-scale reversible self-attention module to perform attention calculation, thereby realizing an accurate detection model for precise localization of anomaly regions. Background Technology
[0004] Industrial visual anomaly detection and localization technology has become a core component of intelligent manufacturing systems due to its high efficiency in quality control. However, this field faces a dual dilemma: first, defect samples are inherently scarce and skewed in distribution, making supervised models susceptible to overfitting from a limited number of anomaly instances; second, industrial defects typically exhibit weak visual salience and heterogeneous appearance characteristics, including multimodal forms such as micron-level scratches, texture distortion, and structural deformation, making it difficult for traditional methods to decouple features when localizing at fine granular levels. While existing research attempts to alleviate the lack of samples by synthesizing anomaly data, it generally suffers from problems such as significant deviations between generated defects and the true distribution, and insufficient cross-scale feature coupling. Summary of the Invention
[0006] This invention discloses an industrial image anomaly detection system based on image generation and a dual-branch prototype residual network. The system expands the database based on normal industrial images and then introduces a multi-scale prototype library of normal patterns to help the model recognize the distribution of normal features. A reversible attention mechanism is designed to capture local feature deviations caused by anomalies, thereby identifying and locating surface defect information of objects.
[0007] To achieve the above objectives, the following technical solution is adopted:
[0008] An industrial image anomaly detection system based on image generation and a dual-branch prototype residual network includes an anomaly generator module, an improved ResNet-18 pre-trained network module, a multi-scale prototype sample library module, and a multi-scale reversible self-attention module.
[0009] Anomaly Generator Module: This module generates anomalous images by utilizing the random characteristics of noise. It consists of a Berlin noise submodule, a salt-and-pepper noise submodule, and a fusion strategy submodule. It aims to simulate structural anomalies and minor defects in images, design a foreground classification strategy to confine noise to specific regions, and finally generate different anomalous images randomly through a fusion strategy to expand the training library.
[0010] The Berlin noise submodule generates a Berlin image of the same size as the original image using a Berlin noise generator, and then separates the foreground and background parts through binarization and rotation operations.
[0011] Salt and pepper noise submodule: Uses a salt and pepper noise generator to generate a salt and pepper image the same size as the original image, and performs element-wise multiplication with the separated Berlin image to obtain our noise image.
[0012] The fusion strategy submodule employs two fusion strategies to expand and enhance the anomalous features of images, thereby improving the learning ability of anomalous samples during training and enhancing the robustness of the model.
[0013] The improved ResNet-18 pre-trained network module replaces the original residual blocks with a Bottleneck structure to address the weak feature representation capability of the original network, and introduces grouped convolutions to enhance feature diversity and expressive power. Secondly, it introduces the ACON dynamic activation function, enabling the network to automatically adjust the nonlinear intensity based on depth, enhancing its ability to model features at different levels and mitigating the gradient vanishing problem. Finally, it employs a Stochastic Depth training strategy, randomly discarding residual blocks to improve the network's generalization ability, thereby enhancing the model's adaptability and real-time performance to industrial anomalies. After the input image is processed by the improved ResNet-18 pre-trained network, it undergoes successive convolutions to obtain three feature layers of 64×64×64, 128×32×32, and 256×16×16, respectively. These three feature maps at different scales serve as input data for the multi-scale fusion module.
[0014] Multi-scale fusion module: Three feature maps at different scales serve as input data for the multi-scale fusion module, which uses multi-scale feature blocks to perform multi-scale cross-domain information fusion. The output data is the sum of the transformed representations of the three input feature maps.
[0015] Multi-scale prototype sample library module: By performing multi-scale feature extraction and k-means clustering on normal samples, a prototype set representing normal patterns is constructed and stored as memory units according to spatial regions. During the detection phase, the feature query vector of the input image is matched with the prototype library using cosine similarity. Only normal features with high similarity are extracted to assist in reconstruction, improving the model's sensitivity to abnormal regions.
[0016] Multi-scale reversible self-attention module: This module utilizes transition block sub-modules and reinforcement block sub-modules for block attention computation and residual connections, effectively maintaining the integrity of feature structure and information, and achieving efficient and reversible feature representation. Through a mean-based discrimination mechanism for significant anomalies, it balances pixel-level localization and image-level anomaly estimation, improving overall detection accuracy and stability.
[0017] The process formula for the Berlin noise submodule in the aforementioned industrial image anomaly detection system is as follows:
[0018]
[0019]
[0020] in Represents random coordinates of the image. Indicates the size of the image grid division. This represents the gradient vector. The input image of size H×W is divided into an integer grid, and a randomly generated unit gradient vector is stored at the vertex of each grid. The directions of these gradient vectors are uniformly distributed between 0 and 360 degrees, and the length of each vector is normalized to 1.
[0021]
[0022]
[0023] in This represents the influence weight of each grid point on the current point, reflecting the influence of the gradient direction on the target point. For any given coordinate point, first locate the grid cell containing that point, then determine the four grid vertices surrounding that point. Calculate the relative vectors between these vertices and the target point, and then perform a dot product operation between the gradient vector of each grid vertex and its corresponding relative vector.
[0024]
[0025] in This is the bilinear interpolation function we use. and Interpolation processing is applied to achieve smooth transitions in both the horizontal and vertical directions. This operation eliminates obvious mesh traces, avoids abrupt changes at mesh boundaries, effectively prevents unnatural staircase effects, and ensures that noise remains continuous and natural during the generation process.
[0026] The salt-and-pepper noise submodule of the aforementioned industrial image anomaly detection system operates as follows:
[0027] The original image is read and converted into a single-channel grayscale image. Next, the image dimensions are obtained, and the height H and width W are recorded. This information forms the basis for generating noise; subsequently, pixels are randomly selected from the image and modified.
[0028] Define noise ratio This controls the percentage of pixels in an image that will be contaminated with noise. A small noise ratio is typically set, such as 0.1, meaning 10% of pixels will be contaminated with noise. To simulate small, localized anomalous blocks that might exist in industrial images, the salt noise ratio is set to 1, meaning all noisy pixels will become salt noise.
[0029] By randomly generating pixel coordinates ,in The range of values is , The range of values is At these randomly selected pixel locations, the value is replaced with 255. In this way, salt noise can be randomly added to the image, ultimately generating an image with small-scale, discrete outliers.
[0030] The attention calculation of the multi-scale reversible self-attention module in the aforementioned industrial image anomaly detection system is as follows:
[0031]
[0032] Where Q, K, and V are the query matrix, key matrix, and value matrix, respectively. Scaling factor This represents a weighted combination of the relevance between different elements in the input sequence. The query matrix Q represents the set of query vectors from which information is to be obtained, the key matrix K represents the set of key vectors used to match the queries, and the value matrix V represents the set of value vectors that actually provide information. These three quantities all come from the same input and are used to capture the dependencies within the input. The model first uses Q and K to calculate the attention score, then uses the dot product to measure the similarity between each query and all keys, and introduces a scaling factor. This is to prevent the dot product calculation result from becoming too large, which could lead to gradient instability. Then, Softmax normalization is applied to normalize the attention score into a probability distribution, ensuring that the sum of the attention weights for each query is 1. Finally, the value matrix K is weighted and summed according to the attention weights to generate the final output.
[0033]
[0034] in The loss function is denoted by . The core purpose of backward gradient calculation is to optimize model parameters so that the attention weights can more accurately capture key information in the input data.
[0035] During training, focus loss and smoothed L1 loss are used as loss functions to train an accurate model for industrial image anomaly detection.
[0036] The beneficial effects of this invention are:
[0037] This invention employs an anomaly detection system based on image generation and a dual-branch prototype residual network to achieve anomaly detection and localization in industrial images. An anomaly generator module expands the database, and the ResNet-18 pre-trained network is improved for faster and more accurate feature extraction. A multi-scale prototype library module of normal patterns is then introduced to help the model recognize the distribution of normal features. Finally, a multi-scale reversible self-attention module is designed to capture local feature deviations caused by anomalies, identifying and locating surface defects. Even in complex detection environments, this model exhibits excellent robustness and can therefore be applied to anomaly detection in industrial images. Attached Figure Description
[0039] Figure 1 This is the overall network architecture of an industrial image anomaly detection system based on image generation and a dual-branch prototype residual network.
[0040] Figure 2 This refers to the overall network architecture of the exception generator module.
[0041] Figure 3 The overall network architecture for the improved ResNet-18 pre-trained network module.
[0042] Figure 4 The network architecture for the multi-scale prototype sample library module.
[0043] Figure 5 It is a network architecture for multi-scale reversible self-attention modules.
[0044] Figure 6 This is a comparison of the test set image-level AUROC of the present invention (Model 1) with two other methods. Detailed Implementation
[0046] The present invention will be described in detail below with reference to specific embodiments.
[0047] An industrial image anomaly detection system based on image generation and a dual-branch prototype residual network, the overall network architecture of which is as follows: Figure 1 As shown, it includes:
[0048] A1. Anomaly Generator Module: Selects a portion of images from the existing normal image database to generate new anomalous images, uses a fusion strategy to expand and enhance the anomalous features of the images, and unifies the image size to 256×256 pixels;
[0049] like Figure 2As shown. To simulate the generation process of natural anomalies and enable the generated anomaly images to smoothly expand the dataset, tighten the decision boundary during training, and help the system improve its ability to identify anomaly samples, this invention generates two types of random noise images using Berlin noise and salt-and-pepper noise respectively. These noise images are used to simulate anomaly patterns in industrial images. To increase the diversity of defect samples, the samples simulate different types of anomaly features, and image adjustments are made to the noise, such as rotation, symmetry, and flipping. Considering that industrial products usually have small sample sizes, noise is avoided in the background when generating anomalies, thus reducing the difference between generated defect samples and natural anomaly samples. This invention employs a foreground enhancement strategy, binarizing the input image by setting a threshold T, successfully separating the foreground and background. The final generated mask image contains the foreground region with anomaly patterns, which can be used to train the model and further improve its robustness.
[0050] To expand and enhance the anomalous features of images and improve the system's ability to learn from anomalous samples, this invention employs two strategies: Strategy One performs random spatial transformations on the input image to simulate structural anomalies of objects, including rotation, shearing, and translation. These transformations help to spatially simulate structural anomalies that may occur in industrial images, such as misalignment or deformation of defects. Strategy Two randomly adjusts various visual attributes of the input image to simulate texture anomalies on the object's surface, including equalization, exposure, tone separation, sharpness, automatic contrast, inversion, and gamma contrast. These attribute adjustment methods help generate texture anomalies at the levels of image color, brightness, and sharpness, thereby better matching the anomaly patterns in industrial images.
[0051] A2. Improved ResNet-18 Pretrained Network Module: Improves the ResNet-18-based encoder to further lightweight the network.
[0052] like Figure 3 As shown. To reduce computational cost, improve feature diversity, and enhance the model's expressive power, this invention replaces the original BasicBlock residual with Bottleneck residuals, compresses channels using 1×1 convolutions, and adjusts them to grouped convolutions. To capture simple features more linearly in shallow networks and complex features more non-linearly in deep networks, alleviate the gradient vanishing problem, and make the model suitable for large-scale training, this invention introduces learnable parameters into the ACON activation function to dynamically adjust its non-linear characteristics. To alleviate overfitting and ensure the complete network is preserved in subsequent detections, guaranteeing high model performance, this invention uses Stochastic Depth in this module to randomly discard some residuals during forward propagation.
[0053] After the input image is pre-trained by the improved ResNet-18 network, it will be convolved step by step to obtain three-level feature layers of 64×64×64, 128×32×32 and 256×16×16 respectively. These three feature maps of different scales are used as input data for the multi-scale fusion module.
[0054] A3. Multi-scale fusion module: Three feature maps at different scales serve as input data for the multi-scale fusion module, which uses multi-scale feature blocks to perform multi-scale cross-domain information fusion. The output data is the sum of the transformed representations of the three input feature maps.
[0055] The specific steps are as follows:
[0056]
[0057] It is important to note that the transformation function The choice depends on the input feature map index. and output feature map index .if , representing feature map Perform the migration directly, if , This indicates that the feature map is downsampled to increase the ability to represent geometric details. , This indicates that the feature map is upsampled to better combine local and global information and restore the image's detailed information.
[0058] A4. Multi-scale prototype sample library module: Learns and stores the latent feature representations of normal samples, constructs a normal benchmark pattern with high discriminative power, and compares it with the normal pattern in the prototype library when a new sample is input to quickly determine whether the target deviates from the normal distribution.
[0059] like Figure 4 As shown, the specific steps are as follows:
[0060] A41. Set up a storage module and use k-means clustering to divide normal samples into several clusters. The center of each cluster represents the typical characteristics of the normal data of that type, thus establishing a baseline pattern for the model.
[0061] For each structure Feature map , using Figure 4 The partitioning method shown is used to divide it. Divided The size is Each region is a separate area where feature storage units are managed and queried independently; that is, each region represents multiple memory units for each feature map. The single-channel feature map in each partition is flattened into a single memory unit. A dimensional vector. Thus, a set of channels can be obtained in each region. Each channel geometry contains storage collections Each storage collection contains One memory item ( The size of the memory item is the same as the dimension of the query vector for subsequent model feature matching.
[0062] To ensure stable mapping of high-level features when memory information and input images are fused in the ResNet-18 decoder, the encoder model parameters need to be frozen to ensure that the output features of blocks 1, 2 and 3 have consistent granularity. To ensure that there is a significant difference between the number of normal features and abnormal features in the dataset, this invention adjusts the number of prototypes to 15% ± 5% of the number of normal samples in the dataset.
[0063] A42. Set up the reading module and use the pre-trained ResNet-18 network to extract features from the input image, obtaining feature blocks of the input image at different scales.
[0064] Specifically, a retrieval matching process is performed using a query vector Q and memory units M in a multi-scale prototype library. In this process, the query vector and memory units are first normalized to improve the accuracy of the matching weight calculation. Then, the similarity matching weights are derived by calculating their cosine similarity, as shown below:
[0065]
[0066] in Describing the L2 norm, This represents the cosine similarity. To prevent excessively low matching scores from leading to inaccurate feature extraction from the memory, a threshold is introduced. When querying features related to abnormal regions, the weight value is low due to the low matching degree. A value of 0 means that no additional normal features will be learned.
[0067]
[0068] A new feature vector can be generated through a multi-scale prototype library and query mechanism. Next, these matched key features are reorganized to match the size of the query feature map and cascaded with it along the channel dimension. This cascaded information is then integrated through a multi-scale feature fusion module to assist in image reconstruction in the decoder. This operation not only reduces the representation requirements of the CNN but also allows the model to better understand the normal distribution of the data.
[0069] A5. Multi-scale reversible self-attention module: Design transition blocks and reinforcement blocks for attention operations. The embedding layer first divides the feature block into patches of different sizes and uses different heads to calculate the attention between patches. Different heads represent different patch blocks. Finally, the normalization function is used to integrate the patch information.
[0070] like Figure 5 As shown, the specific steps are as follows:
[0071] Both transition blocks and enhancement blocks can be viewed as inputs consisting of two partition tensors, which are transformed according to the following equation while preserving the invertibility of the input and output. The input is divided along the channel dimension. and This refers to the memory features for matching the input image and the extracted features of the input image. Simultaneously, following the MViT linkage mechanism, multi-head attention is utilized. and MLP sublock The feature information is integrated with each other.
[0072]
[0073] The value vector of the transition block incorporates lateral connectivity and relative positional information, allowing for efficient computation of resolution changes during feature sampling and minimizing the loss of initial information. Simultaneously, the residual connections use the same pooling blocks as the key vectors, enabling synchronous changes in all feature sizes within the same block while preserving the feature sizes of other blocks. The enhancement block performs reversible attention computation only on the previously learned feature stream, while the remaining channels undergo feature fusion after the MLP, ensuring the entire reversible stream is fully reversible and learnable without the need for cached activation.
[0074] Firstly, from Extract the shape as The blocks are flattened into one-dimensional vectors, and then the flattened vectors are embedded into the query vector Q using a fully connected layer and pooling blocks. The key vector K and value vector V are obtained through similar operations.
[0075]
[0076] It's important to note that the value vector generates an additional branch that forms a residual connection with the tensor after attention. Simultaneously, the value vector introduces relative positions to improve computational efficiency. Then, attention... It will be reshaped to the original spatial resolution of the input. Head attention is calculated from different block sizes to obtain the features of the current input feature block. Finally, these features are concatenated through 2D residual blocks to obtain the output. In order to further fuse the calculated attention information, the model stacks the enhancement blocks and transition blocks N times.
[0077] A6. The entire network uses focal loss and smoothed L1 loss.
[0078] A61. Focus Loss
[0079] In industrial image anomaly detection tasks, the number of negative samples typically far exceeds the number of target positive samples. Traditional cross-entropy loss functions treat all samples equally, leading to the model being dominated by a large number of simple negative samples and making it difficult to effectively learn key positive sample features. Focus loss, by reducing the loss weight of easily classifiable samples, allows the model to focus more on difficult-to-classify samples.
[0080]
[0081] in This represents the model's predicted probability of the true class. If the sample is a positive class, If the sample is a negative class, ; These are the class weight parameters, used to balance the loss contributions of positive and negative samples; To focus on the parameters, adjust the weight index of easy and difficult samples.
[0082] A62. Smooth L1 loss
[0083] Smoothing L1 loss is a loss function that combines the advantages of L1 loss and L2 loss. Its core design is to use smooth gradients in the form of L2 when the error is small to facilitate fine-tuning of the model, and to use constant gradients in the form of L1 when the error is large to avoid gradient explosion and enhance robustness to outliers.
[0084]
[0085] in This is the difference between the predicted value and the actual value. When the error is small, a squared term similar to L2 loss is used. At this point, the gradient is The loss term decreases linearly as the error decreases, which helps the model finely adjust parameters when approaching the true value and avoid oscillations; when the error is large, it switches to a linear term similar to L1 loss. At this point, the gradient is fixed at ±1 to avoid the gradient explosion problem caused by the L2 loss as the gradient increases with the error.
[0086] Finally, a deviation factor is mentioned. Increase robustness to accurate segmentation of difficult samples and reduce oversensitivity to outliers.
[0087]
[0088] The mean of the top K significant anomaly points is extracted and used as the basis for global anomaly detection. When the predicted Mo is accurate and close enough to M, it can not only be interpreted as a pixel-level anomaly localization result, but also as an image-level anomaly estimate for anomaly detection.
[0089] Figure 6 This is an AUROC comparison curve of the industrial image anomaly detection system based on image generation and a dual-branch prototype residual network of this invention with two other methods. Method 2 performs anomaly detection without an anomaly generation module, and Method 3 performs anomaly detection without using a reversible attention calculation module. As can be seen from the figure, the accuracy of this invention is the highest compared to the other two methods, ultimately reaching 92.4%.
[0090] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. An industrial image anomaly detection system based on a dual-branch prototype residual network, characterized in that, It includes an anomaly generator module, an improved ResNet-18 pre-trained network module, a multi-scale fusion module, a multi-scale prototype sample library module, and a multi-scale reversible self-attention module: Anomaly Generator Module: The input data is normal images. It uses Berlin noise and salt-and-pepper noise to generate anomalous images, aiming to simulate structural anomalies and minor defects in images. It designs a foreground classification strategy to limit noise to specific regions. Finally, it randomly generates different anomalous images through a fusion strategy to expand the training library. The output data is randomly generated anomalous images. The improved ResNet-18 pre-trained network module uses a Bottleneck structure for residuals to address the weak feature representation capability of the original network, and employs grouped convolutions to enhance feature diversity and expressive power. Secondly, it introduces the ACON dynamic activation function, enabling the network to automatically adjust the nonlinear intensity based on depth. Finally, it adopts a Stochastic Depth training strategy to improve the model's adaptability to industrial anomalies and its real-time performance. After the input image is processed by the improved ResNet-18 pre-trained network, it undergoes successive convolutions to obtain three feature layers of 64×64×64, 128×32×32, and 256×16×16, respectively. These three feature maps at different scales serve as input data for the multi-scale fusion module. Multi-scale fusion module: Three feature maps at different scales serve as input data for the multi-scale fusion module, which uses multi-scale feature blocks to perform multi-scale cross-domain information fusion; the output data is the sum of the transformed representations of the three input feature maps. Multi-scale prototype sample library module: The input data is a sample library of normal images. Multi-scale feature extraction and k-means clustering are performed on the normal samples. The output data is a prototype set representing normal patterns. In the detection stage, the feature query vector of the input image is matched with the prototype library by cosine similarity. Only normal features with high similarity are extracted to assist in reconstruction. Multi-scale reversible self-attention module: The input data is the sum of the transformed representations of the multi-scale fusion module. It utilizes the transition block sub-module and the reinforcement block sub-module for block attention calculation and residual connection to effectively maintain the feature structure and information integrity. Through the mean discrimination mechanism of significant anomalies, it takes into account both pixel-level localization and image-level anomaly estimation, thereby improving the overall detection accuracy and stability. The output data represents the attention calculation results of the three levels respectively.
2. The industrial image anomaly detection system according to claim 1, characterized in that, The anomaly generator module includes a Berlin noise submodule, a salt-and-pepper noise submodule, and a fusion strategy submodule.
3. The industrial image anomaly detection system according to claim 2, characterized in that, The Berlin noise submodule generates a Berlin image of the same size as the original image using a Berlin noise generator, and then separates the foreground and background parts through binarization and rotation operations. ; ;in Represents random coordinates of the image. Indicates the size of the image grid division. The gradient vector is represented by H×W. The input image is divided into an integer grid, and a randomly generated unit gradient vector is stored at the vertex of each grid. The directions of these gradient vectors are uniformly distributed between 0 and 360 degrees, and the length of each vector is normalized to 1. ; ;in This represents the influence weight of each grid point on the current point, reflecting the influence of the gradient direction on the target point. For any given coordinate point, first locate the grid cell where the point is located, then determine the four grid vertices surrounding the point; calculate the relative vectors between these vertices and the target point, and perform a dot product operation between the gradient vector of each grid vertex and the corresponding relative vector. ;in This is the bilinear interpolation function we use. and Interpolation processing is applied to ensure smooth transitions in both the horizontal and vertical directions. This operation eliminates obvious traces of the mesh, avoids abrupt changes at mesh boundaries, effectively prevents unnatural staircase effects, and ensures that noise remains continuous and natural during the generation process.
4. The industrial image anomaly detection system according to claim 2, characterized in that, Salt and pepper noise submodule: Uses a salt and pepper noise generator to generate a salt and pepper image the same size as the original image, and performs element-wise multiplication with the separated Berlin image to obtain our noise image; reads the original image and converts it into a single-channel grayscale image, then obtains the image dimensions, and records the image height H and width W; this information is the basis for generating noise, and then randomly selects pixels in the image for modification. Define noise ratio This is used to control what percentage of pixels in an image will be contaminated by noise; By randomly generating pixel coordinates ,in The range of values is , The range of values is At these randomly selected pixel locations, the value is replaced with 255; in this way, salt noise is randomly added to the image, ultimately generating an image of small-scale, discrete outliers.
5. The industrial image anomaly detection system according to claim 2, characterized in that, The fusion strategy submodule employs two fusion strategies to expand and enhance the anomalous features of images, thereby improving the learning ability of anomalous samples during training and enhancing the robustness of the model.
6. The industrial image anomaly detection system according to claim 1, characterized in that, The specific steps of the multi-scale fusion module are as follows: Transformation function The choice depends on the input feature map index. and output feature map index ;if , representing feature map Perform the migration directly, if , This indicates that the feature map is downsampled to increase its ability to represent geometric details. , This indicates that the feature map is upsampled to better combine local and global information and restore the image's detailed information.
7. The industrial image anomaly detection system according to claim 1, characterized in that, The specific attention steps of the multi-scale reversible self-attention module are as follows: Where Q, K, and V are the query matrix, key matrix, and value matrix, respectively. Scaling factor The input sequence is represented by a weighted combination of relevance between different elements; the query matrix Q represents the set of query vectors from which information is to be obtained, the key matrix K represents the set of key vectors used to match the query, and the value matrix V represents the set of value vectors that actually provide information. These three quantities all come from the same input and are used to capture the dependencies within the input. First, attention scores are calculated using Q and K. Then, the similarity between each query and all keys is measured using a dot product, and a scaling factor is introduced. This is to prevent the dot product calculation result from being too large, which would cause gradient instability; then, Softmax normalization is applied to normalize the attention score into a probability distribution, so that the sum of the attention weights for each query is 1; finally, the value matrix K is weighted and summed according to the attention weights to generate the final output.