TL;DR
MRAD (Memory-Driven Retrieval Anomaly Detection) shifts the paradigm of zero-shot anomaly detection from complex model fitting to direct data retrieval. By storing and retrieving feature-label pairs from a simple memory bank, it achieves state-of-the-art accuracy across 16 industrial and medical datasets with significantly lower training and inference costs than existing prompt-learning methods.
What Problem Does This Paper Address?
Zero-shot anomaly detection (ZSAD) aims to identify defects or irregularities in images without having seen any labeled examples from the target domain. While Vision-Language Models (VLMs) like CLIP have opened new doors for this task, current approaches generally fall into two camps: prompt ensemble (using hand-crafted templates like "a photo of a defect") or prompt optimization (learning vectors to represent "normality").
The authors argue that both approaches have a fundamental flaw: they try to "fit" a complex parametric model to a data distribution. This often leads to "information loss," where subtle but critical details of what makes an anomaly are smoothed over. Furthermore, these methods are often computationally expensive to train, slow at inference time, and struggle to generalize when moving between wildly different domains, such as from industrial parts to medical scans.
Methods
The core innovation of MRAD is replacing parametric fitting with a two-level feature-label memory bank. Instead of asking a model to remember what an anomaly looks like through its weights, MRAD simply looks it up in a database of raw features.
The framework consists of three hierarchical variants:
- MRAD-TF (Train-Free): The base model. It uses a frozen CLIP image encoder to extract features from a small auxiliary dataset (like the VisA dataset). It stores these as "keys" (features) and "values" (labels: normal or anomalous) in a memory bank. At inference, it calculates an anomaly score based on the similarity between the test image's features and the stored keys.
- MRAD-FT (Fine-Tuned): A lightweight enhancement that adds just two linear layers to "calibrate" the retrieval metric. This helps the model better distinguish between normal and abnormal patterns by enlarging the margin between them in the feature space.
- MRAD-CLIP: This variant bridges the gap back to language. It takes the "region priors" (the areas the retrieval model thinks are anomalous) and injects them as dynamic biases into CLIP’s learnable text prompts. This guides the text encoder to focus on the most relevant parts of the image.
To ensure the model focuses on local defects rather than just global image properties, the authors also utilize a V-V (Value-Value) attention mechanism in the CLIP encoder, which emphasizes local context over dominant global tokens.
Key Insights and Ideas
- Retrieval > Fitting: The "aha moment" here is that the empirical distribution of raw data is often more informative than a compressed model. By directly accessing stored features, the model avoids the "forgetting" or "blurring" that happens during traditional training.
- The "Anomaly Direction": Through t-SNE visualizations, the authors show that CLIP features naturally tend to shift in a consistent "direction" when an anomaly is present. MRAD-FT works by simply amplifying this pre-existing latent direction.
- Stability through Simplicity: Because the core of the model is a memory bank, it is remarkably robust. Ablation studies showed that even if you randomly sub-sample the memory bank down to just 100 entries, the performance drop is negligible.
- Dual Priors: Injecting both normal and anomalous priors into the text prompts (the "dual prior" approach) yielded the most robust results, suggesting that knowing what "good" looks like is just as important as knowing what "bad" looks like.
Key Results
MRAD consistently outperformed previous state-of-the-art methods like AnomalyCLIP and FAPrompt:
- Accuracy: On average across all 16 datasets, MRAD-CLIP achieved 92.7% I-AUROC (image-level classification) and 92.7% P-AUROC (pixel-level segmentation).
- Efficiency: MRAD-FT is incredibly fast to train, requiring only 1 epoch (about 334 seconds), compared to the hundreds of seconds per epoch over many more epochs required by competitors.
- Inference Speed: MRAD-TF/FT clocks in at roughly 198ms per image, significantly faster than the 840ms required by WinCLIP.
- Qualitative: Visualizations show that MRAD produces much "tighter" anomaly maps with fewer false positives in the background compared to previous methods.
Datasets
The authors conducted an extensive evaluation across 16 public datasets:
- Industrial (8): MVTec-AD, VisA, BTAD, MPDD, SDD, KSDD2, DAGM, and DTD-Synthetic.
- Medical (8): HeadCT, BrainMRI, Br35H, CVC-ColonDB, CVC-ClinicDB, Endo, Kvasir, and ISIC.
By using one dataset (e.g., VisA) as the auxiliary source and testing on the other 15, they rigorously tested the "zero-shot" and cross-domain capabilities of the framework.
Limitations and Future Work
- Dependency on Auxiliary Quality: While MRAD is robust, its performance does dip if the auxiliary dataset is too small or lacks diversity (e.g., using a single-category dataset to build the memory bank).
- Synthetic Anomalies: The authors found that using purely synthetic anomalies (like CutPaste) to build the memory bank leads to a performance drop compared to using real anomalous samples, as synthetic defects often lack the semantic complexity of real-world failures.
- Scaling: Future work could explore how this retrieval-based approach scales to massive, "in-the-wild" datasets or how it could be adapted for online, incremental learning where the memory bank is updated in real-time.
Summary updated