Unsupervised anomaly detection method based on discrete feature rectification
Abstract
Unsupervised anomaly detection (AD) based on reverse distillation (RD) exploits reconstruction discrepancies between fixed teacher encoder and trainable student decoder. However, existing paradigms typically assume a continuous latent space, allowing student encoder to approximate unseen anomalies by generalizing from normal features. This mechanism inherently weakens the information bottleneck, leading to erroneous over-generalized reconstructions that mask true defects. To overcome these limitations, we propose a RD framework based on discrete feature rectification. The framework strengthens anomaly detection capability through a Discrete Feature Rectification (DFR) strategy and a Multi-Scale Feature Fusion (MFF) module. First, the DFR utilizes an adaptive distribution alignment mechanism to map encoder features into a high-variance target space, adapting to diverse industrial data. Subsequently, a learnable Feature Memory module filters out anomalies via discrete feature matching, preventing anomaly leakage. Finally, to address spatial information loss from discretization, a Spatial Attention module incorporating positional encoding is introduced. By capturing spatial correlations within sample data, it adaptively enhances focus on key structural regions while suppressing background noise. Moreover, a MFF effectively integrates rectified multi-level features for high-quality reconstruction. The experimental results on the MVTec dataset demonstrate the significant advantages of our method, particularly in detecting texture anomalies and fine scratches with precise localization, satisfying the industrial inspection requirements in most scenarios. Our code is released on https://github.com/snapelxy/DFR-MMF.