Unsupervised visual anomaly detection method based on normal prototype estimation and feature amplification

CN122966529APending Publication Date: 2026-10-23YUNNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610934170.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0008]本发明的目的在于提供一种基于正常原型估计与特征放大的免训练视觉异常检测方法,以解决现有训练自由异常检测方法中存在的如下技术问题:直接利用预训练模型输出特征进行相似性匹配时,异常响应容易被正常信息稀释,正常显著结构容易引发伪异常响应,从而导致图像级异常判别能力不足、像素级异常定位精度不高,并且在工业缺陷检测与医疗图像异常识别等不同场景下的泛化能力仍有待提升

Benefits of technology

首先,本发明提出了一种基于正常原型估计的异常特征增强方式。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122966529A_ABST
    Figure CN122966529A_ABST
Patent Text Reader

Abstract

The application discloses a kind of training-free visual anomaly detection methods based on normal prototype estimation and feature amplification, comprising the following steps: S1, construct anomaly detection framework;S2, extract image and text features;S3, execute normal prototype estimation;S4, execute deviation perception feature amplification;S5, generate branch anomaly map;S6, fusion anomaly map and output result.Through local average pooling to intermediate Patch feature, feature distribution statistics and low deviation feature screening, the normal prototype in the current image feature space is constructed, thereby providing a stable normal reference center for anomaly response modeling.This design makes subsequent feature amplification no longer dependent on empirical heuristic rules, but directly uses the normal mode in the current image as a reference, so it is more suitable for complex anomaly detection tasks in industrial and medical images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image anomaly detection technology, and specifically relates to a training-free visual anomaly detection method based on normal prototype estimation and feature amplification. Background Technology

[0002] With the development of industrial automated inspection and medical image-assisted diagnosis, the automatic identification of abnormal regions in images using computer vision technology has become an important means to improve inspection efficiency and diagnostic accuracy. In industrial manufacturing scenarios, visual anomaly detection can be used for metal surface defect detection, electronic component defect detection, and parts assembly quality inspection; in medical scenarios, visual anomaly detection can be used for lesion screening, organ structural abnormality identification, fundus image analysis, and tomographic image analysis. By automatically locating and identifying abnormal regions or abnormal samples in input images, the burden of manual inspection can be effectively reduced, and the consistency and real-time performance of detection can be improved, thus possessing significant application value.

[0003] Existing visual anomaly detection methods mainly include supervised methods, unsupervised methods, and methods based on pre-trained models. Supervised methods typically rely on a large number of labeled anomaly samples, especially in pixel-level localization tasks, requiring precise manual annotation of anomaly regions. While these methods can achieve high accuracy on specific datasets, in industrial defect detection and medical image analysis scenarios, anomaly samples are scarce, and annotation work usually requires experienced technicians or doctors, resulting in high data acquisition costs and long lead times, making it difficult to meet practical deployment needs.

[0004] To reduce reliance on anomaly labeling, unsupervised anomaly detection methods typically build normal pattern models using only normal samples, then identify anomalies through reconstruction errors, feature distribution biases, or similarity differences. While this approach alleviates the problem of insufficient anomaly samples to some extent, it still requires collecting a significant number of normal samples for the target application scenario and performing model training, parameter updates, or threshold adjustments. When the detection object, imaging equipment, acquisition environment, or sample distribution changes, model retraining or re-adaptation is often necessary, leading to high model transfer costs and insufficient cross-scenario application capabilities.

[0005] In recent years, with the development of large-scale pre-trained visual models and visual language models, existing technologies have begun to explore the use of the general feature representation capabilities of pre-trained models for anomaly detection. For example, methods based on pre-trained models such as CLIP and DINO can perform anomaly scoring and localization on industrial and medical images with little or no target domain training data. These methods avoid the traditional large-scale training process and improve cross-scene applicability to a certain extent, thus becoming an important research direction.

[0006] However, existing training-free or training-free anomaly detection methods based on pre-trained models typically use model output features directly for similarity matching or anomaly scoring, which still has the following shortcomings: First, anomaly regions usually only occupy a local area in an image. When directly using the original features for matching, the anomaly response is easily diluted by a large amount of normal information, resulting in insufficient anomaly discrimination ability. Second, bright areas and texture edges in industrial parts, as well as normal structural changes in medical images, are prone to generating strong responses in the feature space, thereby triggering pseudo-anomaly activation and affecting detection accuracy. Third, most existing methods lack explicit modulation mechanisms for intermediate features, making it difficult to actively enhance anomaly-related features and suppress normal interference during forward propagation. Therefore, they still have limitations in image-level anomaly discrimination and pixel-level anomaly localization.

[0007] Therefore, there is an urgent need for a visual anomaly detection method that can be applied to industrial defect detection and medical image anomaly recognition. This method should be able to establish a stable normal reference during feature extraction without additional training or with only a few reference samples, and explicitly enhance abnormal features that deviate from the normal pattern, thereby improving the accuracy, robustness and cross-scenario applicability of anomaly detection. Summary of the Invention

[0008] The purpose of this invention is to provide a training-free visual anomaly detection method based on normal prototype estimation and feature amplification, in order to solve the following technical problems existing in the current training-free anomaly detection method: when directly using the output features of the pre-trained model for similarity matching, the anomaly response is easily diluted by normal information, and normal salient structures are prone to triggering pseudo-anomaly responses, resulting in insufficient image-level anomaly discrimination ability, low pixel-level anomaly localization accuracy, and the generalization ability in different scenarios such as industrial defect detection and medical image anomaly recognition still needs to be improved.

[0009] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a training-free visual anomaly detection method based on normal prototype estimation and feature amplification, comprising the following steps: S1. Construct an anomaly detection framework; S11. Construct the DINO visual branch to extract fine-grained structural features from the query image and the reference image; S12. Construct CLIP visual branches to extract high-level semantic features from the query image and reference image. S13. Construct a text prompt branch to encode normal prompt words and abnormal prompt words, and obtain normal text embedding and abnormal text embedding; S14. Insert the Normal Prototype Feature Amplification Module (NPFA) into the selected intermediate layer of the DINO vision branch and the CLIP vision branch to enhance the intermediate features. S2. Extract image and text features; S21. Obtain a reference image and a query image, wherein the reference image is a normal sample image and the query image is the image to be detected; S22. Input the reference image and the query image into the DINO visual branch and the CLIP visual branch respectively, and extract the intermediate patch features of the selected layer; in S22, the first... The patch features output by the layer are represented as follows: in, Indicates the first The first in the layer Feature vectors of each patch Indicates the number of patches; S23. Input the normal prompt words and abnormal prompt words into the text prompt branch to obtain the normal text embedding. and abnormal text embedding ; S3. Perform normal prototype estimation; S31, regarding the first Local average pooling is performed on the layer patch features to obtain the pooled feature representation; In S31, the features after local average pooling are represented as follows: in, , Indicates the number of features after pooling; S32. Calculate the statistics of the current feature distribution based on the pooled features; S33. Calculate the deviation of each pooling feature from the current feature distribution; In steps S32 and S33, the channel mean of the pooling feature is calculated first. and variance , and redefine the first The deviation of each pooling feature is: in, For feature dimension, It is a numerically stable term; S34. Filter for low-deviation features; S35. Construct a normal prototype based on the low deviation characteristics; S4. Perform deviation perception feature amplification; S41. Calculate the deviation vector of the original Patch features relative to the normal prototype; S42. Calculate the deviation magnitude of each patch feature; S43. Construct weights that enhance high deviation and weaken low deviation based on the deviation magnitude; S44. Update the Patch features based on the deviation direction and deviation magnitude; S45. Smooth the updated Patch features to obtain enhanced feature representations; S5. Generate a branch anomaly graph; S51. Generate a DINO visual anomaly map based on the matching relationship between the enhanced DINO branch features and the reference image features; S52. Generate a CLIP visual anomaly map based on the matching relationship between the enhanced CLIP visual branch features and the reference image features; S53. Generate a text guidance anomaly map based on the cross-modal similarity between the enhanced CLIP features and normal text embeddings and anomalous text embeddings; S6. Merge the anomaly maps and output the results; S61. Merge the DINO visual anomaly map, CLIP visual anomaly map, and text-guided anomaly map; S62. Generate the final anomaly graph; S63. Output the image-level anomaly score and pixel-level anomaly localization results based on the final anomaly map.

[0010] Furthermore, in steps S34 and S35, a set of low-deviation features is selected based on a deviation threshold. The normal prototype is obtained by averaging the features in this set. in, Indicates the first The normal prototype of the layer is used as a normal reference center for subsequent feature enhancement.

[0011] Furthermore, in S41 and S42, the first... The deviation vector of each original image patch feature relative to the normal prototype is represented as: And calculate the first based on the deviation vector. Deviation magnitude of features from the original image patch: The larger the deviation value, the more significantly the corresponding Patch feature deviates from the normal pattern.

[0012] Furthermore, in S43, high deviation enhancement weights are constructed. and low deviation weakens weight Features with larger deviations in magnitude have greater enhancement weights, while features with smaller deviations in magnitude have greater reduction weights.

[0013] Furthermore, in S44, let the unit vector of the deviation direction be: The updated Patch feature is then represented as: in, This is the amplification factor for high deviation characteristics. This is the attenuation coefficient for low deviation characteristics.

[0014] Furthermore, in step S45, the updated Patch features are smoothed using average pooling to obtain an enhanced feature representation: Furthermore, in S51 and S52, the query image contains the first... The visual anomaly score of each enhanced feature is represented as: in, Represents the feature distance metric function. An enhanced feature representation of a normal reference set.

[0015] Furthermore, in S53, the text anomaly score is represented as: in, A similarity function representing the relationship between visual features and text features.

[0016] Furthermore, in step S61, the final anomaly graph is represented as follows: in, , , For weight fusion.

[0017] Furthermore, the reference image includes one or more normal sample images of the category to be detected, and the query image includes an industrial sample image to be detected or a medical image to be analyzed; steps S2 to S6 are executed by a server, an edge computing device, an industrial detection terminal, or a medical image analysis terminal.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: First, this invention proposes an abnormal feature enhancement method based on normal prototype estimation.

[0019] This invention constructs a normal prototype in the current image feature space by performing local average pooling, feature distribution statistics, and low-deviation feature selection on intermediate patch features, thus providing a stable normal reference center for anomaly response modeling. This design allows subsequent feature amplification to no longer rely on empirical heuristic rules, but directly uses the normal pattern in the current image as a benchmark, making it more suitable for complex anomaly detection tasks in industrial and medical images.

[0020] Secondly, this invention proposes a mechanism for amplifying deviation-perceptual features.

[0021] Existing methods for anomaly detection often rely on direct matching between original features, lacking an active enhancement mechanism for anomaly-related features. This leads to problems such as scattered anomaly responses and false activation of normal salient structures. In contrast, this invention calculates the deviation vector and magnitude of each patch feature relative to the normal prototype, and constructs high-deviation enhancement weights and low-deviation reduction weights. Features that deviate significantly from the normal pattern are enhanced, while features close to the normal pattern are relatively weakened. This explicitly widens the distance between anomalous and normal features in the feature space, thereby improving the separability of anomaly representation and the accuracy of anomaly localization.

[0022] Furthermore, this invention integrates the above-mentioned normal prototype estimation and deviation perception feature amplification into the DINO visual branch and CLIP visual branch, and combines them with the text prompt branch to perform anomaly graph fusion.

[0023] Among them, the DINO vision branch is better at extracting fine-grained structural information, the CLIP vision branch is better at extracting high-level semantic information, and the text prompting branch can provide cross-modal semantic priors. Through the synergistic effect of the three, this invention can simultaneously take into account local structural changes and global semantic anomalies in abnormal regions, thereby improving the image-level anomaly discrimination capability and pixel-level anomaly localization accuracy in industrial defect detection and medical image anomaly recognition.

[0024] Therefore, the method of the present invention can achieve high anomaly detection performance with only a small number of normal reference images without the need for additional training or parameter adaptation in the target domain. It has good cross-scene generalization ability and engineering application value. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1This is a framework diagram of a training-free visual anomaly detection method based on normal prototype estimation; Figure 2 It is a line graph comparing the invention method at different resolutions and with different magnification parameters. Detailed Implementation

[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0028] See Figure 1-2 This invention provides a training-free visual anomaly detection method based on normal prototype estimation and feature amplification. This method can be applied to industrial defect detection and medical image anomaly recognition.

[0029] The complete steps of this invention are as follows: S1: Constructing an anomaly detection framework. The specific steps are as follows: S11: Construct the DINO visual branch.

[0030] The DINO vision branch is used to extract fine-grained structural features from the input image, including local texture, edge information, contour information, and structural distribution information. In industrial inspection scenarios, these fine-grained structural features can be used to characterize local defects in samples such as screws, capsules, circuit boards, and electronic devices; in medical image analysis scenarios, they can be used to characterize lesion boundaries, tissue structure changes, and local abnormal regions.

[0031] S12: Construct the CLIP visual branch.

[0032] The CLIP visual branch is used to extract high-level semantic features from the input image. Compared to the DINO visual branch, the CLIP visual branch is more suitable for describing the overall semantic information of the image and the high-level semantic responses related to anomalies. In industrial inspection scenarios, the high-level semantic features can be used to distinguish between normal and defective parts; in medical imaging scenarios, the high-level semantic features can be used to describe the semantic differences between normal and abnormal tissues.

[0033] S13: Build the text hint branch.

[0034] The text prompt branch is used to encode normal and abnormal prompt words to form a cross-modal semantic prior. Normal prompt words can be "normal screw," "normal circuit board," "normal brain image," "normal liver CT image," etc., while abnormal prompt words can be "abnormal screw," "abnormal circuit board," "abnormal brain image," "abnormal liver CT image," etc. By encoding the prompt words, normal and abnormal text embeddings can be obtained, which are used for the subsequent generation of text-guided anomaly maps.

[0035] S14: Insert a normal prototype feature amplification module into the visual branch.

[0036] Normal Prototype Feature Amplification (NPFA) modules are inserted into selected intermediate layers of the DINO and CLIP vision branches. The NPFA module is a fixed feature processing module without learnable parameters; it does not participate in model training and does not alter the network parameters of the pre-trained models in the DINO and CLIP vision branches. During forward inference, this module calculates and transforms the intermediate layer patch features to enhance anomaly-related feature responses and suppress normal structural interference.

[0037] Specifically, the NPFA module includes two processing steps: normal prototype estimation and deviation-aware feature amplification. The normal prototype estimation step constructs a normal prototype based on the statistical distribution of intermediate layer patch features in the current input image, representing the normal reference pattern in the current image. The deviation-aware feature amplification step enhances features with larger deviations and suppresses features with smaller deviations based on the direction and magnitude of deviation of each patch feature relative to the normal prototype. Since the above processing only includes statistical calculations, distance metrics, weight generation, and feature update operations, the NPFA module does not require parameter learning from training samples or fine-tuning of the pre-trained visual model.

[0038] S2: Extract image and text features. The specific steps are as follows: S21: Input the reference image and the query image.

[0039] The reference image and query image are input into the DINO vision branch and CLIP vision branch, respectively. The reference image is a normal sample image, and the query image is the image to be detected. In industrial scenarios, the reference image can be a normal industrial product image, and the query image can be the product image to be detected; in medical scenarios, the reference image can be a normal medical image, and the query image can be the image to be analyzed.

[0040] S22: Extract visual intermediate features.

[0041] Let the first The patch features output by the layer are represented as follows: in, Indicates the first The first in the layer Feature vectors of each patch Indicates the number of patches.

[0042] The patch feature is a local representation of the image in the intermediate layer, which not only preserves local spatial distribution information but can also be used for subsequent anomaly response modeling.

[0043] S23: Extract text features.

[0044] Input normal and abnormal prompt words into the text prompt branch to obtain the normal text embedding. and abnormal text embedding The aforementioned text embedding is used for subsequent cross-modal matching to generate a text-guided anomaly graph.

[0045] S3: Perform normal prototype estimation. The specific steps are as follows: S31: Perform local average pooling on the Patch features.

[0046] To construct a stable normal reference in the feature space, firstly, the first... Local average pooling is performed on the layer patch features to obtain the pooled feature representation: in, , This indicates the number of features after pooling.

[0047] Average pooling can aggregate features within a local neighborhood, reducing the impact of random fluctuations in a single patch on normal prototype estimation.

[0048] S32: Calculate the characteristic distribution statistic.

[0049] Based on the pooled features, calculate the current image at the [number]th [position]. Channel mean in layer feature space and channel variance .in, This indicates the average distribution center of the features in this layer. This indicates the degree of dispersion of the features in this layer.

[0050] S33: Calculate the deviation of the pooling feature.

[0051] For the Each pooling feature is defined as having a deviation relative to the current feature distribution as follows: in, Representing feature dimension, It is a numerically stable term.

[0052] The deviation is used to characterize the degree of deviation of the current local feature from the dominant normal distribution. The smaller the deviation, the more the local feature conforms to the normal pattern; the larger the deviation, the more likely the local feature contains abnormal clues.

[0053] S34: Filter low-deviation features and build normal prototypes.

[0054] Select the low-deviation feature set based on the degree of deviation. The normal prototype is obtained by averaging the features in the set. in, Indicates the first The normal prototype of the layer.

[0055] The normal prototype represents the normal reference center of the current image in the feature space of that layer. For industrial images, the normal prototype corresponds to the feature center of a normal component; for medical images, the normal prototype corresponds to the feature center of a normal tissue structure.

[0056] S4: Perform deviation-perceptual feature amplification. The specific steps are as follows: S41: Calculate the deviation vector of the original Patch features relative to the normal prototype.

[0057] Definition of the first The deviation vector of each patch feature relative to the normal prototype is: The direction of the deviation vector indicates the direction in which the patch feature deviates from the normal pattern, and the magnitude of the deviation vector indicates the degree of deviation.

[0058] S42: Calculate the deviation amplitude.

[0059] Based on the deviation vector, define the first... The deviation magnitude of each patch feature is: in, Denotes the Euclidean norm. It is a numerically stable term.

[0060] The larger the deviation, the more significant the deviation of the patch feature from the normal mode.

[0061] S43: Construct weights that enhance high deviation and weights that weaken low deviation.

[0062] Based on the deviation magnitude, larger enhancement weights are assigned to patch features with greater deviation, and larger reduction weights are assigned to patch features with smaller deviation. Let the th... The set of deviation magnitudes for all patches in the layer is Based on the quantile threshold of the deviation magnitude, high deviation is enhanced by weighting. and low deviation weakens weight They are defined as follows: in, and They represent the first quantiles and the Quantiles This represents the Sigmoid function. This is the temperature coefficient. In a preferred embodiment, Set to 0.88, Set to 0.20, Set to 0.10. Using the soft weighting calculation method described above, patches with larger deviations will receive greater boosting weights, while patches with smaller deviations will receive greater weakening weights, thus avoiding the discontinuous feature updates caused by hard threshold filtering.

[0063] S44: Update Patch features.

[0064] Let the unit vector of the deviation direction be: The updated Patch feature is then represented as: in, The amplification factor for high deviation characteristics is set to 2 in the experiment. The reduction factor for low deviation characteristics is set to 0.25.

[0065] The above update process further enhances features that deviate far from the normal prototype along the deviation direction, while relatively weakening features that deviate close to the normal prototype, thereby expanding the difference between normal and abnormal features in the feature space.

[0066] S45: Perform smoothing on the updated features.

[0067] To enhance spatial continuity and reduce the impact of discrete noise points, average pooling smoothing is performed on the updated Patch features to obtain the enhanced feature representation: S5: Generate a branching anomaly graph. The specific steps are as follows: S51: Generate a visual anomaly map.

[0068] Based on the enhanced DINO branch features and CLIP visual branch features, they are matched with normal enhanced features in the reference image to obtain the DINO visual anomaly map and the CLIP visual anomaly map.

[0069] For the query image, the first Each enhanced feature has a visual anomaly score defined as: in, Represents the feature distance metric function. This represents the set of enhanced features for the normal reference set.

[0070] The higher the visual anomaly score, the more the corresponding location deviates from the normal reference, and the higher the probability of an anomaly.

[0071] S52: Generate a text-guided exception graph.

[0072] Based on the cross-modal matching relationship between the enhanced CLIP features and normal and anomalous text embeddings, a text-guided anomaly map is generated. The text anomaly score is defined as follows: in, A similarity function representing the relationship between visual features and text features.

[0073] This step allows for a text-guided response that is more consistent with the semantics of the anomaly.

[0074] S6: Fuse the anomaly maps and output the detection results. The specific steps are as follows: S61: Fusion of three-way anomaly graph.

[0075] The DINO visual anomaly map, CLIP visual anomaly map, and text-guided anomaly map are fused to obtain the final anomaly map: in, , , For weight fusion.

[0076] In this embodiment, an equal-weighted fusion method is preferred.

[0077] S62: Output image-level anomaly score.

[0078] Based on the final anomaly map, an image-level anomaly score is output for the entire query image to determine whether the image is abnormal.

[0079] S63: Output pixel-level anomaly location results.

[0080] Based on the intensity of the abnormal response at each location in the final anomaly map, pixel-level anomaly localization results are output to mark the location and extent of abnormal regions in the image.

[0081] In the industrial defect detection embodiment, the reference image can be an image of a normal screw, circuit board, electronic component, or capsule, while the query image can be an image of the industrial sample to be inspected. Through the above steps, the location of the industrial defect and the anomaly score can be output.

[0082] In this embodiment of medical image anomaly recognition, the reference image can be a normal brain MRI image, a normal liver CT image, a normal fundus image, or a normal tomographic scan image, and the query image can be the medical image to be analyzed. Through the above steps, an image-level anomaly score and the location result of the lesion area can be output.

[0083] Each step in this embodiment can be executed by the same computing device, or it can be completed collaboratively by the server and the terminal. With the same set of pre-trained model parameters, industrial defect detection and medical image anomaly recognition tasks can be completed without additional training or parameter updates.

[0084] Experimental results We present comparative experimental results between our proposed method and existing benchmark methods on industrial defect detection datasets and medical image anomaly recognition datasets. Here, image-level AUC and pixel-level AUC are used as evaluation metrics. Image-level AUC is used to evaluate the anomaly detection performance of the entire image, while pixel-level AUC is used to evaluate the anomaly region localization performance. For medical datasets that do not provide pixel-level ground truth annotations, only image-level evaluation results are given. Experimental results show that the training-free visual anomaly detection method based on normal prototype estimation and feature amplification proposed in this invention achieves superior detection performance compared to existing methods in various industrial and medical scenarios.

[0085] Taking a 1-shot setting as an example, on the industrial dataset MVTec_AD, the method of this invention achieved an image-level AUC of 98.2 and a pixel-level AUC of 97.2, both improvements over the baseline method UniVAD's 97.8 and 96.3. On the industrial dataset VisA, the method of this invention achieved an image-level AUC of 94.4 and a pixel-level AUC of 98.4, also outperforming existing methods such as UniVAD, WinCLIP, and PromptAD. On medical datasets, the method of this invention achieved superior image-level anomaly detection results on multiple datasets such as BrainMRI, LiverCT, and RESC, and maintained superior localization performance on datasets with pixel-level annotations such as BrainMRI, LiverCT, and RESC. This demonstrates that the method of this invention is applicable not only to industrial defect detection scenarios but also to medical image anomaly recognition scenarios.

[0086] Furthermore, we conducted experimental analysis on the input resolution and amplification parameters, such as... Figure 2 As shown. Experimental results show that as the input resolution increases from 224×224 to 448×448, the image-level AUC increases on both MVTec_AD and VisA, indicating that higher resolutions can provide more sufficient details of local anomalies; meanwhile, the pixel-level AUC remains relatively stable at different resolutions, indicating that the method of this invention has good localization robustness. (Regarding magnification parameters...) In the experiment, when When a suitable value is selected, a good balance is achieved between image-level and pixel-level performance, indicating that the deviation sensing feature amplification mechanism proposed in this invention can achieve an effective trade-off between enhancing abnormal response and suppressing normal interference.

[0087] As shown in Table 1, in order to illustrate the technical effect of the method of the present invention, experimental results on representative industrial and medical datasets can be compared.

[0088] Table 1. Comparison of image-level AUC / pixel-level AUC between the method of the present invention and existing methods on five datasets. The results for each group in Table 1 are presented in the form of "image-level AUC / pixel-level AUC". As shown in Table 1, the method of the present invention achieves better results than existing methods on representative industrial datasets and medical datasets, thus verifying the effectiveness of the present invention in cross-scene anomaly detection.

[0089] First, this invention proposes an abnormal feature enhancement method based on normal prototype estimation.

[0090] Existing training-free anomaly detection methods typically perform similarity matching or anomaly scoring directly on the output features of pre-trained models, lacking explicit modeling of the relationship between normal and abnormal patterns in intermediate features. This can easily lead to the true anomaly response being diluted by surrounding normal information. This invention constructs a normal prototype in the current image feature space by performing local average pooling, feature distribution statistics, and low-deviation feature filtering on intermediate patch features, thus providing a stable normal reference center for anomaly response modeling. This design allows subsequent feature amplification to no longer rely on empirical heuristic rules, but instead directly uses the normal patterns in the current image as a benchmark, making it more suitable for complex anomaly detection tasks in industrial and medical images.

[0091] Secondly, this invention proposes a mechanism for amplifying deviation-perceptual features.

[0092] Existing methods for anomaly detection often rely on direct matching between original features, lacking an active enhancement mechanism for anomaly-related features. This leads to problems such as scattered anomaly responses and false activation of normal salient structures. In contrast, this invention calculates the deviation vector and magnitude of each patch feature relative to the normal prototype, and constructs high-deviation enhancement weights and low-deviation reduction weights. Features that deviate significantly from the normal pattern are enhanced, while features close to the normal pattern are relatively weakened. This explicitly widens the distance between anomalous and normal features in the feature space, thereby improving the separability of anomaly representation and the accuracy of anomaly localization.

[0093] Furthermore, this invention integrates the above-mentioned normal prototype estimation and deviation perception feature amplification into the DINO visual branch and CLIP visual branch, and combines them with the text prompt branch to perform anomaly graph fusion.

[0094] Among them, the DINO vision branch is better at extracting fine-grained structural information, the CLIP vision branch is better at extracting high-level semantic information, and the text prompting branch can provide cross-modal semantic priors. Through the synergistic effect of the three, this invention can simultaneously take into account local structural changes and global semantic anomalies in abnormal regions, thereby improving the image-level anomaly discrimination capability and pixel-level anomaly localization accuracy in industrial defect detection and medical image anomaly recognition.

[0095] Therefore, the method of the present invention can achieve high anomaly detection performance with only a small number of normal reference images without the need for additional training or parameter adaptation in the target domain. It has good cross-scene generalization ability and engineering application value.

[0096] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0097] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A training-free visual anomaly detection method based on normal prototype estimation and feature amplification, characterized in that, Includes the following steps: S1. Construct an anomaly detection framework; S11. Construct the DINO visual branch to extract fine-grained structural features from the query image and the reference image; S12. Construct CLIP visual branches to extract high-level semantic features from the query image and reference image. S13. Construct a text prompt branch to encode normal prompt words and abnormal prompt words, and obtain normal text embedding and abnormal text embedding; S14. Insert the Normal Prototype Feature Amplification Module (NPFA) into the selected intermediate layer of the DINO vision branch and the CLIP vision branch to enhance the intermediate features. S2. Extract image and text features; S21. Obtain a reference image and a query image, wherein the reference image is a normal sample image and the query image is the image to be detected; S22. Input the reference image and the query image into the DINO visual branch and the CLIP visual branch respectively, and extract the intermediate patch features of the selected layer; In S22, the first The patch features output by the layer are represented as follows: in, Indicates the first The first in the layer Feature vectors of each patch Indicates the number of patches; S23. Input the normal prompt words and abnormal prompt words into the text prompt branch to obtain the normal text embedding. and abnormal text embedding ; S3. Perform normal prototype estimation; S31, regarding the first Local average pooling is performed on the layer patch features to obtain the pooled feature representation; In S31, the features after local average pooling are represented as follows: in, , Indicates the number of features after pooling; S32. Calculate the statistics of the current feature distribution based on the pooled features; S33. Calculate the deviation of each pooling feature from the current feature distribution; In steps S32 and S33, the channel mean of the pooling feature is calculated first. and variance , and redefine the first The deviation of each pooling feature is: in, For feature dimension, It is a numerically stable term; S34. Filter for low-deviation features; S35. Construct a normal prototype based on the low deviation characteristics; S4. Perform deviation perception feature amplification; S41. Calculate the deviation vector of the original Patch features relative to the normal prototype; S42. Calculate the deviation magnitude of each patch feature; S43. Construct weights that enhance high deviation and weaken low deviation based on the deviation magnitude; S44. Update the Patch features based on the deviation direction and deviation magnitude; S45. Smooth the updated Patch features to obtain enhanced feature representations; S5. Generate a branch anomaly graph; S51. Generate a DINO visual anomaly map based on the matching relationship between the enhanced DINO branch features and the reference image features; S52. Generate a CLIP visual anomaly map based on the matching relationship between the enhanced CLIP visual branch features and the reference image features; S53. Generate a text guidance anomaly map based on the cross-modal similarity between the enhanced CLIP features and normal text embeddings and anomalous text embeddings; S6. Merge the anomaly maps and output the results; S61. Merge the DINO visual anomaly map, CLIP visual anomaly map, and text-guided anomaly map; S62. Generate the final anomaly graph; S63. Output the image-level anomaly score and pixel-level anomaly localization results based on the final anomaly map.

2. The method according to claim 1, characterized in that: In S34 and S35, a low deviation feature set is selected based on the deviation threshold. The normal prototype is obtained by averaging the features in this set. in, Indicates the first The normal prototype of the layer is used as a normal reference center for subsequent feature enhancement.

3. The method according to claim 2, characterized in that: In S41, the deviation vector is represented as:

4. The method according to claim 3, characterized in that: In S42, the deviation amplitude is expressed as: The larger the deviation value, the more significantly the corresponding Patch feature deviates from the normal pattern.

5. The method according to claim 1, characterized in that: In S43, high deviation enhancement weights are constructed. and low deviation weakens weight Features with larger deviations in magnitude have greater enhancement weights, while features with smaller deviations in magnitude have greater reduction weights.

6. The method according to claim 1, characterized in that: In S44, let the unit vector of the deviation direction be: The updated Patch feature is then represented as: in, This is the amplification factor for high deviation characteristics. This is the attenuation coefficient for low deviation characteristics.

7. The method according to claim 1, characterized in that: In step S45, the updated Patch features are smoothed using average pooling to obtain the enhanced feature representation: 。 8. The method according to claim 1, characterized in that: In S51 and S52, the query image contains the first... The visual anomaly score of each enhanced feature is represented as: in, Represents the feature distance metric function. An enhanced feature representation of a normal reference set.

9. The method according to claim 1, characterized in that: In S53, the text anomaly score is represented as follows: in, A similarity function representing the relationship between visual features and text features.

10. The method according to claim 1, characterized in that: In S61, the final anomaly graph is represented as follows: in, , , For weight fusion.