Long tail anomaly detection method and device based on parallel path reconstruction
By employing a parallel path reconstruction method, utilizing a twin reconstruction framework, a low-rank attention module, and parallel consistency loss, the lazy mapping problem of reconstructive anomaly detection models under long-tail data distribution is solved, improving the detection accuracy of tail categories and the overall reconstruction quality of the model. This method is applicable to multi-class anomaly detection tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN UNIV
- Filing Date
- 2026-03-11
- Publication Date
- 2026-07-28
AI Technical Summary
Existing reconstruction-based anomaly detection methods are prone to lazy mapping under long-tailed data distributions, which leads to the averageization of tail category reconstruction features. This severely weakens the model's sensitivity to subtle structural differences and makes it difficult to improve the detection accuracy of tail categories without sacrificing the performance of head classes.
We adopt a parallel path reconstruction-based approach, which optimizes the training process of the reconstruction model by constructing a twin reconstruction framework, a low-rank attention module, and a parallel consistency loss, thereby ensuring the detection accuracy of tail categories and the overall reconstruction quality of the model.
Under different types and intensities of long-tail distributions, it significantly improves the detection accuracy of tail categories, maintains the stability and reconstruction quality of the model, and is suitable for multi-class anomaly detection tasks.
Smart Images

Figure CN122473048A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of anomaly detection technology, and in particular to a long-tail anomaly detection method based on parallel path reconstruction, a long-tail anomaly detection device based on parallel path reconstruction, a computer-readable storage medium, and a computer device. Background Technology
[0002] Anomaly detection (AD), a crucial component of intelligent manufacturing and quality control, is widely applied in industrial inspection, medical image analysis, and intelligent monitoring. Its core objective is to identify potential anomalous regions by learning normal patterns when only normal samples are available. In recent years, reconstruction-based unsupervised anomaly detection methods have become the mainstream approach due to their strong interpretability and low training data requirements. These methods typically utilize structures such as autoencoders or visual transformers to reconstruct the input image and use the reconstruction error as a measure of anomaly to achieve pixel-level anomaly localization.
[0003] However, in real-world industrial environments, collected data often exhibits a significant long-tail distribution, meaning that some "head categories" have a sufficient number of samples, while "tail categories" have very few. This data imbalance causes the model to favor learning head category features during training, resulting in significant performance degradation for tail categories. Existing research has shown that reconstruction-based anomaly detection methods are prone to the so-called "lazy mapping" phenomenon in long-tail scenarios. This means that the model reconstructs almost identical results for different inputs and outputs, causing the reconstructed features of tail categories to become averaged and blurred. This severely weakens the model's sensitivity to subtle structural differences, ultimately leading to anomaly detection failure.
[0004] To address the problem of long-tailed data distribution, existing methods mainly optimize data resampling and loss reweighting. One type of method alleviates sample imbalance by oversampling the tail classes or undersampling the head classes, but this can easily lead to overfitting and disrupt inter-class relationships. Another type of method improves tail performance by increasing the loss weight of the tail classes or introducing class priors, but it is difficult to balance global feature consistency and local structure fidelity. In addition, most of these methods are designed for classification tasks and are not directly applicable to anomaly detection tasks that focus on pixel-level reconstruction.
[0005] Therefore, how to maintain the sensitivity of the reconstruction network to the tail classes, suppress lazy mapping, and improve the reconstruction diversity and detection accuracy of the tail classes without sacrificing the performance of the head classes has become a key problem that urgently needs to be solved in the field of long-tail anomaly detection. Summary of the Invention
[0006] This invention aims to at least partially solve one of the technical problems in the aforementioned technologies. Therefore, one objective of this invention is to propose a long-tail anomaly detection method based on parallel path reconstruction, which maintains highly stable anomaly detection performance under different types and intensities of long-tail distributions, significantly improving the detection accuracy of tail categories while also considering the overall model reconstruction quality. This method is applicable to multi-category anomaly detection tasks in various industrial vision scenarios.
[0007] A second objective of this invention is to provide a computer-readable storage medium.
[0008] The third objective of this invention is to provide a computer device.
[0009] The fourth objective of this invention is to propose a long-tail anomaly detection device based on parallel path reconstruction.
[0010] To achieve the above objectives, a first aspect of the present invention proposes a long-tail anomaly detection method based on parallel path reconstruction. The method includes the following steps: acquiring a detection dataset; constructing a reconstruction model, wherein the reconstruction model includes an encoder module, a bottleneck layer, and a decoder; performing data augmentation on sample images in the detection dataset to obtain augmented images; inputting the sample images into the encoder module for feature extraction to obtain first encoded features, and inputting the augmented images into the encoder module for feature extraction to obtain second encoded features; inputting the first encoded features and the second encoded features into the bottleneck layer for dimensionality reduction projection to filter redundant features, to obtain optimized first encoded features and optimized second encoded features; inputting the optimized first encoded features and optimized second encoded features into the decoder for reconstruction to obtain first decoded features and second decoded features; calculating reconstruction loss and parallel consistency loss based on the optimized first encoded features, optimized second encoded features, first decoded features, and second decoded features to obtain a total loss, and using the total loss to iteratively optimize and train the reconstruction model to obtain a trained anomaly detection model; and using the trained anomaly detection model to perform anomaly detection and output corresponding detection results.
[0011] The long-tail anomaly detection method based on parallel path reconstruction proposed in this invention has the following advantages: it can maintain highly stable anomaly detection performance under different types and intensities of long-tail distribution, significantly improve the detection accuracy of tail categories, and take into account the reconstruction quality of the overall model. It is applicable to multi-category anomaly detection tasks in various industrial vision scenarios.
[0012] In addition, the long-tail anomaly detection method based on parallel path reconstruction proposed in the above embodiments of the present invention may also have the following additional technical features: Optionally, data augmentation operations are performed on the sample images in the detection dataset to obtain enhanced images, including rotating, translating, and color perturbing the sample images in the detection dataset to obtain enhanced images.
[0013] Optionally, inputting the sample image into the encoder module for feature extraction to obtain a first encoded feature, and inputting the enhanced image into the encoder module for feature extraction to obtain a second encoded feature, includes: inputting the sample image into the encoder module for multi-layer feature extraction to obtain a first multi-scale feature, and performing layered fusion of the first multi-scale feature, processing it using a relaxed reconstruction method to obtain the first encoded feature; and inputting the enhanced image into the encoder module for multi-layer feature extraction to obtain a second multi-scale feature, and performing layered fusion of the second multi-scale feature, processing it using a relaxed reconstruction method to obtain the second encoded feature.
[0014] Optionally, the first and second encoded features are input into a bottleneck layer for dimensionality reduction projection to filter redundant features, thereby obtaining optimized first and second encoded features. This includes: using a bottleneck projection matrix to perform bottleneck projection on the first and second encoded features to obtain corresponding low-rank queries and keys; calculating the similarity between the queries and keys in the low-rank space to obtain an attention score matrix, and then normalizing it to attention weights using Softmax; using a value projection matrix to obtain the value matrices corresponding to the first and second encoded features; and obtaining optimized first and second encoded features corresponding to the first and second encoded features based on the attention weights and value matrices.
[0015] Optionally, the reconstruction loss can be calculated according to the following formula:
[0016]
[0017] in, This indicates the difference in features extracted by the encoder. This indicates the difference in features extracted by the decoder. Represents the calculation of cosine similarity. This represents the amplitude scaling constraint parameter, used to control the relationship between the characteristic variation amplitudes of the encoder and decoder. This represents the numerical stability constant, used to avoid the denominator being zero. Indicates directional loss. Indicates amplitude loss. This represents the loss of parallel consistency.
[0018] Optionally, the parallel consistency loss is calculated according to the following formula, including:
[0019]
[0020] in, This indicates the difference in features extracted by the encoder. This indicates the difference in features extracted by the decoder. Represents the calculation of cosine similarity. This represents the amplitude scaling constraint parameter, used to control the relationship between the characteristic variation amplitudes of the encoder and decoder. This represents the numerical stability constant, used to avoid the denominator being zero. Indicates directional loss. Indicates amplitude loss. This represents the loss of parallel consistency.
[0021] Alternatively, the total loss can be obtained using the following formula:
[0022] in, Indicates the total loss. Indicates the reconstruction loss. This represents the parallel consistency loss. This indicates dynamic weights.
[0023] To achieve the above objectives, a second aspect of the present invention provides a computer-readable storage medium storing a long-tail anomaly detection program based on parallel path reconstruction, which, when executed by a processor, implements the long-tail anomaly detection method based on parallel path reconstruction as described above.
[0024] To achieve the above objectives, a third aspect of 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. When the processor executes the program, it implements the long-tail anomaly detection method based on parallel path reconstruction as described above.
[0025] To achieve the above objectives, a fourth aspect of the present invention proposes a long-tail anomaly detection device based on parallel path reconstruction, comprising: an acquisition module for acquiring a detection dataset; a model building module for constructing a reconstruction model, wherein the reconstruction model includes an encoder module, a bottleneck layer, and a decoder; an enhancement module for performing data enhancement operations on sample images in the detection dataset to obtain enhanced images; a feature extraction module for inputting the sample images into the encoder module for feature extraction to obtain first encoded features, and inputting the enhanced images into the encoder module for feature extraction to obtain second encoded features; and a feature optimization module for inputting the first encoded features and the second encoded features into the bottleneck layer. The neck layer performs dimensionality reduction projection to filter redundant features, resulting in optimized first and second encoded features. A decoding module inputs the optimized first and second encoded features into the decoder for reconstruction, yielding first and second decoded features. A model training module calculates reconstruction loss and parallel consistency loss based on the optimized first and second encoded features, the first and second decoded features, to obtain a total loss. This total loss is then used to iteratively optimize and train the reconstruction model, resulting in a trained anomaly detection model. An anomaly detection module uses the trained anomaly detection model to perform anomaly detection and outputs the corresponding detection results. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating the long-tail anomaly detection method based on parallel path reconstruction according to an embodiment of the present invention. Figure 2 This is a flowchart illustrating a long-tail anomaly detection method based on parallel path reconstruction according to an embodiment of the present invention. Figure 3 This is a block diagram of a long-tailed anomaly detection device based on parallel path reconstruction according to an embodiment of the present invention. Detailed Implementation
[0027] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0028] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the invention to those skilled in the art.
[0029] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0030] refer to Figure 1 As shown, the long-tail anomaly detection method based on parallel path reconstruction according to an embodiment of the present invention includes the following steps: S101, Obtain the detection dataset.
[0031] It should be noted that long-tailed industrial anomaly detection datasets (such as MVTec-AD, VisA, and DAGM) include multiple categories of normal samples, and the number of samples in different categories is unbalanced (more samples in the head category and fewer samples in the tail category).
[0032] As an example, after obtaining the detection dataset, the images in the detection dataset are uniformly scaled to 448×448 and then cropped to 392×392 in the center to configure the PyTorch training environment and use an NVIDIA GeForceRTX 3090 GPU for training.
[0033] S102, Construct the reconstruction model, which includes an encoder module, a bottleneck layer, and a decoder.
[0034] In other words, a reconstruction network based on a visual Transformer or other autoencoder structure is built into the system. The model consists of three parts: a pre-trained frozen encoder module. Used for extracting multi-scale features; trainable bottleneck layer Decoder module used to perturb the latent space to prevent shortcut mapping and weight sharing. It is responsible for reconstructing from the latent space, and the initial parameters are loaded from the pre-trained weights.
[0035] S103, perform data augmentation on the sample images in the detection dataset to obtain augmented images.
[0036] As an example, data augmentation operations are performed on sample images in the detection dataset to obtain enhanced images, including rotating, translating, and color perturbing the sample images in the detection dataset to obtain enhanced images.
[0037] S104, the sample image is input into the encoder module for feature extraction to obtain the first encoded feature, and the enhanced image is input into the encoder module for feature extraction to obtain the second encoded feature.
[0038] As one embodiment, inputting a sample image into an encoder module for feature extraction to obtain a first encoded feature, and inputting an enhanced image into the encoder module for feature extraction to obtain a second encoded feature, includes: inputting a sample image into the encoder module for multi-layer feature extraction to obtain a first multi-scale feature, performing layered fusion of the first multi-scale feature, and processing it using a relaxation reconstruction method to obtain the first encoded feature; and inputting an enhanced image into the encoder module for multi-layer feature extraction to obtain a second multi-scale feature, performing layered fusion of the second multi-scale feature, and processing it using a relaxation reconstruction method to obtain the second encoded feature.
[0039] S105, input the first coding feature and the second coding feature into the bottleneck layer for dimensionality reduction projection to filter redundant features, so as to obtain the optimized first coding feature and the optimized second coding feature.
[0040] As one embodiment, the first and second encoded features are input into a bottleneck layer for dimensionality reduction projection to filter redundant features, thereby obtaining optimized first and second encoded features. This includes: using a bottleneck projection matrix to perform bottleneck projection on the first and second encoded features to obtain the corresponding low-rank queries and keys; calculating the similarity between the queries and keys in the low-rank space to obtain an attention score matrix, which is then normalized to attention weights using Softmax; using a value projection matrix to obtain the value matrices corresponding to the first and second encoded features; and obtaining the optimized first and second encoded features corresponding to the first and second encoded features based on the attention weights and the value matrices.
[0041] In other words, for long-tailed data distributions, to reduce the pressure of the head class on the learning of the tail class reconstruction function, a low-rank attention module is used, which reduces the feature dimensionality of the target through a bottleneck mapping layer. Since the head class accounts for the vast majority of data in the entire dataset, reducing redundancy through a low-rank approach allows for the removal of more redundant information from the head class, thus reducing its dominance over the model gradient.
[0042] S106, the optimized first coding feature and the optimized second coding feature are input into the decoder for reconstruction to obtain the first decoding feature and the second decoding feature.
[0043] S107. Calculate the reconstruction loss and parallel consistency loss based on the optimized first coding feature, optimized second coding feature, first decoding feature and second decoding feature to obtain the total loss. Use the total loss to iteratively optimize and train the reconstruction model to obtain the trained anomaly detection model.
[0044] As an example, S108 uses a trained anomaly detection model to perform anomaly detection and outputs the corresponding detection results.
[0045] To better understand the above technical solutions, such as Figure 2 As shown, a specific embodiment will be described in detail: Step 1: Data processing and environment configuration.
[0046] Specifically, step 1 includes: Step 1-1 considers using a single model to detect anomalies across multiple categories. Since the types of anomalies in the real world are diverse and inexhaustible, an unsupervised anomaly detection method is adopted, with the training set consisting entirely of normal sample images. During training, the normal paradigm of the samples is learned, and during testing, anomaly information is obtained by comparing the learned paradigm with the training set. However, in a long-tailed data distribution, the number of training images varies between different categories. Head classes have more training samples, while tail classes have fewer, exhibiting an unbalanced long-tailed distribution trend in the number of training samples across different categories. Specifically, we define... Represent each category The number of training samples determines the definition of the imbalance factor. .
[0047] Training dataset in experiments It is formed by splitting the MVTec-AD, VisA, and DAGM datasets according to different long-tail configurations.
[0048] MVTec Anomaly Detection (MVTec-AD) is one of the most classic and widely used unsupervised anomaly detection datasets in the field of industrial vision, primarily used to evaluate image-level and pixel-level anomaly recognition capabilities. This dataset contains 15 industrial categories, including 10 object classes (such as bottles, metal nuts, and planks) and 5 texture classes (such as tiles, grids, and carpets). Each category consists of a large number of normal samples and a small number of anomaly samples with various defect types, such as cracks, deformations, stains, damage, and contamination.
[0049] VisA is a large-scale industrial product anomaly detection dataset proposed in recent years, designed to more realistically simulate the difficulty of appearance inspection in complex industrial scenarios. The dataset contains 12 categories, covering real industrial products such as food, workpieces, and packaging materials.
[0050] The DAGM dataset originates from a computer vision competition organized by the German Association for Automation and Manufacturing (DAGM) and is a commonly used dataset in the field of industrial surface defect detection. This dataset contains 10 classes of industrial surface textures, each including normal samples and anomalous samples with specific defects.
[0051] Steps 1-2: All experiments were implemented using the PyTorch framework, running on an NVIDIA GeForce RTX 3090 GPU. Input images were uniformly scaled to 448×448, then cropped to 392×392. A stable AdamW optimizer was used for parameter updates, with a learning rate set to 8×10⁻⁶. -4 200 training rounds.
[0052] Step 2, model parameter initialization.
[0053] The model parameters were initialized using random initialization to construct a reconstructed model, which included a frozen pre-trained encoder, a bottleneck layer to be trained, and a decoder with shared weights. The encoder used DINOv2-R ViT-B / 14 and was trained on three datasets: MVTec-AD, VisA, and DAGM, with different long-tail configurations.
[0054] Step 3, image preprocessing.
[0055] The input image is first uniformly scaled to 448×448, and then centered to obtain 392×392. Next, a pre-trained feature extractor is used to modularize the image, with each module having a side length of 14, resulting in feature maps with a feature dimension of 768 and a size of 28×28.
[0056] Step 4, Twin Restructuring Framework.
[0057] For the input sample x, perform data augmentation operations to obtain... Data augmentation operations include rotation, translation, and color perturbation, and this operation is denoted as... To obtain an augmented image The original image and the augmented image are respectively processed by an encoder to extract multi-scale features. and Next, a relaxed reconstruction method is adopted, which groups and fuses the features extracted from each layer of the encoder. This changes the original strict reconstruction method of layer-by-layer alignment to a relaxed reconstruction method of grouping, thereby obtaining the encoded features. and .
[0058] Since the two reconstruction paths are identical and symmetrical, we will now take the original branch as an example. For each spatial group The cosine distance between the encoder and decoder features is calculated as follows:
[0059] And a dynamic weighting coefficient:
[0060] in, Indicates the number of elements in the batch. This represents the cosine distance between the features of the encoder and decoder in spatial group i.
[0061] In this formula, we introduce The gradient is reweighted based on the difficulty of local reconstruction. This is a temperature parameter used to control the sharpness of the weighted distribution, empirically set to approximately 3. Then, the weighted features are used. Calculate the principal reconstruction loss. Before calculation, and They are all flattened into vectors, denoted as follows: and The loss is defined as follows:
[0062] Loss function of augmenting path The definition is similar, just need to... Replace with That's all.
[0063] Therefore, the reconstruction losses of the two pathways are defined as follows:
[0064] The final reconstruction loss function combines the two paths, as shown below:
[0065] in, Based on experience, it is set to 0.8 to highlight the original branch, thereby better preserving the inherent normal pattern of each category and achieving a balance between the two paths.
[0066] Step 5, Low-rank attention module.
[0067] By prioritizing these information-rich and diverse bases, low-rank attention eliminates redundant information, thereby facilitating discriminative representation learning under long-tailed distributions. Given an input feature matrix... Where N is the feature sequence length (corresponding to the number of spatial locations in the image), and D is the original feature dimension; firstly, bottleneck projection is applied to obtain low-rank query and key representations.
[0068]
[0069] in, Indicates a demotion. and These are two learnable bottleneck projection matrices.
[0070] The rank inequality property based on matrix multiplication ensures that bottleneck projection results in a query and key rank no higher than the original rank.
[0071] The resulting attention calculation is guaranteed to reside within a subspace of at most r dimensions. Therefore, this low-rank constraint acts as an adaptive information bottleneck, filtering out redundant correlations while preserving structural orientation. Attention is then calculated within this constrained subspace to capture the most informative and discriminative components.
[0072] Where A represents the low-rank attention weight matrix, V represents the value matrix, and Y represents the output of the low-rank attention module, i.e., the optimized encoded features.
[0073] Step 6, parallel consistency loss.
[0074] To ensure that different images retain their respective reconstruction paths after reconstruction and do not collapse into an averaged output, a parallel consistency loss is introduced into the twin reconstruction framework to maintain the differences between different paths. Naturally, data augmentation operations can be used to obtain the encoded differences. After reconstruction, the decoding differences will also be obtained. .
[0075] To ensure differences before and after reconstruction and To ensure consistency, constraints are introduced in both direction and magnitude. First, it is required that the direction of change remain parallel, which means… and The included angle between them should be as small as possible. Directional consistency is enforced by calculating the cosine distance between the two differences.
[0076] At the same time, the magnitude of changes in the decoded features is constrained to maintain a proportional relationship with the magnitude of changes in the encoded features, thereby controlling the consistency of the differences in magnitude:
[0077] in, The desired scaling ratio (usually set to) To maintain consistency, a hyperparameter is introduced to control the relative intensity of feature changes. It's important to note that reconstruction loss is the primary task and should dominate the gradient direction during the learning process. Therefore, a hyperparameter is introduced. Adjusting the balance between reconstruction loss and parallel consistency loss:
[0078] Therefore, the total training loss Reconstruction loss and parallel consistency loss Composition. In the early stages of training, the reconstruction intensity is insufficient to guarantee parallel relationships. ;therefore, The weights are relatively small. This parallel relationship gradually stabilizes as training progresses. The impact also increases accordingly. Specifically, the weights of the loss term are dynamically adjusted based on the training progress and the average smoothing loss to ensure the stability and effective learning of the model.
[0079] To verify the effectiveness of the long-tail anomaly detection method based on parallel reconstruction, experiments were conducted on a long-tail anomaly detection dataset.
[0080] Table 1 shows the comparison results of this application with several other anomaly detection methods on different long-tail configurations of MVTec-AD for I-auroc and P-auroc. The bolded items in the table indicate the optimal results under various conditions.
[0081] The results in Table 1 show that this application can solve the problem of poor anomaly detection performance under the long-tail distribution of the MVTec-AD dataset, and achieves the highest test accuracy under all different long-tail configurations.
[0082] Table 1
[0083] In the table above, exp100 and step100 represent different long-tail distribution types. exp and step represent different data partitioning methods. exp indicates an exponential decrease in the number of different classes from the head class to the tail class, and step indicates dividing the dataset into head and tail classes. The numbers represent the ratio between the number of samples in the class with the most samples and the number of samples in the class with the fewest samples. Det represents image-level detection tasks, measured by I-auroc; Seg represents pixel-level detection tasks, measured by P-auroc. N / A indicates that this experiment was not performed. See the table below.
[0084] Table 2 shows the comparison results of I-auroc and P-auroc between this application and several other anomaly detection methods on different long-tail configurations of VisA. The bolded items in the table indicate the optimal results under various conditions.
[0085] As shown in Table 2, this application can solve the problem of poor anomaly detection performance under the long-tail distribution of the VisA dataset, and achieves the highest test accuracy under all different long-tail configurations.
[0086] Table 2
[0087] Table 3 shows the comparison results of I-auroc and P-auroc between this application and several other anomaly detection methods on different long-tail configurations of DAGM. The bolded items in the table indicate the optimal results under various conditions.
[0088] As shown in Table 3, this application can solve the problem of poor anomaly detection performance under the long-tail distribution of the DAGM dataset. It achieves the highest test accuracy and good detection results in most long-tail configurations.
[0089] Table 3
[0090] Based on the above results, it can be concluded that the method proposed in this application can maintain highly stable anomaly detection performance under different types and intensities of long-tail distributions, significantly improve the detection accuracy of tail categories while taking into account the overall model reconstruction quality, and is suitable for multi-category anomaly detection tasks in various industrial vision scenarios.
[0091] In summary, the long-tail anomaly detection method based on parallel path reconstruction according to embodiments of the present invention alleviates the lazy mapping problem of tail class reconstruction collapsing to averaged output by maintaining the consistency of differences between the two paths before and after reconstruction. It mainly includes three core modules: a twin reconstruction framework, a low-rank attention module, and a parallel consistency loss. To address the lazy mapping problem of tail classes caused by long-tail distribution, the twin reconstruction framework simulates different images of the same category, improving input diversity. Simultaneously, the introduction of two parallel reconstruction paths naturally introduces the differences between them before reconstruction, thus providing a starting point for introducing a parallel consistency loss to constrain the differences after reconstruction to remain consistent. Finally, for anomaly detection in long-tail distribution, the method extracts the core features of the target to reduce redundancy, thereby reducing the pressure of the head class on the tail class and learning more core and critical features, thus helping to better reconstruct the anomaly.
[0092] In addition, the present invention also proposes a computer-readable storage medium storing a long-tail anomaly detection method program based on parallel path reconstruction, which, when executed by a processor, implements the long-tail anomaly detection method based on parallel path reconstruction as described above.
[0093] In addition, this invention also proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the long-tail anomaly detection method based on parallel path reconstruction as described above.
[0094] Figure 3 This is a block diagram of a long-tailed anomaly detection device based on parallel path reconstruction according to an embodiment of the present invention. Figure 3 As shown, the generation device includes: an acquisition module 10, a model building module 20, an enhancement module 30, a feature extraction module 40, a feature optimization module 50, a decoding module 60, a model training module 70, and an anomaly detection module 80; The system comprises the following modules: Acquisition module 10 acquires the detection dataset; Model building module 20 constructs a reconstruction model, which includes an encoder module, a bottleneck layer, and a decoder; Augmentation module 30 performs data augmentation on sample images in the detection dataset to obtain augmented images; Feature extraction module 40 inputs the sample images into the encoder module for feature extraction to obtain first encoded features, and inputs the augmented images into the encoder module for feature extraction to obtain second encoded features; Feature optimization module 50 inputs the first and second encoded features into the bottleneck layer for dimensionality reduction projection to filter redundant features, resulting in optimized first and second encoded features; Decoding module 60 inputs the optimized first and second encoded features into the decoder for reconstruction, resulting in first and second decoded features; Model training module 70 calculates the reconstruction loss and parallel consistency loss based on the optimized first and second encoded features, first and second decoded features, to obtain the total loss, and uses the total loss to iteratively optimize and train the reconstruction model to obtain a trained anomaly detection model; Anomaly detection module 80 uses the trained anomaly detection model to perform anomaly detection and output the corresponding detection results.
[0095] It should be noted that the foregoing explanation of the embodiments of the long-tailed anomaly detection method based on parallel path reconstruction also applies to the long-tailed anomaly detection device based on parallel path reconstruction in this embodiment, and will not be repeated here.
[0096] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0097] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0098] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0099] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0100] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0101] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0102] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0103] In the description of this invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0104] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0105] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0106] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms should not be construed as necessarily referring to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0107] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A long-tail anomaly detection method based on parallel path reconstruction, characterized in that, Includes the following steps: Obtain the detection dataset; Construct a reconstruction model, wherein the reconstruction model includes an encoder module, a bottleneck layer, and a decoder; Data augmentation is performed on the sample images in the detection dataset to obtain augmented images; The sample image is input into the encoder module for feature extraction to obtain a first encoded feature, and the enhanced image is input into the encoder module for feature extraction to obtain a second encoded feature; The first and second encoded features are input into the bottleneck layer for dimensionality reduction projection to filter redundant features, so as to obtain the optimized first and second encoded features. The optimized first coding feature and the optimized second coding feature are input into the decoder for reconstruction to obtain the first decoding feature and the second decoding feature; The reconstruction loss and parallel consistency loss are calculated based on the optimized first encoding feature, optimized second encoding feature, first decoding feature and second decoding feature to obtain the total loss. The total loss is then used to iteratively optimize and train the reconstruction model to obtain a trained anomaly detection model. Anomaly detection is performed using a pre-trained anomaly detection model, and the corresponding detection results are output.
2. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, Perform data augmentation operations on the sample images in the detection dataset to obtain augmented images, including: The sample images in the detection dataset are rotated, translated, and color-perturbed to obtain enhanced images.
3. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, The sample image is input into the encoder module for feature extraction to obtain a first encoded feature, and the enhanced image is input into the encoder module for feature extraction to obtain a second encoded feature, including: The sample image is input into the encoder module for multi-layer feature extraction to obtain a first multi-scale feature. The first multi-scale feature is then fused in layers and processed using a relaxed reconstruction method to obtain a first coding feature. The enhanced image is then input into the encoder module for multi-layer feature extraction to obtain a second multi-scale feature. The second multi-scale feature is then fused in layers and processed using a relaxed reconstruction method to obtain a second coding feature.
4. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, The first and second encoded features are input into the bottleneck layer for dimensionality reduction projection to filter redundant features, resulting in optimized first and second encoded features, including: Bottleneck projection matrix is used to perform bottleneck projection on the first and second encoded features to obtain the corresponding low-rank query and key; The similarity between the query and the key is calculated in the low-rank space to obtain the attention score matrix, which is then normalized to attention weights using Softmax. The value matrix corresponding to the first encoded feature and the second encoded feature is obtained by using the value projection matrix; Based on the attention weight and value matrix, the optimized first coding feature and optimized second coding feature corresponding to the first coding feature and the second coding feature are obtained.
5. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, The reconstruction loss is calculated using the following formula: in, Indicates the number of elements in the feature set. This represents the feature map of the i-th layer. This represents the i-th layer feature map after the original image has been encoded by the encoder. This represents the i-th layer feature map after the enhanced image has been encoded by the encoder. This represents the i-th layer feature map after the original image has been decoded by the decoder. This represents the i-th layer feature map of the enhanced image after being decoded by the decoder. It is the reconstruction balance coefficient between the original image and the enhanced image. This represents the reconstruction loss of the original image. This represents the reconstruction loss of the enhanced image. This indicates the final reconstruction losses.
6. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, The parallel consistency loss is calculated using the following formula, including: in, This indicates the difference in features extracted by the encoder. This indicates the difference in features extracted by the decoder. Represents the calculation of cosine similarity. This represents the amplitude scaling constraint parameter, used to control the relationship between the characteristic variation amplitudes of the encoder and decoder. This represents the numerical stability constant, used to avoid the denominator being zero. Indicates directional loss. Indicates amplitude loss. This represents the loss of parallel consistency.
7. The long-tail anomaly detection method based on parallel path reconstruction as described in claim 1, characterized in that, The total loss is obtained using the following formula: in, Indicates the total loss. Indicates the reconstruction loss. This represents the parallel consistency loss. This indicates dynamic weights.
8. A computer-readable storage medium, characterized in that, It stores a long-tail anomaly detection program based on parallel path reconstruction, which, when executed by the processor, implements the long-tail anomaly detection method based on parallel path reconstruction as described in any one of claims 1-7.
9. 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 long-tail anomaly detection method based on parallel path reconstruction as described in any one of claims 1-7.
10. A long-tail anomaly detection device based on parallel path reconstruction, characterized in that, include: The acquisition module is used to acquire the detection dataset; A model building module is used to build a reconstructed model, wherein the reconstructed model includes an encoder module, a bottleneck layer, and a decoder; An enhancement module is used to perform data enhancement operations on sample images in the detection dataset to obtain enhanced images; The feature extraction module is used to input the sample image into the encoder module for feature extraction to obtain a first encoded feature, and to input the enhanced image into the encoder module for feature extraction to obtain a second encoded feature; The feature optimization module is used to input the first encoded feature and the second encoded feature into the bottleneck layer for dimensionality reduction projection to filter redundant features, so as to obtain the optimized first encoded feature and the optimized second encoded feature. The decoding module is used to input the optimized first encoded feature and the optimized second encoded feature into the decoder for reconstruction, so as to obtain the first decoded feature and the second decoded feature; The model training module is used to calculate the reconstruction loss and parallel consistency loss based on the optimized first encoding feature, optimized second encoding feature, first decoding feature and second decoding feature to obtain the total loss, and to use the total loss to iteratively optimize and train the reconstruction model to obtain the trained anomaly detection model. The anomaly detection module is used to perform anomaly detection using a trained anomaly detection model and output the corresponding detection results.