Industrial visual anomaly detection method based on low-dimensional hidden space diffusion model, storage medium and electronic device
Patent Information
- Application Number
- CN202611275343.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-21
- Publication Date
- 2026-10-27
AI Technical Summary
[0004]本发明旨在解决采用扩散模型进行工业视觉异常检测的传统方法通过像素级差异判断异常导致的计算量大和语义异常不敏感的问题
[0019](1)通过扩散模型在低维隐空间处理样本,减少了模型的计算量和成本,在紧凑的隐空间中,快速地分离正常样本和异常样本,提高了模型的异常检测速度。
Smart Images

Figure CN122990338A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of industrial visual anomaly detection, and more specifically, to an industrial visual anomaly detection method, storage medium, and electronic device based on a low-dimensional latent space diffusion model. Background Technology
[0002] Industrial visual anomaly detection aims to identify and locate abnormal areas in images and has been widely applied in the field of industrial product quality inspection. Currently, industrial visual anomaly detection still faces significant challenges: ensuring both detection accuracy and speed to reduce costs and improve efficiency. Simultaneously, with the increasing diversity of product appearances and types, the shapes and sizes of product defects vary greatly. Anomalies can range from subtle changes (such as thin scratches) to large structural defects (such as missing parts), and are often unpredictable, mixing with normal images and posing significant difficulties for anomaly detection. Therefore, there is an urgent need for a new product anomaly detection technology in the field of intelligent industrial manufacturing to improve the accuracy of industrial anomaly detection.
[0003] Diffusion models, with their powerful image generation and generalization capabilities, have become an effective method for anomaly detection. In anomaly detection tasks, diffusion models mask defects in anomalous images by adding noise and then removing the defects as noise, thus reconstructing and repairing the anomalous image. This facilitates comparison between the anomalous image and the reconstructed image, and further estimates the defects. However, current diffusion models suffer from slow inference speed and insufficient anomaly detection accuracy in industrial anomaly detection. Therefore, we need to propose an improved diffusion model-based method for industrial visual anomaly detection. Summary of the Invention
[0004] The present invention aims to solve the problems of high computational cost and insensitivity to semantic anomalies caused by the traditional method of industrial visual anomaly detection using diffusion models, which judges anomalies by pixel-level differences.
[0005] Therefore, in view of the shortcomings of the existing technology, the first objective of this invention is to provide an industrial visual anomaly detection method based on a low-dimensional latent space diffusion model.
[0006] A second object of the present invention is to provide a computer-readable storage medium.
[0007] A third objective of this invention is to provide an electronic device.
[0008] To achieve the above objectives, the first aspect of the present invention provides an industrial visual anomaly detection method based on a low-dimensional latent space diffusion model. The method includes: Step S1: Inputting the sample to be detected into a trained latent space compression network to map the high-dimensional sample to a low-dimensional latent space, obtaining the latent space representation of the sample; Step S2: Inputting the latent space representation of the sample to be detected into a trained defect classifier to obtain the noise intensity and denoising time step of the sample; Step S3: Building and calling the trained low-dimensional latent space diffusion model, and inputting the noise intensity and denoising time step of the sample to be detected into the trained low-dimensional latent space diffusion model to perform corresponding forward addition on the latent space representation of the sample. Noise reduction and backward denoising reconstruction; Step S4: Using the latent space representation of the sample to be detected after denoising reconstruction as the reference distribution and the latent space representation of the sample to be detected as the target distribution, an adaptive threshold mechanism is adopted to set dynamic thresholds for the low-level features and high-level features output by the latent space compression network, and then the local anomaly score and global anomaly score are obtained based on the dynamic thresholds, so as to calculate the pixel-level local anomalies and semantic-level global anomalies between the reference distribution and the target distribution, respectively; Step S5: After fusing the local anomaly score and the global anomaly score, an anomaly heatmap is output, and then the anomaly detection result is output based on the anomaly heatmap.
[0009] Preferably, the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model further includes: before step S1: constructing a latent space compression network and training the latent space compression network based on normal samples; wherein, during the training process of the latent space compression network, the latent space compression network uses normal samples to learn the mapping relationship from high-dimensional space to low-dimensional latent space, and introduces distribution consistency constraints and contrastive learning to make normal samples form a dense cluster in the low-dimensional latent space to establish a normal-anomaly decision boundary; the contrastive learning adopts hierarchical contrastive loss, enabling the latent space compression network to simultaneously focus on local texture details and global semantic information; adopting hierarchical contrastive loss to enable the latent space compression network to simultaneously focus on local texture details and global semantic information specifically includes: using local attention windows for shallow features of normal samples to obtain pixel-level anomaly information, using channel attention for mid-level features of normal samples to detect local structural anomalies, and applying global self-attention for deep features of normal samples to identify semantic-level anomalies.
[0010] Preferably, the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model further includes: before step S1: building a defect classifier and training the defect classifier based on synthesized anomaly samples; wherein, during the training of the defect classifier, the defect classifier learns the distribution of anomaly samples in the low-dimensional latent space, evaluates the defect type and severity of the anomaly samples, outputs the defect category probability distribution and severity score of the anomaly samples, and then executes an adaptive time step adjustment strategy according to the defect category probability distribution and severity score, dynamically setting the noise intensity and denoising time step; for anomaly samples with a mixture of severe and minor defects, a composite noise processing scheme is adopted, and the dynamic noise intensity and denoising time step are set differently according to the defect type and defect region; wherein, severe and minor defects are judged according to the severity score of the anomaly samples.
[0011] Preferably, step S1 specifically involves: inputting the sample to be detected into the trained latent space compression network, so that the trained latent space compression network can map the high-dimensional sample to be detected to a low-dimensional latent space through multi-level downsampling and residual processing, thereby obtaining the latent space representation of the sample to be detected, so as to maintain the integrity of the spatial and semantic information of the sample to be detected.
[0012] Preferably, in step S3, the training process of the low-dimensional latent space diffusion model only uses the latent space representation of normal samples for fitting learning, so that the low-dimensional latent space diffusion model only learns the latent space distribution law of normal samples and does not learn any defect features, so that the low-dimensional latent space diffusion model can only reconstruct the latent space representation of normal samples in the inference stage.
[0013] Preferably, in step S4, the low-level features are high-resolution features output by the shallow layer encoding of the latent space compression network, used to locate pixel-level local anomalies; wherein, the low-level features include: image edges, color and texture information; the high-level features are low-resolution features output by the deep layer downsampling of the latent space compression network, used to determine semantic-level global anomalies at the overall image structure and semantic level.
[0014] Preferably, in step S4, dynamic thresholds are set for the low-level features and high-level features output by the latent space compression network, specifically including: the low-level features calculate the feature distance matrix based on the cluster centers of normal samples, and then generate a local adaptive dynamic threshold through a weighted averaging strategy; the high-level features are modeled based on the Gaussian distribution of normal samples, and then generate a global semantic anomaly dynamic threshold through an exponential smoothing iteration method.
[0015] Preferably, in step S5, after fusing the local anomaly scores and the global anomaly scores, an anomaly heatmap is output. Specifically, after fusing the local anomaly scores and the global anomaly scores, the fused anomaly scores are mapped to the spatial location of the original image to output an anomaly heatmap; wherein, the severity of defects in the anomaly heatmap corresponds to the vividness of the colors.
[0016] The second aspect of the present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model described in any of the above technical solutions.
[0017] The third aspect of the present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model described in any of the above technical solutions.
[0018] The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model proposed in this invention is based on a full consideration of the characteristics and shortcomings of the diffusion model, aiming to enhance the application advantages of the diffusion model in the field of industrial anomaly detection. The beneficial technical effects of this invention are as follows:
[0019] (1) By processing samples in a low-dimensional latent space through a diffusion model, the computational load and cost of the model are reduced. In a compact latent space, normal samples and abnormal samples are quickly separated, which improves the anomaly detection speed of the model.
[0020] (2) By adopting an adaptive time step adjustment strategy through the diffusion model, the complexity of the model is reduced and the number of inference steps of the diffusion model is reduced.
[0021] (3) By utilizing the distribution difference between the abnormal image and the reconstructed image, the image abnormality score is obtained, and an adaptive threshold mechanism is introduced to dynamically adjust the abnormality score threshold, thereby obtaining a more accurate abnormality detection result and improving the abnormality detection accuracy of the model.
[0022] Additional aspects and advantages of the invention will become apparent from the description which follows, or may be learned by practice of the invention. Attached Figure Description
[0023] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0024] Figure 1A schematic flowchart of an industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to an embodiment of the present invention is shown.
[0025] Figure 2 A schematic diagram illustrating the normal-abnormal decision boundary established according to an embodiment of the present invention is shown;
[0026] Figure 3 A flowchart illustrating the output anomaly heatmap of an embodiment of the present invention is shown. Detailed Implementation
[0027] To better understand the above-mentioned objects, features, and advantages of the present invention, such as Figures 1 to 3 As shown in the accompanying drawings and specific embodiments, the present invention will be further described in detail below. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0028] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0029] Figure 1 A schematic flowchart of an industrial visual anomaly detection method based on a low-dimensional latent space diffusion model, according to an embodiment of the present invention, is shown. Figure 1 As shown, this industrial visual anomaly detection method based on a low-dimensional latent space diffusion model includes:
[0030] Step S1: Input the sample to be detected into the trained latent space compression network to map the high-dimensional sample to be detected to a low-dimensional latent space, and obtain the latent space representation of the sample to be detected.
[0031] Step S2: Input the latent space representation of the sample to be detected into the trained defect classifier to obtain the noise intensity and denoising time step of the sample to be detected.
[0032] Step S3: Build and call the trained low-dimensional latent space diffusion model, and input the noise intensity and denoising time step of the sample to be detected into the trained low-dimensional latent space diffusion model to perform corresponding forward denoising and backward denoising reconstruction of the latent space representation of the sample to be detected.
[0033] Step S4: Using the latent space representation of the sample to be detected after denoising and reconstruction as the reference distribution and the latent space representation of the sample to be detected as the target distribution, an adaptive threshold mechanism is adopted to set dynamic thresholds for the low-level features and high-level features output by the latent space compression network, and then the local anomaly score and global anomaly score are obtained based on the dynamic thresholds, so as to calculate the pixel-level local anomalies and semantic-level global anomalies between the reference distribution and the target distribution respectively.
[0034] Step S5: After fusing the local anomaly scores and the global anomaly scores, output an anomaly heatmap, and then output the anomaly detection results based on the anomaly heatmap.
[0035] In this embodiment, the present invention processes samples in a low-dimensional latent space using a diffusion model, reducing the computational load and cost of the model. Within a compact latent space, it quickly separates normal and abnormal samples, improving the model's anomaly detection speed. Furthermore, the diffusion model employs an adaptive time step adjustment strategy to reduce model complexity and the number of inference steps. Moreover, by utilizing the distributional differences between anomalous and reconstructed images, an image anomaly score is obtained, and an adaptive threshold mechanism is introduced to dynamically adjust the anomaly score threshold, ultimately achieving more accurate anomaly detection results and improving the model's anomaly detection precision.
[0036] In one embodiment of the present invention, the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model further includes: before step S1: constructing a latent space compression network and training the latent space compression network based on normal samples; wherein, during the training process of the latent space compression network, the latent space compression network uses normal samples to learn the mapping relationship from high-dimensional space to low-dimensional latent space, and introduces distribution consistency constraints and contrastive learning to make normal samples form a dense cluster in the low-dimensional latent space to establish a normal-anomaly decision boundary; the contrastive learning adopts hierarchical contrastive loss, so that the latent space compression network pays attention to local texture details and global semantic information at the same time; adopting hierarchical contrastive loss, so that the latent space compression network pays attention to local texture details and global semantic information at the same time, specifically includes: using local attention windows on the shallow features of normal samples to obtain pixel-level anomaly information, using channel attention on the mid-level features of normal samples to detect local structural anomalies, and applying global self-attention on the deep features of normal samples to identify semantic-level anomalies.
[0037] In one embodiment of the present invention, the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model further includes: before step S1: building a defect classifier and training the defect classifier based on synthesized anomaly samples; wherein, during the training of the defect classifier, the defect classifier learns the distribution of anomaly samples in the low-dimensional latent space, evaluates the defect type and severity of the anomaly samples, outputs the defect category probability distribution and severity score of the anomaly samples, and then executes an adaptive time step adjustment strategy according to the defect category probability distribution and severity score, dynamically setting the noise intensity and denoising time step; for anomaly samples with a mixture of severe and minor defects, a composite noise processing scheme is adopted, and the dynamic noise intensity and denoising time step are set differently according to the defect type and defect region; wherein, severe and minor defects are judged according to the severity score of the anomaly samples.
[0038] In one embodiment of the present invention, step S1 specifically involves: inputting the sample to be detected into a trained latent space compression network, so that the trained latent space compression network can map the high-dimensional sample to be detected to a low-dimensional latent space through multi-level downsampling and residual processing to obtain the latent space representation of the sample to be detected, so as to maintain the integrity of the spatial and semantic information of the sample to be detected.
[0039] In one embodiment of the present invention, in step S3, the training process of the low-dimensional latent space diffusion model only uses the latent space representation of normal samples for fitting learning, so that the low-dimensional latent space diffusion model only learns the latent space distribution law of normal samples and does not learn any defect features, so that the low-dimensional latent space diffusion model can only reconstruct the latent space representation of normal samples in the inference stage.
[0040] In one embodiment of the present invention, in step S4, the low-level features are high-resolution features output by the shallow layer encoding of the latent space compression network, used to locate pixel-level local anomalies; wherein, the low-level features include: image edges, color and texture information; the high-level features are low-resolution features output by the deep layer downsampling of the latent space compression network, used to determine semantic-level global anomalies at the overall image structure and semantic level.
[0041] In one embodiment of the present invention, in step S4, dynamic thresholds are set for the low-level features and high-level features output by the latent space compression network, specifically including: the low-level features calculate the feature distance matrix based on the cluster centers of normal samples, and then generate a local adaptive dynamic threshold through a weighted averaging strategy; the high-level features are modeled based on the Gaussian distribution of normal samples, and then generate a global semantic anomaly dynamic threshold through an exponential smoothing iteration method.
[0042] In one embodiment of the present invention, in step S5, after fusing the local anomaly score and the global anomaly score, an anomaly heatmap is output. Specifically, after fusing the local anomaly score and the global anomaly score, the fused anomaly score is mapped to the spatial location of the original image to output an anomaly heatmap; wherein, the severity of defects in the anomaly heatmap corresponds to the vividness of the color.
[0043] The present invention also proposes a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model in any of the above embodiments.
[0044] The present invention also proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model in any of the above embodiments.
[0045] The following specific embodiment will illustrate the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model of the present invention. This specific embodiment of the industrial visual anomaly detection method based on a low-dimensional latent space diffusion model specifically includes:
[0046] (1) Step 1: A latent space compression network is used to map high-dimensional anomalous images to a compact latent space through multi-level downsampling and residual processing, maintaining the integrity of image spatial and semantic information. Specifically, during the training phase of the latent space compression network, the network learns the mapping relationship from high-dimensional space to latent space using a large number of normal samples, such as... Figure 2 As shown, to obtain a unified normal-abnormal decision boundary in the latent space, distribution consistency constraints and contrastive learning are introduced to ensure that normal samples form dense clusters in the latent space while keeping potentially anomalous samples as unchanged as possible. Contrastive learning employs hierarchical contrastive loss, enabling the model to simultaneously focus on local texture details and global semantic information: shallow features utilize local attention windows to acquire pixel-level anomaly information, mid-level features use channel attention to guide the detection of local structural anomalies, and deep features apply global self-attention to identify semantic-level anomalies. The feature information acquired at each level involves both global and local information, effectively distinguishing between normal and anomalous samples and establishing a clear normal-abnormal decision boundary.
[0047] (2) Step 2: Build a defect classifier. The defect classifier synthesizes a large number of abnormal samples, learns the distribution of abnormal samples in the latent space, evaluates the defect type and severity of abnormal samples, and outputs the probability distribution of defect categories and severity scores of abnormal samples. Based on the identification of defect type and severity, differential noise is added to dynamically adjust the noise intensity and time step.
[0048] For samples with a mixture of severe and minor defects, a composite noise processing scheme is designed based on the dominant defect type and severity score: in complex defect regions, large-area defects are processed with large-scale noise and long-interval step sizes, while detailed defects are processed with small-scale noise and dense step sizes; for structural defects (such as large-area occlusion, deformation, etc.) that affect the overall structure, processing is performed in the early stages of denoising; local noise or artifacts are processed in the middle stages of denoising; and blurring or color deviations are finely adjusted in the later stages of denoising. The adaptive time step adjustment strategy makes the diffusion model more flexible and efficient, improving generalization ability and reconstruction quality while reducing computational load and training time.
[0049] (3) Step 3: Calculate the latent space anomaly score. Using the latent space representation of normal samples as the reference distribution and the latent space representation of abnormal samples as the target distribution, the anomaly score is obtained by calculating the distribution difference between them. To improve the detection capability of local anomalies, such as... Figure 3 As shown, a hierarchical computation scheme is adopted to use features at different levels to calculate the distribution differences between local and global features, and finally fuse them through learnable weights. This multi-granularity analysis enables the model to simultaneously detect pixel-level subtle anomalies and semantic-level high-level anomalies, reducing the influence of irrelevant factors and making anomalies easier to distinguish. Specifically, low-level features typically contain basic local information such as edges, colors, and textures, which facilitates the calculation of local anomaly scores for samples and captures pixel-level anomalies; while high-level features contain high-level semantic information, which can be used to calculate global anomaly scores for samples and measure the degree of deviation from high-level semantics. The adaptive threshold mechanism designed in this patent uses multi-level feature analysis to design dynamic threshold strategies for features at different levels (from low-level texture to high-level semantics), achieving the collaborative detection of pixel-level local anomalies and semantic-level global anomalies.
[0050] Specifically, such as Figure 3 As shown, the input image to be detected is fed into a feature extractor (i.e., a latent space compression network); the feature extractor (i.e., a latent space compression network) outputs a multi-scale feature map, which is then fed into a dynamic thresholding module; after processing by the dynamic thresholding module, global anomaly scores and local anomaly scores are obtained respectively; the global anomaly scores and local anomaly scores are fused and calculated to output an anomaly heatmap.
[0051] The dynamic threshold module contains two independent processing branches: The first branch receives low-level features, inputs them into a clustering unit to obtain cluster centers, constructs a feature distance matrix based on the cluster centers, and calculates the weighted average dynamic anomaly score threshold based on this feature distance matrix. The second branch receives high-level features, fits them to a Gaussian distribution to obtain a feature distribution sample point set, and iteratively updates the anomaly score threshold using an exponential smoothing method based on this distribution sample point set.
[0052] The weighted average dynamic anomaly score threshold and the exponentially smoothed anomaly score threshold are combined to calculate the local anomaly score and the global anomaly score respectively. Finally, the two types of anomaly scores are combined to output an anomaly heatmap, which is then used to output anomaly detection results in the future.
[0053] (4) Step 4: Weighted fusion of the low-level feature anomaly score distribution and the high-level feature anomaly score distribution to reflect the contribution of different features to the anomaly score. Then, the anomaly score is mapped to the spatial location of the original data, transforming the multidimensional anomaly detection result into a two-dimensional intuitive representation, forming a color-distinguished anomaly score heatmap. From the anomaly score heatmap, the range of the abnormal area of the image and the severity of the defect can be observed intuitively. The more severe the defect, the more vivid the color. The color gradient is easy to verify and can reduce the false detection rate and the missed detection rate.
[0054] In this specific embodiment, the present invention processes samples in a low-dimensional latent space using a diffusion model, which reduces the computational load and cost of the model. In a compact latent space, it quickly separates normal samples from abnormal samples, thereby improving the anomaly detection speed of the model.
[0055] In this specific embodiment, adding consistent noise to samples with varying degrees of anomalousness in traditional diffusion models wastes computational resources and results in suboptimal anomaly detection, which is detrimental to anomaly detection of diverse samples. Therefore, this specific embodiment designs an adaptive time step adjustment strategy, adding noise of different intensities to samples with different defect types, and setting different time intervals and step sizes to improve the reconstruction capability of the diffusion model and reduce the number of inference steps.
[0056] In this specific embodiment, the distribution difference between the abnormal image and the reconstructed image is used to obtain the image abnormality score, and an adaptive threshold mechanism is introduced to dynamically adjust the abnormality score threshold, ultimately obtaining a more accurate abnormality detection result and improving the abnormality detection accuracy of the model.
[0057] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. 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. An industrial visual anomaly detection method based on a low-dimensional latent space diffusion model, characterized in that, include: Step S1: Input the sample to be detected into the trained latent space compression network to map the high-dimensional sample to be detected to a low-dimensional latent space, thereby obtaining the latent space representation of the sample to be detected. Step S2: Input the latent space representation of the sample to be detected into the trained defect classifier to obtain the noise intensity and denoising time step of the sample to be detected; Step S3: Build and call the trained low-dimensional latent space diffusion model, and input the noise intensity and denoising time step of the sample to be detected into the trained low-dimensional latent space diffusion model to perform corresponding forward denoising and backward denoising reconstruction of the latent space representation of the sample to be detected. Step S4: Using the latent space representation of the sample to be detected after denoising and reconstruction as the reference distribution and the latent space representation of the sample to be detected as the target distribution, an adaptive threshold mechanism is adopted to set dynamic thresholds for the low-level features and high-level features output by the latent space compression network, and then the local anomaly score and global anomaly score are obtained based on the dynamic thresholds, so as to calculate the pixel-level local anomalies and semantic-level global anomalies between the reference distribution and the target distribution respectively. Step S5: After fusing the local anomaly scores and the global anomaly scores, output an anomaly heatmap, and then output the anomaly detection results based on the anomaly heatmap.
2. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 1, characterized in that, Also includes: Before step S1: Construct a latent space compression network and train the latent space compression network based on normal samples; wherein, during the training process of the latent space compression network, the latent space compression network uses normal samples to learn the mapping relationship from high-dimensional space to low-dimensional latent space, and introduces distribution consistency constraints and contrastive learning to make normal samples form a dense cluster in the low-dimensional latent space to establish a normal-abnormal decision boundary. The contrastive learning employs hierarchical contrastive loss, enabling the latent space compression network to simultaneously focus on local texture details and global semantic information. The hierarchical contrast loss is adopted so that the latent space compression network can simultaneously focus on local texture details and global semantic information. Specifically, it includes: using local attention windows to obtain pixel-level anomaly information for shallow features of normal samples, using channel attention to detect local structural anomalies for mid-level features of normal samples, and applying global self-attention to identify semantic-level anomalies for deep features of normal samples.
3. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 1, characterized in that, Also includes: Before step S1: A defect classifier is built and trained based on the synthesized abnormal samples; wherein, during the training of the defect classifier, the defect classifier learns the distribution of abnormal samples in the low-dimensional latent space, evaluates the defect type and severity of the abnormal samples, outputs the defect category probability distribution and severity score of the abnormal samples, and then executes the time step adaptive adjustment strategy according to the defect category probability distribution and severity score, dynamically setting the noise intensity and denoising time step; For abnormal samples with a mixture of severe and minor defects, a composite noise processing scheme is adopted. The dynamic noise intensity and denoising time step are set differently according to the defect type and defect area. Among them, severe and minor defects are judged based on the severity score of the abnormal sample.
4. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 1, characterized in that, Step S1 specifically involves inputting the sample to be detected into the trained latent space compression network, so that the trained latent space compression network can map the high-dimensional sample to be detected into a low-dimensional latent space through multi-level downsampling and residual processing to obtain the latent space representation of the sample to be detected, so as to maintain the integrity of the spatial and semantic information of the sample to be detected.
5. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 1, characterized in that, In step S3, the training process of the low-dimensional latent space diffusion model only uses the latent space representation of normal samples for fitting learning, so that the low-dimensional latent space diffusion model only learns the latent space distribution law of normal samples and does not learn any defect features, so that the low-dimensional latent space diffusion model can only reconstruct the latent space representation of normal samples in the inference stage.
6. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 1, characterized in that, In step S4, the low-level features are high-resolution features output by the shallow coding layer of the latent space compression network, used to locate pixel-level local anomalies; wherein, the low-level features include: image edges, color and texture information; The high-level features are low-resolution features output by multiple downsamplings in the deep layers of the latent space compression network, used to determine semantic-level global anomalies in the overall graph structure and semantic level.
7. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to claim 6, characterized in that, In step S4, dynamic thresholds are set for the low-level and high-level features output by the latent space compression network, specifically including: The low-level features are calculated based on the feature distance matrix of the cluster centers of normal samples, and then a local adaptive dynamic threshold is generated through a weighted averaging strategy. The high-level features are modeled using a Gaussian distribution based on normal samples, and then an exponential smoothing iterative method is used to generate a global semantic anomaly dynamic threshold.
8. The industrial visual anomaly detection method based on a low-dimensional latent space diffusion model according to any one of claims 1 to 7, characterized in that, In step S5, after fusing the local anomaly scores and the global anomaly scores, an anomaly heatmap is output. Specifically, after fusing the local anomaly scores and the global anomaly scores, the fused anomaly scores are mapped to the spatial location of the original image, and an anomaly heatmap is output. The severity of defects in the abnormal heat map corresponds to the vividness of the color.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 8.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.