A frequency-space dual-domain-based normalized flow anomaly detection method and system
Patent Information
- Application Number
- CN202611169426.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2046-08-04
AI Technical Summary
[0008]本发明提供一种基于频空双域的归一化流异常检测方法及系统,解决现有归一化流异常检测方法因局部感受野局限导致全局异常检测能力不足、频域信息利用不充分、频域与空间域特征处理割裂以及缺乏多尺度频域联合建模能力等技术问题
1.本发明将二维离散傅里叶变换表示为矩阵乘法形式并封装为可微分的可逆神经网络层,利用傅里叶矩阵的正交性保证变换严格可逆且雅可比行列式为常数,梯度可通过逆傅里叶变换精确高效地反向传播,计算复杂度较低。
Smart Images

Figure CN122676272B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of anomaly detection technology, and more specifically, to a normalized flow anomaly detection method and system based on frequency-space dual domain. Background Technology
[0002] Deep learning models are widely used in industrial anomaly detection tasks. Among them, anomaly detection methods based on normalized flow have received widespread attention in recent years due to their advantages such as accurate calculation of the log-likelihood of data and realization of invertible mapping. This type of method constructs an invertible neural network to map the input image to a standard Gaussian distribution in the latent space and uses the likelihood value as an anomaly score for discrimination.
[0003] However, existing anomaly detection methods based on normalized flow mainly suffer from the following technical shortcomings: I. Limited local receptive field leads to insufficient global anomaly detection capability. Traditional normalized flow models use convolution-based coupling layers for feature transformation, and their receptive field is limited by the size of the convolution kernel. For periodic texture anomalies and global structural anomalies (such as large-area deformation and global pattern shift), these patterns are widely distributed in the spatial domain, making it difficult for local convolution to effectively capture them. Although the receptive field can be expanded by stacking a large number of coupling layers, this results in a huge number of model parameters, difficult training, and a significant increase in computational cost.
[0004] Second, insufficient utilization of frequency domain information. The energy of an image exhibits a highly structured distribution in the frequency domain: low-frequency components concentrate the global structural information of the image, while high-frequency components contain details and texture information. Periodic textures manifest as discrete spectral peaks in the frequency domain, while anomalies often introduce new frequency components or alter the amplitude of existing peaks. Traditional spatial domain normalized flow cannot directly utilize this frequency domain structured feature, resulting in insufficient sensitivity for detecting texture-related anomalies.
[0005] Third, the processing of features in the frequency domain and the spatial domain is fragmented. Some existing methods use Fourier transform as a fixed preprocessing step, first transforming the image to the frequency domain to extract features, and then feeding it into the subsequent network modeling. This two-stage method has an information transmission bottleneck: frequency domain preprocessing and subsequent model training are independent of each other, lacking a joint optimization mechanism. The model cannot adaptively determine which domain to perform the optimal feature transformation, resulting in the potential of frequency domain features not being fully explored.
[0006] Fourth, there is a lack of joint modeling capabilities for multi-scale frequency domain features. Anomalies at different scales in an image correspond to components in different frequency ranges. Existing methods lack mechanisms for flexible information exchange and differentiated processing between different frequency bands, making it difficult to simultaneously detect both low-frequency global structural anomalies and high-frequency detail texture anomalies.
[0007] In summary, existing anomaly detection methods based on normalized flow have significant shortcomings in terms of receptive field range, frequency domain information utilization, inter-feature domain collaborative processing capability, and multi-scale modeling. There is an urgent need for a novel anomaly detection technology that can organically integrate Fourier transform into a normalized flow reversible architecture and achieve end-to-end collaborative processing of the spatial and frequency domains under a unified framework. Summary of the Invention
[0008] This invention provides a normalized flow anomaly detection method and system based on frequency and space domains, which solves the technical problems of existing normalized flow anomaly detection methods, such as insufficient global anomaly detection capability due to the limitation of local receptive field, insufficient utilization of frequency domain information, fragmented feature processing of frequency and spatial domains, and lack of multi-scale frequency domain joint modeling capability.
[0009] In a first aspect, embodiments of the present invention provide a normalized flow anomaly detection method based on frequency-space dual domain, the method comprising the following steps: A multi-domain alternating normalized flow model is constructed, in which the frequency-space dual-domain invertible module and the spatial domain coupling layer are alternately stacked in a multi-scale architecture. The frequency-space dual-domain reversible module is used to perform global feature transformation in the frequency domain to capture periodic texture and global structural information; The spatial domain coupling layer is used to perform local feature transformation in the spatial domain to capture local texture and edge information; By maximizing the log-likelihood of normal sample images, end-to-end joint optimization of the multi-domain alternating normalized flow model is achieved. Anomaly detection is performed on test sample images using a multi-domain alternating normalized flow model that is jointly optimized end-to-end.
[0010] In the above embodiments, the present invention constructs a multi-domain alternating normalized flow model by alternately stacking a frequency-space dual-domain reversible module and a spatial domain coupling layer in a multi-scale architecture, so that the model has both the global receptive field in the frequency domain and the local accuracy in the spatial domain: the frequency-space dual-domain reversible module uses the global basis properties of Fourier transform to capture periodic textures and global structural anomalies; the spatial domain coupling layer retains the fine modeling ability of local textures and edges, and the two work together to achieve full coverage detection of multiple types of anomalies.
[0011] As some optional embodiments of this application, each scale layer of the multi-domain alternating normalized flow model includes a sequentially cascaded activation normalization layer, a spatial domain coupling layer, a frequency-space dual-domain invertible module, an activation normalization layer, and a spatial domain coupling layer.
[0012] In the above embodiments, the present invention completes local feature extraction and fine-tuning through two spatial domain coupling layers at the beginning and end, respectively, and inserts a frequency-space dual-domain reversible module in the middle to realize global frequency domain transformation, forming a "local-global-local" feature learning closed loop. Two activation normalization layers are placed before and after the spatial domain coupling and frequency domain transformation, respectively, which effectively suppresses the distribution drift caused by domain switching and ensures a smooth transition and training stability between frequency domain and spatial domain features in deep networks.
[0013] As some optional embodiments of this application, the frequency-space dual-domain reversible module includes a sequentially cascaded reversible Fourier layer, a frequency domain reversible transform module, and an inverse Fourier layer. The reversible Fourier layer is used to transform the input image from the spatial domain to the frequency domain to obtain a frequency domain complex tensor. The frequency domain reversible transformation module is used to perform frequency domain nonlinear transformation on the frequency domain complex tensor to obtain frequency domain features; The inverse Fourier layer is used to transform the frequency domain features to the spatial domain to obtain spatial domain features.
[0014] In the above embodiments, the invertible Fourier layer of the present invention utilizes the orthogonality of the Fourier matrix to transform the input image from the spatial domain to the frequency domain, enabling the model to naturally obtain a global receptive field without the need to stack a large number of convolutional layers. The frequency domain invertible transformation module performs an affine coupling transformation on the complex tensor in the frequency domain, and realizes the differential processing of low-frequency global structure and high-frequency detail texture through frequency coordinate position encoding. The inverse Fourier layer accurately and losslessly transforms the transformed frequency domain features back to the spatial domain, ensuring that the module output is consistent with the input domain of the subsequent spatial domain coupling layer. Since the logarithmic Jacobian determinant of both the invertible Fourier layer and the inverse Fourier layer is zero, the overall logarithmic determinant of this module is contributed only by the frequency domain invertible transformation, which is computationally simple and does not increase the determinant burden of the flow model, achieving a unity of global receptive field, strict invertibility and computational efficiency.
[0015] As some optional implementations of this application, the end-to-end joint optimization process of the multi-domain alternating normalized flow model is as follows: Normal sample images are input into a multi-domain alternating normalization flow model, which passes through multiple scale levels in sequence. Within each scale level, activation normalization, spatial domain affine coupling, frequency-space dual-domain invertible transformation, activation normalization, and spatial domain affine coupling are performed sequentially, and finally mapped to latent spatial variables. At the same time, the log-Jacobi determinant of each scale level is accumulated to calculate the log-likelihood of the normal sample images. Based on the log-likelihood of multiple batches of normal sample images, a negative log-likelihood loss function for a multi-domain alternating normalized flow model is constructed, and model training of the multi-domain alternating normalized flow model is achieved by minimizing the negative log-likelihood loss function.
[0016] In the above embodiments, the present invention enables the model to adaptively learn the optimal frequency-space feature transformation strategy based on minimizing the multi-batch negative log-likelihood loss function, thereby improving the detection capability for multiple types of anomalies.
[0017] As some optional implementations of this application, the anomaly detection process is as follows: Input the test sample image into the trained multi-domain alternating normalized flow model, calculate the negative log-likelihood, and use the negative log-likelihood as the anomaly score of the test sample image. An abnormal score is determined by a threshold. If the abnormal score is greater than the preset threshold, an abnormality is determined to exist; otherwise, no abnormality is determined.
[0018] In the above embodiments, the present invention makes a judgment by setting a threshold based on the mean and standard deviation of the abnormal scores of the normal sample set. It makes full use of the natural properties of normalized flow, which has high density aggregation of normal data and low likelihood of abnormal data. This allows periodic texture anomalies, global structural shifts and local minor defects to be sensitively distinguished under a unified score system. The detection process is simple and highly interpretable.
[0019] As one of the optional embodiments of this application, the negative log-likelihood loss function is expressed as: ; Among them, L NLL Let N represent the negative log-likelihood loss function, and let N represent the batch size of the normal sample set. logp θ (x (i) Let represent the log-likelihood of the i-th normal sample.
[0020] As some optional embodiments of this application, the abnormality score is represented as: ; Among them, S anomaly Represents the abnormal score, logp θ (x test ) represents the log-likelihood of the test sample image.
[0021] In the above embodiments, the normal sample images of the present invention have high log-likelihood and low outlier scores, while the abnormal sample images have low log-likelihood and high outlier scores. The threshold determination is intuitive and highly interpretable.
[0022] In a second aspect, the present invention provides a normalized flow anomaly detection system based on a frequency-space dual-domain approach, the system comprising: A normalized model unit is used to construct a multi-domain alternating normalized flow model, which alternately stacks frequency-space dual-domain invertible modules and spatial domain coupling layers in a multi-scale architecture. The frequency-space dual-domain reversible module is used to perform global feature transformation in the frequency domain to capture periodic texture and global structural information; The spatial domain coupling layer is used to perform local feature transformation in the spatial domain to capture local texture and edge information; The model training unit achieves end-to-end joint optimization of the multi-domain alternating normalized flow model by maximizing the log-likelihood of normal sample images. An anomaly detection unit performs anomaly detection on the test sample image using a multi-domain alternating normalized flow model that is jointly optimized end-to-end.
[0023] In a third aspect, the present invention provides a computer 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 aforementioned normalized flow anomaly detection method based on frequency-space dual domain.
[0024] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the normalized flow anomaly detection method based on frequency-space dual domain.
[0025] The beneficial effects of this invention are as follows: 1. This invention represents the two-dimensional discrete Fourier transform as a matrix multiplication form and encapsulates it into a differentiable invertible neural network layer. It utilizes the orthogonality of the Fourier matrix to ensure that the transformation is strictly invertible and the Jacobian determinant is constant. The gradient can be backpropagated accurately and efficiently through the inverse Fourier transform, resulting in low computational complexity.
[0026] 2. This invention cascades a reversible Fourier layer, a frequency domain reversible transform module, and an inverse Fourier layer to form a frequency-space dual-domain reversible module. This enables the multi-domain alternating normalization model to naturally possess a global receptive field when operating in the frequency domain. It can capture global structural information in one step without stacking a large number of convolutional layers. At the same time, it ensures that the frequency-space dual-domain reversible module is strictly reversible as a whole and that the logarithmic Jacobian determinant is simple and computable.
[0027] 3. This invention alternately stacks the frequency-space dual-domain module and the spatial domain coupling layer in a multi-scale framework, enabling the multi-domain alternating normalization model to adaptively switch between the spatial and frequency domains, while capturing local texture anomalies and global structural anomalies, thus achieving collaborative detection of multiple types of anomalies.
[0028] 4. Unlike the two-stage method that uses two-dimensional discrete Fourier transform as a fixed preprocessing, this invention uses invertible Fourier layers as differentiable layers of the network. Frequency domain and spatial domain parameters are jointly optimized under a unified loss function, eliminating the information transmission bottleneck and enabling the multi-domain alternating normalization model to adaptively learn the optimal frequency-space feature transformation strategy. Attached Figure Description
[0029] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 This is a flowchart of the normalized flow anomaly detection method described in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of the multi-domain alternating normalized flow model described in an embodiment of the present invention. Detailed Implementation
[0031] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0032] To overcome the shortcomings of existing technologies, this invention provides a normalized flow anomaly detection method based on frequency-space dual domain. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a flowchart of the normalized flow anomaly detection method. The method flow is as follows: S1: Construct a reversible Fourier layer.
[0033] In this embodiment of the invention, the two-dimensional discrete Fourier transform operation is encapsulated as a differentiable invertible neural network layer, denoted as the invertible Fourier layer F. DFT It is used to transform spatial domain features into frequency domain features.
[0034] Specifically, the two-dimensional discrete Fourier transform operation process is as follows: For the input image X∈R C×H×W C is the number of channels, H is the height, and W is the width. Its two-dimensional discrete Fourier transform is defined as: ; Where F(u,v) represents the frequency domain component, j represents the imaginary unit, X(x,y) represents the pixel value of the single-channel input image at spatial coordinates (x,y), u=0,1,…,H−1, v=0,1,…,W−1.
[0035] Furthermore, the two-dimensional discrete Fourier transform can be expressed in matrix multiplication form: ; Where F represents the frequency domain complex tensor, X represents the spatial domain image matrix, and W H W WThese represent the Fourier matrices in the height and width directions, respectively.
[0036] Furthermore, the Fourier matrices in the height and width directions are defined as follows: W H =exp(-j2πkn / H) k,n=0,…,H-1; W W =exp(-j2πkn / W) k,n=0,…,H-1; Therefore, both are collectively referred to as one-dimensional discrete Fourier matrices, and their general form is: W DFT =exp(-j2πkn / N) k,n=0,…,H-1; Where N is H or W, k represents the row index (corresponding to the frequency index), and n represents the column index (corresponding to the spatial index).
[0037] Furthermore, since the Fourier matrices satisfy the orthogonality condition: W DFT H ·W DFT =N·I; Among them, W DFT H Represents the Fourier matrix W DFT The conjugate transpose of W DFT Let I be an N×N Fourier matrix, and let W be the identity matrix. DFT H =exp(+j2πkn / N).
[0038] The two-dimensional discrete Fourier transform operation is strictly invertible, its inverse transform is the inverse Fourier transform, and the Jacobian determinant is a non-zero constant with a modulus of 1.
[0039] S2: Construct a frequency domain reversible transformation module.
[0040] In this embodiment of the invention, a reversible neural network is designed to perform frequency domain nonlinear transformation, and the reversible neural network is denoted as the frequency domain reversible transformation module gθ.
[0041] Specifically, the frequency domain nonlinear transformation process is as follows: The frequency domain complex tensor output by the two-dimensional discrete Fourier transform is decomposed into real and imaginary channels, forming frequency domain features, which are expressed as: ; Where Re(F) is the real part of the Fourier transform (corresponding to the cosine component) and Im(F) is the imaginary part (corresponding to the sine component). In order to ensure that a real image is obtained after the inverse transform back to the spatial domain, the frequency domain reversible transform module only operates on the low-frequency non-redundant frequency points. Since the Fourier transform of the real-valued signal has conjugate symmetry, only half of the frequency components need to be stored, and only W / 2+1 columns of frequency components need to be stored.
[0042] Furthermore, the frequency domain reversible transformation module adopts an affine coupling layer structure to transform the frequency domain features F freq Divided into two parts along the channel dimension F a and F b The scaling parameter s and the translation parameter t are determined by the sub-network NN (Neural Network) according to F. a calculate: ; Furthermore, the forward transform of the frequency domain reversible transform module is as follows: inverse transformation F a Remain unchanged. This represents element-wise multiplication. The sub-network NN uses the position encoding of the frequency coordinates (u,v) as additional input, enabling the frequency domain reversible transformation module to adaptively generate different transformation parameters according to the frequency position, thereby achieving differentiated processing of low-frequency global structure and high-frequency detail texture.
[0043] S3: Construct the inverse Fourier layer.
[0044] In this embodiment of the invention, the two-dimensional discrete inverse Fourier transform operation is encapsulated as a differentiable neural network layer, denoted as the inverse Fourier layer F. DFT -1 The inverse Fourier layer F DFT -1 With reversible Fourier layer F DFT These are exact inverse operations, used to transform frequency domain features back to the spatial domain, and the Jacobian determinant is a non-zero constant with a modulus of 1.
[0045] S4: Construct a frequency-space dual-domain reversible module.
[0046] In this embodiment of the invention, the reversible Fourier layer F DFT Frequency domain reversible transform module gθ and inverse Fourier layer F DFT -1 They are cascaded in sequence to form a frequency-space dual-domain reversible module.
[0047] Specifically, the complete forward transformation of the frequency-space dual-domain reversible module is as follows: ; The process involves first transforming the input image from the spatial domain to the frequency domain, performing a reversible nonlinear transformation in the frequency domain, and then transforming it back to the spatial domain. This is because the reversible Fourier layer F... DFT The strictly reversible and frequency-domain reversible transform module gθ is strictly reversible, therefore the composite transform is strictly reversible.
[0048] Specifically, the inverse transform of the frequency-space dual-domain reversible module is as follows: ; Specifically, according to the chain rule, the logarithmic Jacobian determinant of the frequency-space dual-domain invertible module is the sum of three parts: ; The first and third terms represent the reversible Fourier layer F, respectively. DFT and inverse Fourier layer F DFT -1 The logarithmic Jacobian determinant of the frequency domain transform is always zero (because the Fourier transform is a unitary transform, the modulus of the Jacobian determinant is 1, hence the logarithmic Jacobian determinant is 0). Therefore, the logarithmic Jacobian determinant of the frequency domain invertible transform module is equal to the logarithmic Jacobian determinant of the frequency domain transform gθ. ; This frequency-space dual-domain reversible module enables the multi-domain alternating normalized flow model to have a global receptive field when operating in the frequency domain: each frequency domain component F(u,v) corresponds to the global pattern of the entire image, and the model can capture global structural information in one step without stacking a large number of convolutional layers.
[0049] S5: Construct a multi-domain alternating normalized flow model.
[0050] In this embodiment of the invention, frequency-space dual-domain reversible modules and spatial domain coupling layers are alternately stacked to form a deep multi-domain alternating normalized flow network. The multi-domain alternating normalized flow model adopts a multi-scale architecture, with each scale containing an activation normalization layer (compressing spatial dimension information to channel dimension), a spatial domain coupling layer, and a frequency-space dual-domain reversible module. The activation normalization layer adopts an existing activation normalization structure in the normalized flow domain; the spatial coupling layer adopts an existing affine coupling layer structure in the normalized flow domain, and its internal structure is prior art, which is not modified in this embodiment of the invention. Please refer to [link to relevant documentation]. Figure 2 , Figure 2 This is a schematic diagram of the structure of the multi-domain alternating normalized flow model.
[0051] Specifically, at each scale level, the following reversible transformation layers are executed sequentially: (a) Activate the normalization layer, perform reversible affine normalization on each channel, and use a data-related initialization strategy to ensure training stability.
[0052] (b) Spatial domain coupling layer: adopts an affine coupling layer structure to perform local feature transformation in the spatial domain and capture local texture and edge information.
[0053] (c) Frequency-space dual-domain reversible module, which performs global feature transformation in the frequency domain to capture periodic texture and global structural information.
[0054] (d) Activate the normalization layer, perform reversible affine normalization on each channel, and use a data-related initialization strategy to ensure training stability.
[0055] (e) Spatial domain coupling layer: adopts an affine coupling layer structure to refine local features in the spatial domain.
[0056] Specifically, the number and size of the reversible transformation layer can be set according to the actual situation. This embodiment of the invention does not impose any restrictions on this. Preferably, the reversible transformation layer can be set to 3 layers.
[0057] Furthermore, the log-likelihood of the multi-domain alternating normalized flow model is: ; in, Let represent the probability density function of a standard Gaussian distribution, and z represent the latent spatial variables obtained by mapping the input image X, and satisfy ... L i Let K represent the i-th reversible transformation layer, and K represent the number of reversible transformation layers. Let represent the logarithmic Jacobian determinant of the i-th invertible transformation layer. This multi-domain alternation architecture enables the model to adaptively learn the joint distribution of spatial domain local patterns and frequency domain global patterns during end-to-end training.
[0058] S6: End-to-end training.
[0059] In this embodiment of the invention, the multi-domain alternating normalized flow model performs end-to-end joint optimization by minimizing the negative logarithmic loss function of the normal sample image.
[0060] Furthermore, the loss function is the negative log-likelihood loss function: ; Where N represents the batch size of the normal sample set, x (i) This represents the i-th normal sample image. The technical solution of this invention differs from the two-stage method that uses Fourier transform as a fixed preprocessing step. This invention embeds the invertible Fourier layer as a differentiable layer within a normalized flow network, and jointly optimizes the frequency domain transform and spatial domain parameters under a unified loss function.
[0061] Furthermore, the gradient of the multi-domain alternating normalized flow model can be precisely backpropagated via inverse Fourier transform: ;
[0062] in, The gradient of the loss function with respect to the frequency domain features is efficiently propagated to the input via inverse Fourier transform, with a computational complexity of O(n log n). This reduces the computational complexity of the Fast Fourier Transform and eliminates the information transmission bottleneck.
[0063] S7: Anomaly detection.
[0064] In this embodiment of the invention, after the multi-domain alternating normalized flow model has been trained, the test sample image x is... test Calculate its log-likelihood.
[0065] Furthermore, the outlier score is defined as the negative log-likelihood: ; Specifically, when the test sample image x test When the image is an anomalous sample, its latent spatial variable z test This will deviate from the standard Gaussian distribution, leading to an increase in the norm and an increase in outlier scores.
[0066] Furthermore, by setting a threshold τ for the test image x test Perform anomaly detection: ;
[0067] in, and The mean and standard deviation of the abnormal scores of the corresponding normal sample images in the normal sample set are respectively, where k represents the preset standard deviation multiple, which can be set according to the actual situation. This embodiment of the invention does not limit this.
[0068] Specifically, when If the condition is normal, it is considered abnormal; otherwise, it is considered normal.
[0069] Specifically, the global receptive field provided by the frequency-space dual-domain invertible module in the multi-domain alternating normalized flow model makes it particularly sensitive to periodic texture anomalies and global structural anomalies. The spatial domain coupling layer ensures the ability to detect local texture anomalies. The two work together to achieve comprehensive detection of multiple types of anomalies.
[0070] In summary, this invention effectively solves the problem of insufficient detection capability caused by the limitation of local receptive field and insufficient utilization of frequency domain information in existing normalized flow anomaly detection methods, and can significantly improve the detection capability of periodic texture anomalies, high-frequency subtle anomalies and global structural anomalies.
[0071] Furthermore, in one embodiment, based on the same inventive concept as the foregoing embodiments, this embodiment of the invention provides a normalized flow anomaly detection system based on frequency-space dual domains. The system corresponds one-to-one with the method described above, and includes: A normalized model unit is used to construct a multi-domain alternating normalized flow model, which alternately stacks frequency-space dual-domain invertible modules and spatial domain coupling layers in a multi-scale architecture. The frequency-space dual-domain reversible module is used to perform global feature transformation in the frequency domain to capture periodic texture and global structural information; The spatial domain coupling layer is used to perform local feature transformation in the spatial domain to capture local texture and edge information; The model training unit achieves end-to-end joint optimization of the multi-domain alternating normalized flow model by maximizing the log-likelihood of normal sample images. An anomaly detection unit performs anomaly detection on the test sample image using a multi-domain alternating normalized flow model that is jointly optimized end-to-end.
[0072] It should be noted that each unit in the normalized flow anomaly detection system in this embodiment corresponds one-to-one with each step in the normalized flow anomaly detection method in the aforementioned embodiment. Therefore, the specific implementation method and the technical effects achieved in this embodiment can be referred to the implementation method of the aforementioned normalized flow anomaly detection method, and will not be repeated here.
[0073] Furthermore, in one embodiment, this application also provides a computer device, the computer device including a processor, a memory, and a computer program stored in the memory, the computer program being executed by the processor to implement the methods in the foregoing embodiments.
[0074] In addition, in one embodiment, this application also provides a computer storage medium storing a computer program that is executed by a processor to implement the methods described in the foregoing embodiments.
[0075] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a device including one or any combination of the above-mentioned memories. The computer may be a variety of computing devices, including smart terminals and servers.
[0076] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0077] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0078] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0079] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0080] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a multimedia terminal device (which may be a mobile phone, computer, television receiver, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0081] The above are preferred embodiments of this application, and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application’s specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A normalized flow anomaly detection method based on frequency-space dual domain, characterized in that, The method includes the following steps: A multi-domain alternating normalized flow model is constructed, in which the frequency-space dual-domain invertible module and the spatial domain coupling layer are alternately stacked in a multi-scale architecture. The frequency-space dual-domain reversible module is used to perform global feature transformation in the frequency domain to capture periodic texture and global structural information; The spatial domain coupling layer adopts an affine coupling layer structure in the normalized flow domain, which is used to perform local feature transformation in the spatial domain and capture local texture and edge information. By maximizing the log-likelihood of normal sample images, end-to-end joint optimization of the multi-domain alternating normalized flow model is achieved. Anomaly detection was performed on the test sample images using a multi-domain alternating normalized flow model that was jointly optimized from end to end. Each scale layer of the multi-domain alternating normalized flow model includes a sequentially cascaded activation normalization layer, a spatial domain coupling layer, a frequency-space dual-domain invertible module, an activation normalization layer, and a spatial domain coupling layer. The frequency-space dual-domain reversible module includes a sequentially cascaded reversible Fourier layer, a frequency domain reversible transform module, and an inverse Fourier layer. The reversible Fourier layer is used to transform the input image from the spatial domain to the frequency domain to obtain a frequency domain complex tensor. The frequency domain reversible transformation module adopts a reversible neural network structure to perform frequency domain nonlinear transformation on the frequency domain complex tensor to obtain frequency domain features; The inverse Fourier layer is used to transform the frequency domain features to the spatial domain to obtain spatial domain features.
2. The normalized flow anomaly detection method based on frequency-space dual domain as described in claim 1, characterized in that, The end-to-end joint optimization process of the multi-domain alternating normalized flow model is as follows: Normal sample images are input into a multi-domain alternating normalization flow model, which passes through multiple scale levels in sequence. Within each scale level, activation normalization, spatial domain affine coupling, frequency-space dual-domain invertible transformation, activation normalization, and spatial domain affine coupling are performed sequentially, and finally mapped to latent spatial variables. At the same time, the log-Jacobi determinant of each scale level is accumulated to calculate the log-likelihood of the normal sample images. Based on the log-likelihood of multiple batches of normal sample images, a negative log-likelihood loss function for a multi-domain alternating normalized flow model is constructed, and model training is achieved by minimizing the negative log-likelihood loss function.
3. The normalized flow anomaly detection method based on frequency-space dual domain as described in claim 2, characterized in that, The anomaly detection process is as follows: Input the test sample image into the trained multi-domain alternating normalized flow model, calculate the negative log-likelihood, and use the negative log-likelihood as the anomaly score of the test sample image. An abnormal score is determined by a threshold. If the abnormal score is greater than the preset threshold, an abnormality is determined to exist; otherwise, no abnormality is determined.
4. The normalized flow anomaly detection method based on frequency-space dual domain as described in claim 1, characterized in that, The negative log-likelihood loss function is expressed as follows: ; Among them, L NLL Let N represent the negative log-likelihood loss function, and let N represent the batch size of the normal sample set. logp θ (x (i) Let represent the log-likelihood of the i-th normal sample.
5. The normalized flow anomaly detection method based on frequency-space dual domain as described in claim 3, characterized in that, The abnormal score is represented as: ; Among them, S anomaly Represents the abnormal score, logp θ (x test ) represents the log-likelihood of the test sample image.
6. A normalized flow anomaly detection system based on frequency-space dual domain for implementing the method of claim 1, characterized in that, The system includes: A normalized model unit is used to construct a multi-domain alternating normalized flow model, which alternately stacks frequency-space dual-domain invertible modules and spatial domain coupling layers in a multi-scale architecture. The frequency-space dual-domain reversible module is used to perform global feature transformation in the frequency domain to capture periodic texture and global structural information; The spatial domain coupling layer is used to perform local feature transformation in the spatial domain to capture local texture and edge information; The model training unit achieves end-to-end joint optimization of the multi-domain alternating normalized flow model by maximizing the log-likelihood of normal sample images. An anomaly detection unit performs anomaly detection on the test sample image using a multi-domain alternating normalized flow model that is jointly optimized end-to-end.
7. A computer 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 normalized flow anomaly detection method based on frequency-space dual domain as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the normalized flow anomaly detection method based on frequency-space dual domain as described in any one of claims 1-5.
Citation Information
Patent Citations
Industrial image unsupervised anomaly detection method and system based on normalized stream
CN121190416A
Industrial printed circuit board image defect detection method based on AI vision
CN122312603A