ResAD: A Simple Framework for Class Generalizable Anomaly Detection

Xincheng Yao,Zixin Chen,Chao Gao,Guangtao Zhai,Chongyang Zhang
2024-10-26
Abstract:This paper explores the problem of class-generalizable anomaly detection, where the objective is to train one unified AD model that can generalize to detect anomalies in diverse classes from different domains without any retraining or fine-tuning on the target data. Because normal feature representations vary significantly across classes, this will cause the widely studied one-for-one AD models to be poorly classgeneralizable (i.e., performance drops dramatically when used for new classes). In this work, we propose a simple but effective framework (called ResAD) that can be directly applied to detect anomalies in new classes. Our main insight is to learn the residual feature distribution rather than the initial feature distribution. In this way, we can significantly reduce feature variations. Even in new classes, the distribution of normal residual features would not remarkably shift from the learned distribution. Therefore, the learned model can be directly adapted to new classes. ResAD consists of three components: (1) a Feature Converter that converts initial features into residual features; (2) a simple and shallow Feature Constraintor that constrains normal residual features into a spatial hypersphere for further reducing feature variations and maintaining consistency in feature scales among different classes; (3) a Feature Distribution Estimator that estimates the normal residual feature distribution, anomalies can be recognized as out-of-distribution. Despite the simplicity, ResAD can achieve remarkable anomaly detection results when directly used in new classes. The code is available at <a class="link-external link-https" href="https://github.com/xcyao00/ResAD" rel="external noopener nofollow">this https URL</a>.
Computer Vision and Pattern Recognition,Machine Learning
What problem does this paper attempt to address?
The problem that this paper attempts to solve is **class - generalizable anomaly detection**. Specifically, the goal is to train a unified anomaly detection (AD) model so that it can be generalized to detect anomalies of new classes from different domains without any retraining or fine - tuning of the target data. Since normal feature representations vary significantly among different classes, this will lead to a significant performance degradation of existing single - class or multi - class AD models when applied to new classes. Therefore, how to design an AD model that can be generalized in the case of feature changes has become the focus of research. ### Main contributions of the paper: 1. **Proposed a simple but effective framework ResAD**: This framework can be applied to anomaly detection and localization in new classes. 2. **Based on residual feature learning**: Solve the problem that existing single - class or multi - class AD methods cannot be directly generalized to new classes by learning residual features. 3. **Extensive experimental verification**: Comprehensive experiments were carried out on six real - world AD datasets, and the results show that using only 4 samples as references, ResAD can achieve significant AD effects, significantly outperforming the existing state - of - the - art methods. ### Method overview: 1. **Residual feature generation**: Generate residual features by matching input features with the nearest normal reference features and performing a subtraction operation. This process helps to reduce class - related feature changes and makes the normal residual features more uniformly distributed among different classes. 2. **Feature hypersphere constraint**: Constrain normal residual features into a spatial hypersphere through a simple network, further reducing feature changes and maintaining the consistency of feature scales among different classes. 3. **Feature distribution estimation**: Use the normalized flow model to estimate the distribution of residual features, thereby identifying abnormal samples. ### Experimental results: - **Industrial AD datasets**: On the MVTecAD, VisA, BTAD and MVTec3D datasets, ResAD achieved the best image - level and pixel - level AUROC performance in both 2 - shot and 4 - shot settings. - **Medical AD datasets**: On the BraTS dataset, ResAD also performed excellently, especially in the 4 - shot setting, with image - level and pixel - level AUROC reaching 84.6% and 96.1% respectively. - **Video AD datasets**: On the ShanghaiTech dataset, in the 4 - shot setting, the image - level and pixel - level AUROC of ResAD were 84.3% and 92.6% respectively. ### Conclusion: Through residual feature learning and feature hypersphere constraint, ResAD has successfully solved the problem of class - generalizable anomaly detection, demonstrating its effectiveness and generalization ability in various practical application scenarios.