SubspaceAD: Training-Free Few-Shot Anomaly Detection via Subspace Modeling
Organizations: AIMS Group, Department of Electrical Engineering, Eindhoven University of Technology
Abstract
Detecting visual anomalies in industrial inspection often requires training with only a few normal images per category. Recent few-shot methods achieve strong results employing foundation-model features, but typically rely on memory banks, auxiliary datasets, or multi-modal tuning of vision-language models. We therefore question whether such complexity is necessary given the feature representations of vision foundation models. To answer this question, we introduce SubspaceAD, a training-free method, that operates in two simple stages. First, patch-level features are extracted from a small set of normal images by a frozen DINOv2 backbone. Second, a Principal Component Analysis (PCA) model is fit to these features to estimate the low-dimensional subspace of normal variations. At inference, anomalies are detected via the reconstruction residual with respect to this subspace, producing interpretable and statistically grounded anomaly scores. Despite its simplicity, SubspaceAD achieves state-of-the-art performance across one-shot and few-shot settings without training, prompt tuning, or memory banks. In the one-shot anomaly detection setting, SubspaceAD achieves image-level and pixel-level AUROC of 97.1% and 97.5% on the MVTec-AD dataset, and 93.2% and 98.2% on the VisA dataset, respectively, surpassing prior state-of-the-art results. Code and demo are available at https://github.com/CLendering/SubspaceAD.
Figures & tables
| MVTec-AD | VisA | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Image-level | Pixel-level | Image-level | Pixel-level | ||||||
| Setup | Method | AUROC | AUPR | AUROC | PRO | AUROC | AUPR | AUROC | PRO |
| 0-shot | WinCLIP | 91.8 | 96.5 | 85.1 | 64.6 | 78.1 | 81.2 | 79.6 | 56.8 |
| 1-shot | SPADE | 81.0 | 90.6 | 91.2 | 83.9 | 79.5 | 82.0 | 95.6 | 84.1 |
| PatchCore | 83.4 | 92.2 | 92.0 | 79.7 | 79.9 | 82.8 | 95.4 | 80.5 | |
| FastRecon | - | - | - | - | - | - | - | - | |
| Method | MVTec-AD | VisA |
|---|---|---|
| Zero-shot methods | ||
| WinCLIP [ 18 ] | 91.8 | 78.1 |
| AnomalyCLIP [ 42 ] | 91.5 | 82.1 |
| Batched zero-shot methods | ||
| ACR [ 20 ] | 85.8 | – |
| MuSc [ 23 ] | 97.8 | 94.1 |
| MVTec-AD | VisA | |||
|---|---|---|---|---|
| Strategy | I-AUROC | PRO | I-AUROC | PRO |
| Mean-pool (Middle-7) | 98.4 | 95.0 | 94.1 | 95.1 |
| Mean-pool (Final-7) | 98.2 | 93.3 | 91.9 | 93.5 |
| Concat (Middle-7) | 98.6 | 95.0 | 93.8 | 95.0 |
| Last layer only | 97.6 | 92.5 | 89.3 | 91.2 |
| MVTec-AD | VisA | |||||
| I-AUROC (%) | ||||||
| 0.95 | 98.0 | 98.2 | 98.4 | 92.2 | 93.4 | 93.7 |
| 0.96 | 98.1 | 98.2 | 98.4 | 92.4 | 93.5 | 93.9 |
| 0.97 | 98.1 | 98.2 | 98.5 | 92.4 | 93.6 | 93.9 |
| 0.99 | 98.1 | 98.2 | 98.4 | 92.5 | 93.6 | 94.1 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Category | 1-shot | 2-shot | 4-shot | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Img AUROC | Img AUPR | Pxl AUROC | PRO | Img AUROC | Img AUPR | Pxl AUROC | PRO | Img AUROC | Img AUPR | Pxl AUROC | PRO | |
| Bottle | 100.0 0.0 | 100.0 0.0 | 98.6 0.0 | 96.5 0.1 | 100.0 0.0 | 100.0 0.0 | 98.7 0.0 | 96.7 0.1 | 100.0 0.0 | 100.0 0.0 | 98.7 0.0 | 96.7 0.1 |
| Cable | 92.1 1.4 | 95.5 0.7 | 95.6 0.2 | 90.3 0.7 | 92.7 1.2 | 96.2 0.6 | 95.6 0.2 | 90.6 0.5 | 93.5 0.7 | 96.7 0.5 | 95.7 0.2 | 90.9 0.4 |
| Capsule | 88.1 11.3 | 96.8 3.9 | 98.0 0.2 | 96.7 0.5 | 92.7 3.6 | 98.4 0.9 | 98.2 0.1 | 97.1 0.2 | 93.4 4.8 | 98.5 1.2 | 98.3 0.1 | 97.3 0.2 |
| Carpet | 100.0 0.0 | 100.0 0.0 | 99.2 0.0 | 98.2 0.1 | 100.0 0.0 | 100.0 0.0 | 99.2 0.0 | 98.2 0.0 | 100.0 0.0 | 100.0 0.0 | 99.3 0.0 | 98.3 0.0 |
| Grid | 100.0 0.0 | 100.0 0.0 | 99.5 0.0 | 98.1 0.1 | 100.0 0.0 | 100.0 0.0 | 99.5 0.0 | 98.2 0.1 | 100.0 0.0 | 100.0 0.0 | 99.5 0.0 | 98.3 0.1 |
| Category | 1-shot | 2-shot | 4-shot | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Img AUROC | Img AUPR | Pxl AUROC | PRO | Img AUROC | Img AUPR | Pxl AUROC | PRO | Img AUROC | Img AUPR | Pxl AUROC | PRO | |
| Candle | 94.4 0.8 | 94.2 0.7 | 99.4 0.0 | 97.9 0.2 | 94.2 0.5 | 93.8 0.7 | 99.4 0.0 | 98.1 0.1 | 93.9 0.9 | 93.4 1.1 | 99.4 0.0 | 98.1 0.1 |
| Capsules | 96.5 0.7 | 97.9 0.4 | 98.5 0.2 | 97.0 0.3 | 96.8 0.3 | 98.1 0.2 | 98.6 0.1 | 97.2 0.3 | 97.0 0.9 | 98.2 0.6 | 98.6 0.1 | 97.3 0.3 |
| Cashew | 97.7 0.7 | 98.9 0.3 | 99.0 0.0 | 98.5 0.2 | 97.9 1.3 | 99.0 0.6 | 99.2 0.1 | 98.6 0.1 | 98.7 0.8 | 99.4 0.4 | 99.3 0.1 | 98.7 0.1 |
| Chewing Gum | 99.2 0.1 | 99.6 0.1 | 99.6 0.0 | 96.0 0.2 | 99.1 0.1 | 99.6 0.0 | 99.6 0.0 | 96.3 0.1 | 99.1 0.0 | 99.5 0.0 | 99.6 0.0 | 96.2 0.1 |
| Fryum | 97.0 0.6 | 98.7 0.3 | 96.5 0.3 | 95.4 0.5 | 97.9 0.1 | 99.1 0.1 | 96.8 0.1 | 95.5 0.3 | 98.1 0.3 | 99.2 0.1 | 97.0 0.1 | 95.7 0.3 |
| MVTec-AD | VisA | ||||||||
| Image-level | Pixel-level | Image-level | Pixel-level | ||||||
| Setup | Method | AUROC | AUPR | AUROC | PRO | AUROC | AUPR | AUROC | PRO |
| 1-shot | SubspaceAD 448 (DINOv3) | 96.4 | 98.0 | 97.3 | 94.0 | 91.8 | 91.9 | 98.0 | 93.8 |
| SubspaceAD 672 (DINOv3) | 96.2 | 97.9 | 97.3 | 94.2 | 92.8 | 92.9 | 98.0 | 94.7 | |
| 2-shot | SubspaceAD 448 (DINOv3) | 97.1 | 98.3 | 97.6 | 94.5 | 92.9 | 92.7 | 98.2 | 94.3 |
| SubspaceAD 672 (DINOv3) | 96.8 | 98.2 | 97.5 | 94.7 | 93.7 | 93.6 | 98.1 | 95.1 | |
| MVTec-AD | VisA | ||||||||
| Image-level | Pixel-level | Image-level | Pixel-level | ||||||
| Setup | Method | AUROC | AUPR | AUROC | PRO | AUROC | AUPR | AUROC | PRO |
| Full-shot | AnomalyDINO | 99.5 | 99.8 | 98.2 | 95.0 | 97.6 | 98.0 | 98.8 | 96.1 |
| Full-shot | SubspaceAD (Ours) | 99.2 | 99.6 | 98.2 | 95.6 | 98.2 | 98.3 | 99.1 | 96.9 |
| Method | Setting ( ) | Scoring Time (ms / img) |
|---|---|---|
| AnomalyDINO | 1-shot | |
| AnomalyDINO | 2-shot | |
| AnomalyDINO | 4-shot | |
| SubspaceAD (Ours) | 1–4 shot | 74.1 |
| Method | Backbone | Params (M) | GPU | Time (ms / image) |
| WinCLIP [ 18 ] | CLIP ViT-B/16+ | NVIDIA T4 | ||
| AnomalyDINO [ 11 ] | DINOv2 ViT-S | NVIDIA A40 | ||
| AnomalyDINO [ 11 ] | DINOv2 ViT-B | NVIDIA A40 | ||
| AnomalyDINO [ 11 ] | DINOv2 ViT-L | NVIDIA A40 | ||
| SubspaceAD (Ours) – DINOv2 Backbones (NVIDIA H100) | ||||
| SubspaceAD (Ours) | DINOv2 ViT-S | NVIDIA H100 | ||
| Shots | Img AUROC | Img AUPR | Pxl AUROC | Pxl PRO |
|---|---|---|---|---|
| 1-shot | 89.1 7.5 | 84.7 5.7 | 82.3 3.1 | 62.6 2.0 |
| 2-shot | 92.6 3.6 | 88.5 4.7 | 83.6 0.9 | 63.7 0.9 |
| 4-shot | 93.4 4.0 | 90.3 4.3 | 84.0 1.9 | 64.4 1.3 |