Unsupervised OOD detection method and device based on hierarchical semantic reconstruction of diffusion model
By using a layered semantic reconstruction method based on a diffusion model, and utilizing a latent feature diffusion network for multi-layer feature reconstruction, the problem of low computational efficiency in existing unsupervised OOD detection is solved, and a highly efficient OOD detection effect is achieved.
Patent Information
- Application Number
- CN202411372461.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-09-29
AI Technical Summary
Existing unsupervised OOD detection methods are computationally inefficient and cannot accurately capture sample distribution, resulting in long detection times.
A hierarchical semantic reconstruction method based on a diffusion model is adopted. Through multi-layer feature extraction and layer-by-layer semantic feature reconstruction, feature reconstruction is performed using a latent feature diffusion network, and OOD detection is performed using the reconstruction error.
It significantly improves computational efficiency and detection rate, better distinguishes between ID and OOD samples, avoids reconstructing secondary features, and achieves effective OOD detection.
Smart Images

Figure CN119399762B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, specifically relating to an unsupervised OOD detection method and apparatus based on diffusion model-based hierarchical semantic reconstruction. Background Technology
[0002] Unsupervised out-of-distribution (OOD) detection aims to determine whether a data point belongs to an in-distribution (ID) or out-of-distribution dataset by learning only from unlabeled in-distribution training samples. OOD detection plays a crucial role in developing safe, real-world machine learning systems, ensuring that the model only operates on data from the same distribution as its training data. If the test data does not conform to the training distribution, the model may produce meaningless predictions, leading to misleading conclusions. Therefore, OOD detection is one of the key techniques for ensuring model robustness and safety.
[0003] Existing research mainly studies OOD detection in two settings: supervised and unsupervised methods. Supervised methods are typically classification-based, using the probability of the softmax activation function output of the final fully connected (FC) layer as a score to determine ID (In-Distribution) samples. However, classification-based OOD detection methods often encounter the problem of assigning the probability of high activation function outputs to OOD samples. For example, Liu et al. in “Hendrycks D, Gimpel K. A baseline for detecting misclassified and out-of-distribution examples in neural networks[J]. arXiv preprint arXiv:1610.02136, 2016.” and Sun et al. in “Sun Y, Li Y. Dice: Leveraging sparsification for out-of-distribution detection[C] / / European Conference on Computer Vision. Cham: Springer Nature Switzerland, 2022:691-708.” attempted to alleviate this problem. Unsupervised OOD detection can be broadly categorized into distance-based metric evaluation methods and generative model-based reconstruction methods. Distance-based methods assume that OOD data is far from the center of the ID category. Ren et al., in their paper "Ren J, Fort S, Liu J, et al. A simple fix to mahalanobis distance for improving near-ood detection[J]. arXiv preprint arXiv:2106.09022, 2021," improved OOD detection by separating the foreground and background of the image, calculating the Mahalanobis distance separately, and then combining them. Techapanurak et al., in their paper "Techapanurak E, Suganuma M, Okatani T. Hyperparameter-free out-of-distribution detection using cosine similarity[C] / / Proceedings of the Asianconference on computer vision.2020," used cosine similarity to measure the distance between test data features and ID data to identify OOD data. These methods typically fail to accurately capture the sample distribution.In generative model-based methods, OOD detection leverages the idea that generative networks generate different reconstruction errors for ID and OOD data. For example, Sakurad et al. used autoencoders to analyze reconstruction errors in the paper "Sakurada M, Yairi T. Anomaly detection using autoencoders with nonlinear dimensionality reduction [C] / / Proceedings of the MLSDA 2014 2nd workshop on machine learning for sensory data analysis. 2014:4-11." GAN-based methods, such as those by Schlegl et al. in the paper "Schlegl T,..." P, Waldstein SM, et al. Unsupervised anomaly detection with generative adversarial networks to guide marker discovery [C] / / International conference on information processing in medical imaging. Cham: Springer International Publishing, 2017:146-157. This paper utilizes reconstruction error and a discriminator to detect anomalies. Similarly, Graham et al. in the paper "Graham MS, Pinaya WH L, Tudosiu PD, et al. Denoising diffusion models for out-of-distribution detection [C] / / Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition. 2023:2947-2956." applied a diffusion model to model the pixel-level distribution of an image and used the error from multiple reconstructions for OOD detection.
[0004] Existing research on OOD detection is time-consuming and computationally inefficient; therefore, this paper aims to provide an OOD detection method to improve upon the aforementioned shortcomings of existing technologies. Summary of the Invention
[0005] To address the aforementioned problems in the existing technology, this invention provides an unsupervised OOD detection method and apparatus based on hierarchical semantic reconstruction using a diffusion model. The technical problem to be solved by this invention is achieved through the following technical solution:
[0006] In a first aspect, the present invention provides an unsupervised OOD detection method based on hierarchical semantic reconstruction using a diffusion model, comprising:
[0007] Acquire the data to be tested;
[0008] The data to be detected is processed by a pre-defined processing model to extract multi-layer semantic features and obtain multi-layer features.
[0009] After normalizing and distorting the multi-layer features in sequence, the distorted multi-layer features are reconstructed layer by layer to obtain multi-layer reconstructed features.
[0010] The reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector is obtained. If the reconstruction error meets the preset conditions, the data to be detected is determined to be out-of-distribution data.
[0011] Secondly, the present invention also provides an unsupervised OOD detection device based on a diffusion model for hierarchical semantic reconstruction, comprising:
[0012] The data acquisition module is used to acquire the data to be detected.
[0013] Data processing module one is used to process the data to be detected through a preset processing model, so as to extract multi-layer semantic features from the data to be detected and obtain multi-layer features;
[0014] Data processing module two is used to normalize and distort the multi-layer features in sequence, and then reconstruct the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features.
[0015] The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vectors. If the reconstruction error meets the preset conditions, the data to be detected is determined to be out-of-distribution data.
[0016] The beneficial effects of this invention are:
[0017] This invention provides an unsupervised OOD detection method and apparatus based on a diffusion model and hierarchical semantic reconstruction. By extracting and reconstructing multi-layer features, feature reconstruction on multi-layer semantic features encourages the closer distribution of potential features within a specific space to better reconstruct features, while avoiding the reconstruction of OOD samples. This significantly improves computational efficiency and enables effective OOD detection, as well as increasing the detection rate. Furthermore, it avoids the reconstruction of secondary features that are irrelevant to image understanding.
[0018] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0019] Figure 1 This is a flowchart of an unsupervised OOD detection method based on diffusion model hierarchical semantic reconstruction provided in an embodiment of the present invention;
[0020] Figure 2 This is a schematic diagram of a processing model provided in an embodiment of the present invention;
[0021] Figure 3 This is a schematic diagram of a residual block provided in an embodiment of the present invention. Detailed Implementation
[0022] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0023] Please see Figure 1 , Figure 1 This is a flowchart of an unsupervised OOD detection method based on a diffusion model and hierarchical semantic reconstruction, provided in an embodiment of the present invention. The unsupervised OOD detection method based on a diffusion model and hierarchical semantic reconstruction provided by the present invention includes:
[0024] S101. Obtain the data to be detected.
[0025] Specifically, in this embodiment, the data to be detected can be an image.
[0026] S102. The data to be detected is processed by a preset processing model to extract multi-layer semantic features from the data to be detected, thereby obtaining multi-layer features.
[0027] S103. After normalizing and distorting the multi-layer features in sequence, the distorted multi-layer features are reconstructed layer by layer to obtain multi-layer reconstructed features.
[0028] Specifically, please see Figure 2 and Figure 3 , Figure 2 This is a schematic diagram of a processing model provided in an embodiment of the present invention. Figure 3 This is a schematic diagram of a residual block provided in an embodiment of the present invention. In this embodiment, before processing the data to be detected by a preset processing model, the following steps are also included:
[0029] Build a processing model;
[0030] By training the initial processing model and setting its parameters, a preset processing model is obtained.
[0031] The processing model includes an encoder, a normalization layer, and a latent feature diffusion network. The encoder receives the data to be detected at its input and extracts multi-layer features from the data. The normalization layer is connected to the encoder's output and normalizes the multi-layer features to obtain multi-layer feature vectors. Gaussian noise vectors are added to each layer of the multi-layer feature vectors to obtain multi-layer low-dimensional feature vectors. The latent feature diffusion network receives the multi-layer low-dimensional feature vectors and the embedding time step at its input and processes them to obtain multi-layer initial reconstructed features. The multi-layer initial reconstructed features are then sampled to obtain multi-layer reconstructed features.
[0032] In this embodiment, given an image x∈R 3×w×h w and h are the width and height of the image to be processed, respectively. The image is processed by an encoder, which extracts feature maps from different layers, from low-level to high-level semantic blocks. Optionally, the encoder can be a ResNet50, resulting in an M-layer feature F. m The feature representation of the m-th layer is as follows m∈{1,…,M}, where c m 、w m and h m Indicates the number, width, and height of channels; multi-layer feature F m Global average pooling is performed on the features to obtain a one-dimensional feature vector. Z-score normalization is applied to each feature vector. The normalized eigenvectors are represented as follows:
[0033]
[0034] Among them, Var(f m ) represents f m Along the variance of the channel elements, δ represents a very small constant, finally yielding a multi-layer eigenvector, the expression of which is:
[0035]
[0036] Here, H(x) represents the entire feature extraction process.
[0037] In this embodiment, the semantic feature distortion process can be defined as transforming semantic features into distorted correspondences with different noise levels. For each embedding time step t in [1,…,T], the expression for the multi-layer low-dimensional feature vector is:
[0038]
[0039] Where z0 represents the multi-layer feature vector, and t represents the embedding time step. This represents a predefined noise level used to control the amount of Gaussian noise added to each layer of low-dimensional feature vectors, where ε represents the Gaussian noise vector. Indicates a Gaussian distribution, 0 c I represents a c-dimensional zero-dimensional vector. c×c This represents a c×c identity matrix.
[0040] In this embodiment, in order to reconstruct semantic features from distorted semantic features, a Latent Feature Diffusion Network (LFDN) consisting of 16 residual blocks is constructed.
[0041] The latent feature diffusion network includes multiple residual blocks, each of which includes a first unit, a second unit, and a third unit. The first and second units have the same structure, each including a group normalization layer, a SiLU function, and a linear layer connected in sequence. The third unit includes a linear layer, a SiLU function, and a linear layer connected in sequence.
[0042] The input of the latent feature diffusion network receives multi-layer low-dimensional feature vectors and embedding time steps. These are used to process the multi-layer low-dimensional feature vectors and embedding time steps to obtain multi-layer initial reconstructed features, including:
[0043] Different residual blocks correspond to the processing of low-dimensional feature vectors from different layers;
[0044] The first unit processes the low-dimensional feature vector to obtain the first feature. The third unit processes the embedding time step to obtain the second feature. The first and second features are concatenated and the concatenated feature is input into the second unit for processing to obtain the third feature. The third feature is concatenated with the low-dimensional feature vector to obtain the initial reconstructed feature corresponding to the low-dimensional feature vector.
[0045] Based on the calculation process of the denoising diffusion implicit model, LFDN is used to remove noise injected into semantic features, with the skip step size denoted as s and z. t The detailed denoising process is described below, where s is set to a value randomly selected from {1,…,t}. After processing all residual blocks, multi-layer initial reconstructed features are obtained, whose expression is:
[0046]
[0047] in, z represents the initial reconstructed features of the multilayer network, LFDN(·) represents the feedforward process of the latent feature diffusion network, and z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
[0048] It should be noted that the latent feature diffusion model's proprietary time-step embedding refers to embedding time into multi-scale features through an MLP.
[0049] In this embodiment, the initial reconstructed features are sampled to obtain multi-layer reconstructed features, including:
[0050] By analyzing multi-layer low-dimensional feature vectors z t The noise correction vector is estimated, and its estimated value is... Represented as:
[0051]
[0052] in, Indicates a predefined noise level;
[0053] Based on the estimated value Multi-layer initial reconstruction features Sampling is performed, and the features after sampling are obtained. Represented as:
[0054]
[0055] in, The variance represents the added noise. This represents the predefined noise level corresponding to the embedded time step t', where t' = max(ts, 0);
[0056] Sampled features The corresponding embedding time step t' is input into the latent feature diffusion network for processing to predict the reconstructed features at time step t', and its expression is:
[0057]
[0058] From t' = t to t' = 0, we obtain the multi-layer reconstruction features, the expression of which is:
[0059]
[0060] Here, denoise(·) means denoising.
[0061] Understandably, using a latent feature diffusion network to reconstruct features ensures... It does not originate solely from the LFDN output, but is continuously improved by DDIM and integrates detailed corrections to achieve high accuracy in reconstructing the original data from noisy observations.
[0062] In an optional embodiment of the present invention, a preset processing model is obtained by training an initial processing model and setting the parameters of the processing model, including:
[0063] Obtain training samples;
[0064] The training samples are input into the initial processing model for iterative training. The loss function value is minimized within a preset number of iterations. The parameters of the processing model are then determined, and the preset processing model is obtained.
[0065] In this embodiment, to optimize the network parameters of LFDN, mean squared error is used as the loss function to bring the output of LFDN closer to the original semantic features. The expression for the loss function L is:
[0066]
[0067] Where N represents the total number of training samples, and x represents the data input to the processing model. z represents the three-dimensional features of the data input to the processing model, z0 represents the multi-layer feature vector, LFDN(·) represents the feedforward process of the latent feature diffusion network, and z t represents a multi-layer low-dimensional feature vector, and t represents the embedding time step.
[0068] During the iterative training process, t is randomly selected from {1,…,T}.
[0069] S104. Obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector. If the reconstruction error meets the preset conditions, then determine that the data to be detected is out-of-distribution data.
[0070] Specifically, in this embodiment, obtaining the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector includes:
[0071] The mean squared error (MSE) measures the reconstruction error of multi-layer reconstructed features and multi-layer eigenvectors.
[0072] Alternatively, the reconstruction error between multi-layer reconstructed features and multi-layer feature vectors can be measured using likelihood regret; where likelihood regret LR = MSE. initial -MSE final It quantifies the change in mean squared error from the initial iteration training to the final iteration training; it reflects the determinism of the model's continuous development during training. As the model becomes more familiar with ID samples, the reconstruction error of ID samples will decrease, while the reconstruction error of OOD samples will remain relatively stable.
[0073] Alternatively, the reconstruction error between multi-level reconstructed features and multi-level feature vectors can be measured using multi-level semantic similarity.
[0074] In this embodiment, the reconstruction error between multi-layer reconstructed features and multi-layer feature vectors is measured by multi-layer semantic similarity, including:
[0075] The cosine similarity between multi-layer reconstructed features and multi-layer features is calculated using the following expression:
[0076]
[0077] in, Represents the eigenvector. Represents reconstructed features;
[0078] The reconstruction error is calculated based on the cosine similarity, and its expression is as follows:
[0079]
[0080] Where M represents the number of feature maps.
[0081] Understandably, the lower the MFsim score, the more likely the detected data is to be within the distribution.
[0082] In summary, this invention provides an unsupervised OOD detection method based on a diffusion model and hierarchical semantic reconstruction. It introduces a diffusion model to reconstruct multi-scale features, leveraging the stable reconstruction capability of the diffusion model while establishing a comprehensive and discriminative feature representation. By designing a multi-layer semantic feature extraction strategy, feature reconstruction on multi-layer semantic features encourages a more compact distribution of latent features within a specific space, thus better reconstructing ID samples while avoiding the reconstruction of OOD samples. In general, by using Gaussian noise to distort the extracted multi-layer features and applying a diffusion model for feature reconstruction, the separation of ID and OOD samples is achieved based on the reconstruction error. It is noteworthy that the proposed Latent Feature Diffusion Network (LFDN) is built at the feature level, rather than the traditional pixel level, which significantly improves computational efficiency and enables effective OOD detection; furthermore, it avoids the reconstruction of secondary features irrelevant to image understanding.
[0083] In an optional embodiment of the present invention, the effectiveness of the unsupervised OOD detection method based on diffusion model hierarchical semantic reconstruction provided in the above embodiment is verified by simulation experiments, specifically as follows:
[0084] I. Simulation Conditions
[0085] The simulation experiment conditions in this embodiment include an Intel(R) Core(TM) i7-11700 CPU, an NVIDIA RTX 4090 GPU, and an Ubuntu 20.04 operating system, and the simulation is performed using PyTorch 1.8, an open-source software from Facebook.
[0086] II. Simulation Content and Result Analysis
[0087] Table 1 uses CIFAR-10 as the ID dataset to compare the proposed method with pixel-level generative model methods, including GLOW and PixelCNN++. To verify the effectiveness of LFDN, a variant of the proposed method was implemented by replacing LFDN with AutoEncoder and using MFsim to estimate the OOD score.
[0088] Compared to the best pixel-level method, VAE, the proposed method improves the average AUROC by 9.1% when using MFsim for OOD scoring estimation. Compared to DDPM, the proposed method variant shows a significant improvement in average AUROC. For example, when combined with MSE, the proposed method achieves a 20.4% higher AUROC than DDPM.
[0089] This indirectly shows that performing OOD detection at the pixel level is far less effective than performing it at the feature level. Generating pixels may reconstruct more content unrelated to the image's semantics, which could interfere with the recognition of OOD samples. Focusing the model on reconstructing compactly distributed semantic features helps distinguish between ID and OOD samples.
[0090] In terms of testing speed, the method proposed in this invention is nearly 100 times faster than DDPM, significantly improving performance and reducing detection costs. Furthermore, the final version of the method proposed in this invention, based on LFDN, achieves an average AUROC improvement of 18.5% compared to the AutoEncoder-based variant, because the diffusion model more effectively captures the data distribution.
[0091] Table 2 compares the proposed method with VAE, DDPM, and AutoEncoder, using CelebA as the ID dataset. The proposed method, combined with MFsim, achieves state-of-the-art performance, improving AUROC by 19.89% compared to DDPM, and significantly outperforming the baseline in the other two metrics, demonstrating the general applicability of the proposed method.
[0092] Table 1 shows the comparison of AUROC for OOD detection when CIFAR10 is an ID dataset with generation-based methods.
[0093]
[0094] Table 2 shows the performance of AUROC for OOD detection when CelebA is an ID dataset, compared to generation-based methods.
[0095]
[0096] Similarly, when CelebA is the distribution, the method proposed in this invention still has significant advantages.
[0097] Based on the same inventive concept, this invention also provides an unsupervised OOD detection device based on a diffusion model and hierarchical semantic reconstruction, used to implement the unsupervised OOD detection method based on a diffusion model and hierarchical semantic reconstruction provided in the above embodiments of this invention. Implementation examples of the method are described above and will not be repeated here. The device includes:
[0098] The data acquisition module is used to acquire the data to be detected.
[0099] Data processing module one is used to process the data to be detected through a preset processing model, so as to extract multi-layer semantic features from the data to be detected and obtain multi-layer features;
[0100] Data processing module two is used to normalize and distort the multi-layer features in sequence, and then reconstruct the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features.
[0101] The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vectors. If the reconstruction error meets the preset conditions, the detected data is determined to be out-of-distribution data.
[0102] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that an article or device comprising a list of elements includes not only those elements but also other elements not expressly listed. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or device comprising said element. Terms such as "connected" or "linked" are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect. The orientations or positional relationships indicated by terms such as "upper," "lower," "left," and "right" are based on the orientations or positional relationships shown in the accompanying drawings and are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as limiting the invention.
[0103] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.
[0104] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. An unsupervised OOD detection method based on hierarchical semantic reconstruction using a diffusion model, characterized in that, include: Acquire the data to be detected; the data to be detected is an image; The data to be detected is processed by a preset processing model to extract multi-layer semantic features from the data to be detected, thereby obtaining multi-layer features; The multi-layer features are normalized and distorted sequentially, and the distorted multi-layer features are reconstructed layer by layer to obtain multi-layer reconstructed features. The reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector is obtained. If the reconstruction error meets the preset conditions, the data to be detected is determined to be out-of-distribution data. Before processing the data to be detected using a preset processing model, the method further includes: Build a processing model; By training the initial processing model and setting the parameters of the processing model, the preset processing model is obtained. The processing model includes an encoder, a normalization layer, and a latent feature diffusion network. The encoder receives the data to be detected at its input and extracts multi-layer features from the data. The normalization layer's input is connected to the encoder's output and normalizes the multi-layer features to obtain multi-layer feature vectors. Gaussian noise is added to each layer of the multi-layer feature vectors to obtain multi-layer low-dimensional feature vectors. The latent feature diffusion network receives the multi-layer low-dimensional feature vectors and an embedding time step at its input and processes them to obtain multi-layer initial reconstruction features. The multi-layer initial reconstruction features are then sampled to obtain multi-layer reconstructed features. The latent feature diffusion network includes multiple residual blocks, each comprising a first unit, a second unit, and a third unit. The first and second units have identical structures, each including a group normalization layer, a SiLU function, and a linear layer connected in sequence. The third unit includes a linear layer, a SiLU function, and a linear layer connected in sequence. The input of the latent feature diffusion network receives the multi-layer low-dimensional feature vector and the embedding time step, and processes the multi-layer low-dimensional feature vector and the embedding time step to obtain multi-layer initial reconstructed features, including: Different residual blocks correspond to the processing of low-dimensional feature vectors from different layers; The first unit processes the low-dimensional feature vector to obtain a first feature, the third unit processes the embedding time step to obtain a second feature, the first feature and the second feature are concatenated, the concatenated feature is input into the second unit for processing to obtain a third feature, and the third feature is concatenated with the low-dimensional feature vector to obtain the initial reconstructed feature corresponding to the low-dimensional feature vector. After processing all the residual blocks, the multi-layer initial reconstruction features are obtained, and their expression is: ; in, Represents multi-layer initial reconstruction features. This represents the feedforward process of a latent feature diffusion network. Represents multi-layer low-dimensional feature vectors. This indicates the embedded time step.
2. The unsupervised OOD detection method based on diffusion model-driven hierarchical semantic reconstruction according to claim 1, characterized in that, The expression for the multi-layer low-dimensional feature vector is: ; in, Represents multi-layer feature vectors, Indicates embedded time steps, This represents a predefined noise level used to control the amount of Gaussian noise added to the low-dimensional feature vectors of each layer. Represents a Gaussian noise vector. Indicates a Gaussian distribution. express Zero-dimensional zero vector express Identity matrix.
3. The unsupervised OOD detection method based on diffusion model-driven hierarchical semantic reconstruction according to claim 2, characterized in that, The sampling of the initial reconstructed features to obtain multi-layer reconstructed features includes: By analyzing the multi-layer low-dimensional feature vectors The noise correction vector is estimated, and its estimated value is... Expressed as: ; in, Indicates a predefined noise level; Based on the estimated value For multi-layer initial reconstruction features Sampling is performed, and the features after sampling are obtained. Represented as: ; in, The variance represents the added noise. Indicates embedded time steps The corresponding predefined noise level, ; Sampled features Its corresponding time step The input is fed into the latent feature diffusion network for processing to predict the first... The reconstruction features are expressed as follows: ; from Until The multi-layer reconstruction feature is obtained, and its expression is: ; in, This indicates noise reduction.
4. The unsupervised OOD detection method based on diffusion model-driven hierarchical semantic reconstruction according to claim 1, characterized in that, The step of training an initial processing model and setting the parameters of the processing model to obtain the preset processing model includes: Obtain training samples; The training samples are input into the initial processing model for iterative training. The loss function value is minimized within a preset number of iterations. The parameters of the processing model are then determined, and the preset processing model is obtained.
5. The unsupervised OOD detection method based on diffusion model and hierarchical semantic reconstruction according to claim 4, characterized in that, The loss function The expression is: ; in, This represents the total number of training samples. This represents the data input to the processing model. This represents the three-dimensional features of the data input to the processing model. Represents multi-layer feature vectors, This represents the feedforward process of a latent feature diffusion network. Represents multi-layer low-dimensional feature vectors. This indicates the embedded time step.
6. The unsupervised OOD detection method based on diffusion model-driven hierarchical semantic reconstruction according to claim 1, characterized in that, The step of obtaining the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector includes: The reconstruction error between the multi-layer reconstructed features and the multi-layer feature vector is measured by mean square error. Alternatively, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors can be measured by the likelihood regret measure. Alternatively, the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vector can be measured by multi-layer semantic similarity.
7. The unsupervised OOD detection method based on diffusion model hierarchical semantic reconstruction according to claim 6, characterized in that, The method of measuring the reconstruction error between the multi-layer reconstructed features and the multi-layer feature vectors through multi-layer semantic similarity includes: The cosine similarity between the multi-layer reconstructed features and the multi-layer features is calculated as follows: ; in, Represents the eigenvector. Represents reconstructed features; Based on the cosine similarity, the reconstruction error is calculated, and its expression is as follows: ; in, This indicates the number of feature maps.
8. An unsupervised OOD detection device based on a diffusion model and hierarchical semantic reconstruction, characterized in that, include: The data acquisition module is used to acquire the data to be detected; the data to be detected is an image. Data processing module one is used to process the data to be detected through a preset processing model, so as to extract multi-layer semantic features from the data to be detected and obtain multi-layer features; Before processing the data to be detected using a preset processing model, the method further includes: Build a processing model; By training the initial processing model and setting the parameters of the processing model, the preset processing model is obtained. The processing model includes an encoder, a normalization layer, and a latent feature diffusion network. The encoder receives the data to be detected at its input and extracts multi-layer features from the data. The normalization layer's input is connected to the encoder's output and normalizes the multi-layer features to obtain multi-layer feature vectors. Gaussian noise is added to each layer of the multi-layer feature vectors to obtain multi-layer low-dimensional feature vectors. The latent feature diffusion network receives the multi-layer low-dimensional feature vectors and an embedding time step at its input and processes them to obtain multi-layer initial reconstruction features. The multi-layer initial reconstruction features are then sampled to obtain multi-layer reconstructed features. The latent feature diffusion network includes multiple residual blocks, each comprising a first unit, a second unit, and a third unit. The first and second units have identical structures, each including a group normalization layer, a SiLU function, and a linear layer connected in sequence. The third unit includes a linear layer, a SiLU function, and a linear layer connected in sequence. The input of the latent feature diffusion network receives the multi-layer low-dimensional feature vector and the embedding time step, and processes the multi-layer low-dimensional feature vector and the embedding time step to obtain multi-layer initial reconstructed features, including: Different residual blocks correspond to the processing of low-dimensional feature vectors from different layers; The first unit processes the low-dimensional feature vector to obtain a first feature, the third unit processes the embedding time step to obtain a second feature, the first feature and the second feature are concatenated, the concatenated feature is input into the second unit for processing to obtain a third feature, and the third feature is concatenated with the low-dimensional feature vector to obtain the initial reconstructed feature corresponding to the low-dimensional feature vector. After processing all the residual blocks, the multi-layer initial reconstruction features are obtained, and their expression is: ; in, Represents multi-layer initial reconstruction features. This represents the feedforward process of a latent feature diffusion network. Represents multi-layer low-dimensional feature vectors. Indicates the embedded time step; Data processing module two is used to normalize and distort the multi-layer features in sequence, and then reconstruct the semantic features of the distorted multi-layer features layer by layer to obtain multi-layer reconstructed features; The data judgment module is used to obtain the reconstruction error between the multi-layer reconstructed features and the normalized multi-layer feature vector. If the reconstruction error meets the preset conditions, the data to be detected is determined to be out-of-distribution data.
Citation Information
Patent Citations
Unknown-class (out-of-distribution) data detection in machine learning models
US20240095537A1
Systems and methods for text-to-image generation using language models
US20240185035A1