TL;DR
This paper introduces Iterative Latent Token Masking (ILTM), a novel self-supervised method for anomaly detection that can effectively train models even when the training data is heavily contaminated with anomalies. This is a significant advancement for fields like medical imaging where obtaining anomaly-free datasets is often impractical or impossible.
What Problem Does This Paper Address?
Anomaly detection is crucial in many fields, from manufacturing quality control to medical imaging. Traditional supervised methods require extensive labeled data, which is costly and time-consuming to obtain. Unsupervised methods, while avoiding explicit labels, typically demand training data that is entirely free of anomalies. This requirement is a major bottleneck, especially in medical imaging, where scans are often collected from patients with pre-existing conditions, making anomaly-free datasets rare. Existing self-supervised methods also struggle when faced with significant proportions of anomalous data in the training set, leading to performance degradation. This paper tackles the challenge of training robust anomaly detection models when the training data is inherently noisy and contains a substantial number of anomalies.
Methods
The proposed method, Iterative Latent Token Masking (ILTM), builds upon the VQ-VAE (Vector Quantized-Variational Autoencoder) and Transformer architecture, which has shown state-of-the-art performance for anomaly detection on normal data. The core innovation lies in its iterative self-supervised training process:
- VQ-VAE for Discrete Latent Representation: First, a VQ-VAE is trained to encode images into a discrete latent space. This is crucial because Transformers work best with discrete, categorical data.
- Transformer for Anomaly Detection: A Transformer model is then trained on these discrete latent codes to learn the probability distribution of normal data.
- Iterative Token Masking: This is the key novelty. In each iteration:
- The Transformer is used to identify "low likelihood" tokens within the training data, which are suspected anomalies.
- These anomalous tokens are "masked" (their influence is removed) during the Transformer's training for the next iteration. This is achieved by assigning a negative infinity value to masked tokens in the attention mechanism, effectively preventing them from influencing the model's learning.
- A Kernel Density Estimation (KDE) based anomaly score is used to generate an anomaly map, which is then downsampled to create a binary mask for the latent space.
- Resampling and Reconstruction: Anomalous tokens are replaced with higher likelihood tokens by resampling from the Transformer. Multiple "healed" latent representations are generated and then decoded by the VQ-VAE.
- Iterative Refinement: This process of detecting, masking, and retraining is repeated over several iterations. The goal is to progressively remove the influence of anomalies from the training data, allowing the model to learn a representation of pure normality.
This approach differs from prior methods like STKD (Self-Trained Knowledge Distillation) which remove anomalous samples entirely, potentially reducing the training data size. ILTM masks anomalies, retaining the full dataset size and aiming for greater robustness.
Datasets
The paper evaluates ILTM on two datasets:
- AutoPET - 3D Whole-Body PET Dataset: This medical imaging dataset is specifically chosen to highlight the challenge of obtaining anomaly-free data. It contains healthy scans and scans with various pathologies (lung cancer, lymphoma, melanoma). The authors create training datasets with anomalous-to-healthy subject ratios ranging from 0% to 100%.
- MVTec Dataset: A widely adopted benchmark for industrial anomaly detection. The authors use this dataset to demonstrate the broader applicability of their method to common computer vision tasks, creating training sets with anomaly proportions from 0% to 80%.
Key Insights and Ideas
- Anomalies as "Noise" to be Filtered: The core idea is to treat anomalies in the training data not as something to be avoided, but as "noise" that can be iteratively identified and filtered out, allowing the model to learn a cleaner representation of normality.
- Transformer's Attention for Anomaly Localization: The autoregressive nature of Transformers, combined with their attention mechanism, is leveraged to pinpoint low-probability tokens, which are indicative of anomalies.
- Iterative Masking for Robustness: The iterative masking process is crucial. It allows the model to progressively refine its understanding of what constitutes normal data, even when starting with a highly anomalous dataset. This is more robust than methods that simply remove anomalous samples.
- Unsupervised Approach for Real-World Scenarios: The method's ability to work without any prior segmentation labels or anomaly-free data makes it highly practical for real-world applications where such data is scarce.
Key Results
- Superior Performance with Anomalous Data: ILTM significantly outperforms several state-of-the-art anomaly detection methods (Dense AE, Dense VAE, CutPaste, NSA, STKD, and VQ-VAE + Transformer without ILTM) when trained on datasets with varying levels of anomalous data.
- High Contamination Resilience: Even with training data that is 80% anomalous (MVTec) or 100% anomalous (PET), ILTM shows minimal performance degradation, maintaining high AUROC and AUPRO scores. For instance, on MVTec with 80% anomalous data, ILTM achieves an AUROC of 82.7 and AUPRO of 74.3, while other methods see substantial drops.
- Improved Iterative Training: The iterative training process, especially with a decreasing resampling threshold, leads to performance improvements over training cycles, as shown in Figure 3.
- Qualitative Results: Figure 5 visually demonstrates ILTM's ability to generate accurate anomaly maps, even when compared to methods that struggle with highly anomalous training data.
Limitations and Future Work
- Threshold Tuning: The paper acknowledges that the KDE likelihood threshold (0.005) used for anomaly detection and the resampling threshold reduction percentage (12.5%) were arbitrarily chosen and not extensively tuned. Further exploration of these parameters could potentially lead to even better results.
- Computational Cost: While not explicitly detailed as a limitation, iterative training processes can be computationally intensive.
- Future Work: The authors suggest that further investigation into threshold selection could yield improvements. They also express hope that their work will inspire further research into anomaly detection without normal data, a field they believe is underexplored.
Summary updated