Abstract
Anomaly detection is represented as an unsupervised learning to identify deviated images from normal images. In general, there are two main challenges of anomaly detection tasks, i.e., the class imbalance and the unexpectedness of anomalies. In this paper, we propose a multiresolution feature guidance method based on Transformer named GTrans for unsupervised anomaly detection and localization. In GTrans, an Anomaly Guided Network (AGN) pre-trained on ImageNet is developed to provide surrogate labels for features and tokens. Under the tacit knowledge guidance of the AGN, the anomaly detection network named Trans utilizes Transformer to effectively establish a relationship between features with multiresolution, enhancing the ability of the Trans in fitting the normal data manifold. Due to the strong generalization ability of AGN, GTrans locates anomalies by comparing the differences in spatial distance and direction of multi-scale features extracted from the AGN and the Trans. Our experiments demonstrate that the proposed GTrans achieves state-of-the-art performance in both detection and localization on the MVTec AD dataset. GTrans achieves image-level and pixel-level anomaly detection AUROC scores of 99.0% and 97.9% on the MVTec AD dataset, respectively.
Introduction
Anomaly detection in industrial settings faces two primary hurdles: class imbalance (anomalies are rare) and unexpectedness (anomalies can be anything, anywhere). Traditional methods like Autoencoders (AEs) or GANs try to reconstruct images, assuming they will fail to reconstruct anomalies. However, these models often generalize too well, accidentally reconstructing defects, or they produce low-resolution outputs that make precise localization difficult.
Recent "Teacher-Student" models address this by having a student network try to mimic a pre-trained teacher network on normal data. The gap appears when they encounter an anomaly: the teacher (pre-trained on diverse data) sees it clearly, while the student (trained only on "normal" data) fails to predict the teacher's response. The authors of GTrans identify a specific gap in these models: they often treat different feature resolutions independently, ignoring the rich information interaction between multi-scale layers.
Methodology
The GTrans framework consists of two main branches: an Anomaly Guided Network (AGN), which is a frozen, pre-trained backbone acting as the "teacher," and a Trans Network, a trainable "student" network trained from scratch on the target "normal" dataset.
Key Innovations
- Tokenizer: Instead of raw feature maps, GTrans uses a Tokenizer module to convert features into a compact set of visual tokens using point-wise convolutions and spatial attention, improving computational efficiency.
- Transformer Module (TFM): This module uses an encoder-decoder structure. The encoder processes tokens from the student (Trans), while the decoder uses tokens from the teacher (AGN) as guidance. This allows the model to establish relationships between features at different resolutions (multiresolution).
- Novel Anomaly Scoring: During testing, the model compares the features of the AGN and the Trans network using a hybrid function that combines Mean Squared Error (MSE) and Cosine Similarity. This captures both the "distance" and the "direction" of feature deviations.
Experimental Results
The model was evaluated on the MVTec Anomaly Detection (MVTec AD) dataset, which contains over 5,000 high-resolution images across 15 categories (5 textures and 10 objects).
GTrans sets a new bar for the MVTec AD dataset:
- Detection (Image-level): Achieved an average 99.0% AUROC, with perfect 100% scores in categories like "carpet," "leather," and "bottle."
- Localization (Pixel-level): Achieved an average 97.9% AUROC and a 93.0% PRO-score.
- Comparison: It outperformed other leading methods like InTra and SPADE, particularly in complex object categories where feature interaction is critical.
Discussion and Insights
- The Power of Interaction: Anomalies often disrupt the relationship between different scales of an image. By using a Transformer to let these scales "talk" to each other, the model becomes much more sensitive to subtle defects.
- Teacher-Guided Decoding: GTrans uses the decoder to explicitly inject "tacit knowledge" from the pre-trained teacher, which stabilizes the student's learning of the normal data manifold.
- Resolution Trade-offs: The authors found that using the deepest layers of a CNN actually hurt localization performance due to low spatial resolution. GTrans performs best using intermediate layers (Layers 1, 2, and 3), balancing semantic meaning with spatial precision.
Conclusion
GTrans demonstrates that the synergy between pre-trained feature guidance and Transformer-based multiresolution interaction is a highly effective recipe for industrial anomaly detection. While the model shows high sensitivity, future work may focus on automating layer selection and reducing the computational overhead of parallel backbones.
Summary updated