An industrial anomaly detection method based on codec architecture
By generating negative samples and extracting high-level features in industrial anomaly detection, and combining multi-scale feature fusion with a semantic transmission model of generative adversarial networks, the problems of sample imbalance and difficulty in detecting small-area anomalies in traditional supervised learning are solved, achieving more efficient industrial anomaly detection.
Patent Information
- Application Number
- CN202411924348.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Traditional supervised learning methods have limited effectiveness in industrial anomaly detection due to a lack of sufficient anomaly samples. Furthermore, existing methods ignore the inherent differences between industrial anomaly detection datasets and the ImageNet dataset, resulting in poor model performance in industrial anomaly detection.
By adding artificially simulated anomalous image patches to the MVTec dataset, negative samples are generated using a two-dimensional Berlin noise generation algorithm and an anomalous texture dataset. An encoder-decoder architecture is designed to extract high-level features from the memory samples. Combined with multi-scale feature fusion and a semantic transmission model of generative adversarial networks, the problems of sample imbalance and difficulty in detecting small-area anomalies are alleviated.
It improves the model's generalization ability and robustness, enhances its ability to perceive small-area anomalies, and improves the quality and accuracy of segmented images, making it suitable for real-time anomaly detection in complex industrial scenarios.
Smart Images

Figure CN119863438B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial anomaly detection and relates to an industrial anomaly detection method based on an encoder-decoder architecture. Background Technology
[0002] Industrial anomaly detection has become a crucial part of the intelligent industrial development process. In today's highly competitive industrial sector, product quality is the foundation of a company's survival, production efficiency is related to its profitability, and stable production is the basis for ensuring the orderly operation of the entire production chain. The core purpose of industrial anomaly detection is to accurately detect and locate defects that may occur in various industrial products during complex production processes. However, in actual industrial production environments, normal samples constitute the vast majority, while anomaly samples are not only scarce in number but also diverse in their manifestations and unpredictable, making traditional supervised learning methods very limited in effectiveness. Traditional supervised learning heavily relies on a large amount of clearly labeled sample data for model training, but in the field of industrial anomaly detection, the scarcity of anomaly samples cannot meet the needs of traditional supervised learning. Therefore, current research in this field mainly focuses on self-supervised learning methods for industrial anomaly detection. Self-supervised learning has unique advantages; unlike traditional supervised learning, it does not rely on manual labeling of data. Instead, it cleverly utilizes the inherent structural characteristics of the data itself and the correlations between data points to autonomously generate supervisory signals, thereby providing strong support for accurate industrial anomaly detection.
[0003] With the development of deep learning technology, research on industrial image anomaly detection can be broadly categorized into reconstruction-based methods and embedding-based methods. In current research, most reconstruction-based methods train networks using an encoder-decoder architecture to reconstruct the input image, with larger errors indicating anomalous regions. OCR-GAN introduces a frequency decoupling module to decouple the input image into different frequency components, reconstructing the image from a frequency perspective. RealNet generates anomalous samples of varying degrees based on a diffusion process, integrating feature selection strategies and reconstruction processes to improve anomaly detection performance. However, in practical applications, neural networks, due to their powerful learning capabilities, can also reconstruct anomalous regions effectively. Embedding-based methods typically utilize pre-trained networks trained on the ImageNet dataset to extract high-level features from the original image. Anomaly scores are calculated by measuring the distance between test samples and normal samples based on these features, thereby identifying anomalous regions. Directly using pre-trained networks may lead to domain mismatch problems. Patchcore creates a core memory library from extracted normal features to establish an outlier detection model for anomaly detection. FYD designed a coarse-to-fine feature alignment network to learn the dense and compact feature distribution of normal images. Embedding-based models have been widely applied due to their simplicity and effectiveness. However, these methods ignore the inherent differences between industrial anomaly detection datasets and the ImageNet dataset.
[0004] To address these issues, this method proposes an industrial anomaly detection model. During the training phase, image processing algorithms are used to add two-dimensional Berlin noise to images in the MVTec dataset, thereby introducing artificially simulated anomalies to obtain defect sample images, alleviating the limitation of supervised learning which can only use normal samples. During the model's inference phase, the differences between input samples and stored samples in the memory bank are compared to provide more effective information for anomaly region localization. Simultaneously, an industrial image semantic transmission model based on generative adversarial networks is designed. This model compresses images into low-dimensional latent semantics at the encoding end, significantly reducing data transmission while preserving semantic information. The MVTec dataset is a standard dataset for machine vision anomaly detection, containing images of various types of industrial products, such as mechanical parts, electronic components, and textiles. This dataset was created and maintained by the machine vision team at the Technical University of Munich, Germany. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide an industrial anomaly detection method based on an encoder-decoder architecture. Specifically, this invention designs an industrial anomaly detection method based on an encoder-decoder architecture. Addressing the problem that traditional supervised learning methods cannot be trained when the number of positive and negative samples is extremely imbalanced, an anomaly sample generation method is designed. This method utilizes a two-dimensional Berlin noise generation map and an anomaly texture dataset, and employs image processing algorithms to create a negative sample dataset. Considering the problem of not being able to fully utilize information in images during feature extraction, an image feature extraction and fusion method is designed. Normal samples are randomly selected from each set of industrial products as memory samples, and a encoder-decoder network architecture is used to extract high-level features from the memory samples as memory information to assist in model training. Furthermore, considering the difficulty in perceiving small-area anomalies in industrial anomaly detection, a multi-scale feature fusion strategy is used to fully fuse feature maps of different scales, alleviating the problem of imbalanced areas between normal and abnormal regions in the image and the difficulty in prediction.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] An industrial anomaly detection method based on a codec architecture includes the following steps:
[0008] S1: Divide the industrial product images in the MVTec dataset into training set and test set, and add artificially simulated abnormal image patches through an anomaly generation algorithm to create an abnormal image dataset;
[0009] S2: Randomly select a small number of normal samples from each set of industrial products as memory samples, and use an encoder-decoder network architecture to extract high-level features of the memory samples as memory information to assist in model training.
[0010] S3: Employs a multi-scale feature fusion strategy to fully integrate feature maps of different scales, alleviating the problem of small-area anomalies being difficult to detect in the field of industrial anomaly detection.
[0011] S4: Use the loss function of the end-to-end industrial anomaly detection model to alleviate the problem of imbalance between the areas of normal and abnormal regions in the image and the prediction problem, while retaining most of the edge information of the obtained segmented image, thereby completing the training of the industrial anomaly detection model.
[0012] S5: An industrial image semantic transmission model based on generative adversarial networks was designed. At the encoding end, the image is compressed into low-dimensional semantic information, and at the decoding end, the semantic information transmitted through the channel is decoded to reconstruct a high-quality image.
[0013] Furthermore, the anomaly generation algorithm described in S1 specifically includes:
[0014] S11: Generate a two-dimensional Gaussian noise image P, and then binarize image P using a threshold obtained by random uniform sampling to obtain a mask image M. P Berlin noise has multiple random peaks, and the masked image M generated by it... P Extracting continuous regions from an image;
[0015] S12: Binarize the input image I to obtain the mask image I. M The opening and closing operations of the image are used to remove the noise generated during the binarization process, i.e., discrete noise.
[0016] S13: By analyzing the two masked images M obtained P with I M Perform element-wise multiplication to obtain the final mask image M;
[0017] S14: Obtain the noisy image N I It is taken from an abnormal texture dataset and is used to simulate texture anomalies in industrial products;
[0018] S15: Combine the masked image M and the noisy image N I Perform element-wise multiplication to obtain the noisy image N. I The foreground region in the image, that is, the area occupied by the main industrial component;
[0019] S16: Use formula N I ′=σ(M⊙N I )+(1-σ)(M⊙I), generate a noisy foreground image N. I For σ, its value is randomly and uniformly sampled from [0.2, 0.8].
[0020] S17: Invert the mask image M to obtain the image. Then the inverted mask image Perform an element-wise product with the original image I to obtain image I′;
[0021] S18: According to the formula: Fusing image I and image I′ yields a data-enhanced image, i.e., a simulated anomalous image I. A ;I A Using the original input image I as the background, the noise image N is extracted from the mask image M. I The industrial product area in the middle is the prospect.
[0022] Furthermore, in S2, an encoder-decoder network architecture is used to extract high-level features of the memory samples as memory information, specifically including:
[0023] S21: In order to obtain memory information, N normal images are randomly selected from each category in the training data as memory samples and input into the encoder.
[0024] S22: Features with different resolutions are obtained from the first, second and third layers of the pre-trained ResNet50 network on the ImageNet dataset, and together they form a memory information base.
[0025] S23: Freeze the model parameters of the first, second and third layers of the ResNet50 network to obtain information and high-level features of the input image and the memory sample image;
[0026] S24: For the input image in the training phase, the encoder directly extracts the high-level features of the input image and obtains feature maps with different resolutions through the first, second and third layers of the network; these three feature maps with different resolutions store semantic information of the input image II at different scales.
[0027] S25: Calculate the L2 distance between the input image II information and the memory image MI information at different resolutions to obtain the difference information DI between the input image and the memory samples. Where N is the number of memory samples; the difference information DI records the similarities and differences between the input image and the memory samples;
[0028] S26: For N differential information, using the minimum sum of all elements in each DI as the standard, the optimal differential information DI′ between II and MI is obtained, that is: In the formula, i∈[1,N]; the best difference information DI′ contains the difference between the input sample and its most similar memory sample;
[0029] S27: The optimal difference information DI′ and the input image II are added together by the high-level features extracted by the encoder to obtain concatenated information CI1, CI2 and CI3.
[0030] Furthermore, in S3, a multi-scale feature fusion strategy is used to fully fuse feature maps with different scales, specifically including:
[0031] S31: For features of three different dimensions, CI1, CI2 and CI3, feature maps with different resolutions are obtained by using 3×3 convolutional blocks and inverse convolution operations while maintaining the number of channels.
[0032] S32: Align the feature maps obtained in S31 by upsampling in terms of dimensions, so that the dimensions of the three feature maps are the same as the dimensions of the feature map with the largest size.
[0033] S33: Use convolution to align the three feature maps with the same dimension in terms of the number of channels, so that the dimension and number of channels of the three feature maps are the same, so as to facilitate the subsequent addition operation;
[0034] S34: Perform element-wise addition on the feature map obtained in S33 to achieve multi-scale feature fusion, and transmit it to the industrial anomaly detection and identification device.
[0035] Furthermore, in S4, to alleviate the imbalance between normal and abnormal regions in the image and the problem of prediction, the loss function of the end-to-end industrial anomaly detection model is defined as follows:
[0036]
[0037] The loss function of the end-to-end industrial anomaly detection model is a fusion of the L2 loss function and the focus loss function, where p and These are the ground truth image and the model inference image, respectively; λ1 and λ2 are the balancing hyperparameters that control the fusion of the L2 loss function and the focus loss function; α is the balancing factor used to adjust the influence between positive and negative samples; γ is the focus factor used to adjust the weight of abnormal regions in the sample image.
[0038] Furthermore, in step S5, the image is compressed into semantic information at the encoding end, and the semantic information transmitted through the channel is decoded at the decoding end to reconstruct a high-quality image. Specifically, this includes:
[0039] S51: The semantic encoder has an autoencoder network architecture. The input image is processed by the semantic encoder to calculate high-dimensional image information and obtain low-dimensional semantic information. The mathematical expression of the encoding process is as follows:
[0040] y i =f θ (x) = h(Ax + b)
[0041] Where y i θ = (A, b) is the output of semantic encoding, h is the activation function, A is the weight matrix, x is the input image, and b is the bias vector.
[0042] S52: After performing LDPC channel coding on the low-dimensional semantic information calculated in S51, it is transmitted through the physical channel. During the model training phase, an additive white Gaussian noise model is selected as the simulation channel model for training. The mathematical expression of the coding process is as follows:
[0043]
[0044] Among them is the output of LDPC channel coding, e is the channel gain, and n is additive white Gaussian noise;
[0045] S51: Simultaneously using the original image x and the generated image y, a semantic decoder based on a generative adversarial network architecture is trained; through training the semantic decoder, the features of the original image distribution can be effectively extracted, and the original image x can be reconstructed.
[0046] The beneficial effects of this invention are as follows:
[0047] (1) By using an anomaly generation algorithm and two-dimensional Berlin noise and anomaly texture dataset, anomaly images are artificially simulated, which effectively alleviates the problem of extreme imbalance between positive and negative samples in the field of industrial anomaly detection, provides more training data for supervised learning-based anomaly detection models, and improves the generalization ability and robustness of the models.
[0048] (2) By using image feature extraction and fusion methods, high-level features are extracted from normal samples as memory information and fused with the features of the input image. This effectively utilizes the information in the input image, improves the feature expression ability of the model, and enhances the anomaly detection ability of the model.
[0049] (3) By using a multi-scale feature fusion strategy, feature maps of different scales are fully integrated, effectively combining semantic information of different scales, improving the model's ability to perceive small-area anomalies, and solving the challenge of capturing small-area anomalies in the field of industrial anomaly detection.
[0050] (4) By using the loss function of the end-to-end industrial anomaly detection model, the problem of imbalance between the areas of normal and abnormal regions in the image and the prediction problem are alleviated. At the same time, most of the edge information of the segmented image is preserved, which improves the quality and accuracy of the segmented image.
[0051] (5) By using an industrial image semantic transmission model based on generative adversarial networks, images are compressed into low-dimensional semantic information. While preserving semantic information, the amount of data transmission is greatly reduced. This model is suitable for complex industrial scenarios with poor communication signals, strong channel interference, and low bandwidth, thereby improving the real-time performance and efficiency of the anomaly detection model.
[0052] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description
[0053] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein:
[0054] Figure 1 This is a flowchart of the industrial anomaly detection method based on codec architecture described in this invention.
[0055] Figure 2 A diagram of an industrial image semantic transmission model based on generative adversarial networks designed for this invention;
[0056] Figure 3 This is a diagram of an industrial anomaly detection model based on a codec architecture provided in an embodiment of the present invention. Detailed Implementation
[0057] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0058] The accompanying drawings are for illustrative purposes only and are schematic diagrams, not actual pictures. They should not be construed as limiting the invention. To better illustrate the embodiments of the invention, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions. It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0059] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components. In the description of the present invention, it should be understood that if terms such as "upper," "lower," "left," "right," "front," and "rear" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, the terms used to describe positional relationships in the drawings are only for illustrative purposes and should not be construed as limiting the present invention. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.
[0060] like Figure 1 The diagram shows the detection process of an industrial anomaly detection method based on a codec architecture.
[0061] in Figure 2 The diagram shows a method for generating outlier samples by incorporating two-dimensional Berlin noise.
[0062] Figure 3The diagram shown is an industrial anomaly detection model based on a codec architecture, which includes the following steps:
[0063] S1: Divide the industrial product images in the MVTec dataset into training set and test set, and add artificially simulated abnormal image patches through an anomaly generation algorithm to create an abnormal image dataset;
[0064] S2: Randomly select a small number of normal samples from each set of industrial products as memory samples, and use an encoder-decoder network architecture to extract high-level features of the memory samples as memory information to assist in model training.
[0065] S3: Employs a multi-scale feature fusion strategy to fully integrate feature maps of different scales, alleviating the problem of small-area anomalies being difficult to detect in the field of industrial anomaly detection.
[0066] S4: The loss function of the end-to-end industrial anomaly detection model is used to alleviate the problem of imbalance between the areas of normal and abnormal regions in the image and the prediction problem, while retaining most of the edge information of the obtained segmented image, thereby completing the training of the industrial anomaly detection model.
[0067] S5: An industrial image semantic transmission model based on generative adversarial networks was designed. At the encoding end, the image is compressed into low-dimensional semantic information, and at the decoding end, the semantic information transmitted through the channel is decoded to reconstruct a high-quality image.
[0068] The anomaly generation algorithm described in S1 specifically includes:
[0069] S11: Generate a two-dimensional Gaussian noise image P, and then binarize image P using a threshold obtained by random uniform sampling to obtain a mask image M. P Berlin noise has multiple random peaks, and the masked image M produced by it... P It can extract continuous regions from an image.
[0070] S12: Binarize the input image I to obtain the mask image I. M The image opening and closing operations are used to remove noise generated during binarization, i.e., discrete noise.
[0071] S13: By analyzing the two masked images M obtained P with I M Perform element-wise multiplication to obtain the final mask image M.
[0072] S14: Obtain the noisy image N I It is taken from an abnormal texture dataset and is used to simulate texture anomalies in industrial products.
[0073] S15: Combine the masked image M and the noisy image N IPerform element-wise multiplication to obtain the noisy image N. I The foreground area in the image refers to the area occupied by the main industrial component.
[0074] S16: Use formula N I ′=σ(M⊙N I )+(1-σ)(M⊙I), generate a noisy foreground image N. I For σ, its value is randomly and uniformly sampled from [0.2, 0.8].
[0075] S17: Invert the mask image M to obtain the image. Then the inverted mask image The image I′ is obtained by performing an element-wise product with the original image I.
[0076] S18: According to the formula: Fusing image I and image I′ yields a data-enhanced image, i.e., a simulated anomalous image I. A I A Using the original input image I as the background, the noise image N is extracted from the mask image M. I The industrial product area in the middle is the prospect.
[0077] S2 uses an encoder-decoder network architecture to extract high-level features of the memory samples as memory information, specifically including:
[0078] S21: In order to obtain memory information, N normal images are randomly selected from each category in the training data as memory samples and input into the encoder.
[0079] S22: Features with different resolutions are obtained from the first, second and third layers of the pre-trained ResNet50 network on the ImageNet dataset, and together they form a memory information base.
[0080] S23: Freeze the model parameters of the first, second, and third layers of the ResNet50 network to obtain information and high-level features from the input image and the memory sample image.
[0081] S24: For the input image during the training phase, the encoder directly extracts the high-level features of the input image, obtaining feature maps with different resolutions through the first, second, and third layers of the network. These three feature maps with different resolutions store semantic information of the input image II at different scales.
[0082] S25: Calculate the L2 distance between the input image II information and the memory image MI information at different resolutions to obtain the difference information DI between the input image and the memory samples. Where N is the number of memory samples. The difference information (DI) records the similarities and differences between the input image and the memory samples.
[0083] S26: For N differential information, using the minimum sum of all elements in each DI as the standard, the optimal differential information DI′ between II and MI is obtained, that is: In the formula, i∈[1,N]. The best difference information DI′ contains the difference between the input sample and its most similar memory sample.
[0084] S27: The optimal difference information DI′ and the input image II are added together by the high-level features extracted by the encoder to obtain concatenated information CI1, CI2 and CI3.
[0085] S3 employs a multi-scale feature fusion strategy to fully integrate feature maps of different scales, specifically including:
[0086] S31: For features of three different dimensions, CI1, CI2 and CI3, feature maps with different resolutions are obtained by using 3×3 convolutional blocks and inverse convolution operations while maintaining the number of channels.
[0087] S32: For the feature maps obtained in S31, dimensional alignment is performed using upsampling, so that the dimensions of the three feature maps are all the same as the dimension of the feature map with the largest size.
[0088] S33: Use convolution to align the three feature maps with the same dimension in terms of the number of channels, so that the dimension and number of channels of the three feature maps are the same, so as to facilitate the subsequent addition operation.
[0089] S34: Perform element-wise addition on the feature map obtained in S33 to achieve multi-scale feature fusion, and transmit it to the industrial anomaly detection and identification device.
[0090] The loss function of the end-to-end industrial anomaly detection model is defined as follows:
[0091]
[0092] The loss function of the end-to-end industrial anomaly detection model is a fusion of the L2 loss function and the focus loss function, where p and These are the ground truth image and the model inference image, respectively; λ1 and λ2 are the balancing hyperparameters that control the fusion of the L2 loss function and the focus loss function; α is the balancing factor used to adjust the influence between positive and negative samples; γ is the focus factor used to adjust the weight of abnormal regions in the sample image.
[0093] S5 compresses the image into semantic information at the encoding end and decodes the semantic information transmitted through the channel at the decoding end to reconstruct a high-quality image, specifically including:
[0094] S51: The semantic encoder uses an autoencoder network architecture. The input image is processed by the semantic encoder to calculate low-dimensional semantic information from high-dimensional image information. The mathematical expression for the encoding process is as follows:
[0095] y i =f θ (x) = h(Ax + b)
[0096] Where y i θ is the output of semantic encoding, θ = (A, b) are the parameters of the encoder network, h is the activation function, A is the weight matrix, x is the input image, and b is the bias vector.
[0097] S52: After performing LDPC channel coding on the low-dimensional semantic information calculated in S51, it is transmitted through the physical channel. During the model training phase, an additive white Gaussian noise model is selected as the simulation channel model for training. The mathematical expression of the coding process is as follows:
[0098]
[0099] Among them is the output of LDPC channel coding, e is the channel gain, and n is additive white Gaussian noise.
[0100] S51: Using both the original image x and the generated image y, a semantic decoder based on a generative adversarial network architecture is trained. By training the semantic decoder, features of the original image distribution can be effectively extracted, and the original image x can be reconstructed.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. An industrial anomaly detection method based on a codec architecture, characterized in that: The following steps are involved: S1: Divide the industrial product images in the MVTec dataset into training set and test set, and add artificially simulated abnormal image patches through an anomaly generation algorithm to create an abnormal image dataset; S2: Randomly select a small number of normal samples from each set of industrial products as memory samples, and use an encoder-decoder network architecture to extract high-level features of the memory samples as memory information to assist in model training. S3: Employs a multi-scale feature fusion strategy to fully integrate feature maps of different scales, alleviating the problem of small-area anomalies being difficult to detect in the field of industrial anomaly detection. S4: The loss function of the end-to-end industrial anomaly detection model is used to alleviate the problem of imbalance between the areas of normal and abnormal regions in the image and the prediction problem, while retaining most of the edge information of the obtained segmented image, thereby completing the training of the industrial anomaly detection model. S5: An industrial image semantic transmission model based on generative adversarial networks was designed. At the encoding end, the image is compressed into low-dimensional semantic information, and at the decoding end, the semantic information transmitted through the channel is decoded to reconstruct a high-quality image.
2. The industrial anomaly detection method based on a codec architecture according to claim 1, characterized in that: The anomaly generation algorithm described in S1 specifically includes: S11: Generate a two-dimensional Gaussian noise image P, and then binarize image P using a threshold obtained by random uniform sampling to obtain a mask image M. P Berlin noise has multiple random peaks, and the masked image M generated by it... P Extracting continuous regions from an image; S12: Binarize the input image I to obtain the mask image I. M The opening and closing operations of the image are used to remove the noise generated during the binarization process, i.e., discrete noise. S13: By analyzing the two masked images M obtained P with I M Perform element-wise multiplication to obtain the final mask image M; S14: Obtain the noisy image N I It is taken from an abnormal texture dataset and is used to simulate texture anomalies in industrial products; S15: Combine the masked image M and the noisy image N I Perform element-wise multiplication to obtain the noisy image N. I The foreground region in the image, that is, the area occupied by the main industrial component; S16: Use formula N I ′=σ(M⊙N I )+(1-σ)(M⊙I), generate a noisy foreground image N. I For σ, its value is randomly and uniformly sampled from [0.2, 0.8]. S17: Invert the mask image M to obtain image M, and then perform an element-wise product between the inverted mask image M and the original image I to obtain image I′; S18: According to the formula: Fusing image I and image I′ yields a data-enhanced image, i.e., a simulated anomalous image I. A ;I A Using the original input image I as the background, the noise image N is extracted from the mask image M. I The industrial product area in the middle is the prospect.
3. The industrial anomaly detection method based on a codec architecture according to claim 1, characterized in that: In step S2, an encoder-decoder network architecture is used to extract high-level features of the memory samples as memory information, specifically including: S21: In order to obtain memory information, N normal images are randomly selected from each category in the training data as memory samples and input into the encoder. S22: Features with different resolutions are obtained from the first, second and third layers of the pre-trained ResNet50 network on the ImageNet dataset, and together they form a memory information base. S23: Freeze the model parameters of the first, second and third layers of the ResNet50 network to obtain information and high-level features of the input image and the memory sample image; S24: For the input image in the training phase, the encoder directly extracts the high-level features of the input image and obtains feature maps with different resolutions through the first, second and third layers of the network; these three feature maps with different resolutions store semantic information of the input image II at different scales. S25: Calculate the L2 distance between the input image II information and the memory image MI information at different resolutions to obtain the difference information DI between the input image and the memory samples. Where N is the number of memory samples; the difference information DI records the similarities and differences between the input image and the memory samples; S26: For N differential information, using the minimum sum of all elements in each DI as the standard, the optimal differential information DI′ between II and MI is obtained, that is: In the formula, i∈[1,N]; the best difference information DI′ contains the difference between the input sample and its most similar memory sample; S27: The optimal difference information DI′ and the input image II are added together by the high-level features extracted by the encoder to obtain concatenated information CI1, CI2 and CI3.
4. The industrial anomaly detection method based on a codec architecture according to claim 1, characterized in that: In step S3, a multi-scale feature fusion strategy is used to fully fuse feature maps with different scales, specifically including: S31: For features of three different dimensions, CI1, CI2 and CI3, feature maps with different resolutions are obtained by using 3×3 convolutional blocks and inverse convolution operations while maintaining the number of channels. S32: Align the feature maps obtained in S31 by upsampling in terms of dimensions, so that the dimensions of the three feature maps are the same as the dimensions of the feature map with the largest size. S33: Use convolution to align the three feature maps with the same dimension in terms of the number of channels, so that the dimension and number of channels of the three feature maps are the same, so as to facilitate the subsequent addition operation; S34: Perform element-wise addition on the feature map obtained in S33 to achieve multi-scale feature fusion, and transmit it to the industrial anomaly detection and identification device.
5. The industrial anomaly detection method based on a codec architecture according to claim 1, characterized in that: In step S4, to alleviate the imbalance between normal and abnormal regions in the image and the problem of prediction, the loss function of the end-to-end industrial anomaly detection model is defined as follows: The loss function of the end-to-end industrial anomaly detection model is a fusion of the L2 loss function and the focus loss function, where p and These are the ground truth image and the model inference image, respectively; λ1 and λ2 are the balancing hyperparameters that control the fusion of the L2 loss function and the focus loss function; α is the balancing factor used to adjust the influence between positive and negative samples; γ is the focus factor used to adjust the weight of abnormal regions in the sample image.
6. The industrial anomaly detection method based on a codec architecture according to claim 1, characterized in that: In step S5, the image is compressed into semantic information at the encoding end, and the semantic information transmitted through the channel is decoded at the decoding end to reconstruct a high-quality image. Specifically, this includes: S51: The semantic encoder has an autoencoder network architecture. The input image is processed by the semantic encoder to calculate high-dimensional image information and obtain low-dimensional semantic information. The mathematical expression of the encoding process is as follows: y i =f θ (x)=h(Ax+b) Where y i θ = (A, b) is the output of semantic encoding, h is the activation function, A is the weight matrix, x is the input image, and b is the bias vector. S52: After performing LDPC channel coding on the low-dimensional semantic information calculated in S51, it is transmitted through the physical channel. During the model training phase, an additive white Gaussian noise model is selected as the simulation channel model for training. The mathematical expression of the coding process is as follows: Among them is the output of LDPC channel coding, e is the channel gain, and n is additive white Gaussian noise; S51: Simultaneously using the original image x and the generated image y, a semantic decoder based on a generative adversarial network architecture is trained; through training the semantic decoder, the features of the original image distribution can be effectively extracted, and the original image x can be reconstructed.
Citation Information
Patent Citations
End-to-end semi-supervised image surface defect detection method based on memory information
CN114677346A
Industrial product surface defect detection and positioning method and system based on generality and difference
CN115439442A