TL;DR
This paper introduces RegAD, a novel approach to Few-Shot Anomaly Detection (FSAD) that trains a single, category-agnostic model by leveraging image registration as a proxy task. This allows for rapid adaptation to new anomaly detection scenarios with minimal training data and no parameter fine-tuning, outperforming existing methods on challenging benchmarks.
What Problem Does This Paper Address?
Anomaly Detection (AD) is crucial for identifying unusual patterns in data, with applications ranging from manufacturing defect detection to medical diagnosis. A significant challenge in AD is the "few-shot" setting, where only a limited number of "normal" examples are available for training. This is particularly problematic in industrial settings with numerous product types, making it impractical to train a dedicated model for each. Existing few-shot AD methods still rely on a "one-model-per-category" paradigm, failing to exploit commonalities across different categories. This paper addresses this gap by proposing a "one-model-all-category" approach that learns a generalizable model capable of detecting anomalies in novel categories with just a few normal samples, inspired by how humans compare new observations to known normal examples.
Methods
The core innovation of RegAD lies in its use of feature registration as a category-agnostic proxy task. Instead of directly learning anomaly detection, the model is trained to align features from different images of the same category. This is achieved using a Siamese network architecture with spatial transformer networks (STNs).
Here's a breakdown of the key components:
- Feature Extraction: A ResNet-18 backbone is used to extract features, with the first three convolutional blocks retained to preserve spatial information.
- Spatial Transformer Networks (STNs): STNs are integrated into each convolutional block to enable flexible feature registration, allowing the model to learn how to align features from different images.
- Siamese Network: A Siamese network architecture with a shared encoder is employed. To prevent collapsing solutions (where the model learns trivial mappings), a stop-gradient operation is used, similar to SimSiam.
- Feature Registration Loss: A negative cosine similarity loss is used to maximize the similarity between registered features from the same category, promoting feature alignment.
- Category-Agnostic Training: Normal images from multiple known categories are aggregated for training. This encourages the model to learn generalizable registration capabilities, not specific to any single category.
- Anomaly Detection at Test Time: For a new, unseen category, a small support set of normal images is provided. The trained registration network is applied to these support images and a test image. Anomalies are detected by comparing the registered features of the test image to the estimated normal distribution of the registered support features, using a statistical-based estimator (multivariate Gaussian distribution) and Mahalanobis distance.
Datasets
The proposed method is evaluated on two challenging real-world industrial defect detection benchmarks:
- MVTec AD: This dataset contains 15 categories with a total of 3629 training/validation images and 1725 testing images. It includes images with various defects and defect-free normal images.
- MPDD: This dataset focuses on defect detection in painted metal parts, featuring 6 classes of metal parts captured under diverse conditions.
Key Insights and Ideas
- Registration as a Generalizable Proxy Task: The paper demonstrates that image registration, a task inherently capable of aligning diverse visual information, can be effectively repurposed as a proxy task for learning category-agnostic anomaly detection. This is a significant departure from previous FSAD methods.
- Human-like Anomaly Detection: The approach is inspired by how humans compare new observations to known normal examples. By learning to align features, the model learns a fundamental comparison mechanism that can be applied universally.
- No Fine-Tuning Required: A key advantage is that the trained model requires no parameter fine-tuning for new categories. Adaptation is achieved solely by estimating the normal feature distribution from the support set, making it highly efficient for real-world deployment.
- Importance of Support Set Augmentations: The study highlights that augmenting the support set (e.g., with rotation, translation, flipping) is crucial for improving both anomaly detection and localization performance.
Key Results
- State-of-the-Art Performance: RegAD significantly outperforms existing state-of-the-art FSAD methods (TDG+ and DiffNet+) on both MVTec and MPDD datasets. For example, it achieves improvements of 5.1%, 6.9%, and 8.0% in average AUC on MVTec for 2-shot, 4-shot, and 8-shot scenarios, respectively.
- Competitive with Vanilla AD: RegAD demonstrates competitive performance even when compared to traditional AD methods trained on much larger, full datasets. For instance, with only 4 support images, it outperforms MKD (trained on full data) on MVTec.
- Fast Adaptation: The proposed method boasts the fastest adaptation speed among compared methods, with an adaptation time of only 4.47 seconds, compared to hundreds or thousands of seconds for others.
- Improved Feature Representation: t-SNE visualizations show that features learned with RegAD are more compact within each category and better separated from different categories, indicating a more robust feature representation.
- Effective Localization: The method also shows strong performance in anomaly localization, producing results that are closer to ground truth compared to individual training baselines.
Limitations and Future Work
- Performance Saturation with Large k: While increasing the number of support images (k) generally improves performance, the gains tend to saturate quickly. The paper shows limited performance gains beyond k=128.
- STN Effectiveness Varies: The effectiveness of STN modules can vary depending on the dataset. While beneficial for MPDD (which has more varied orientations), it shows less improvement on MVTec where objects are more aligned.
- Future Work: The authors suggest that the proposed method has high potential for real-world applications due to its efficiency and effectiveness. Further exploration of different augmentation strategies and STN transformation versions could lead to further improvements. The paper also implicitly suggests that exploring more sophisticated statistical estimators for normal distribution could be a future direction.
Summary updated