Source-linked AI summary
SubspaceAD: Training-Free Few-Shot Anomaly Detection via Subspace Modeling
Camile Lendering, Erkut Akdag, Egor Bondarev
TL;DR
Industrial anomaly detection must work with few normal examples, yet recent few-shot methods often rely on memory banks, auxiliary data, or vision-language tuning. SubspaceAD uses frozen DINOv2 features and PCA to model normal variation, and achieves state-of-the-art results across one-shot and few-shot settings on MVTec-AD and VisA.
Problem
Few-shot industrial anomaly detection has limited normal training examples, while recent methods often rely on memory banks, auxiliary datasets, or vision-language tuning.
Source: §1 · p. 1Method
SubspaceAD extracts patch-level features with frozen DINOv2 and fits a PCA subspace to normal features, detecting anomalies through reconstruction residuals.
Source: §1 · p. 2, §3.2 · p. 3Results
Takeaways & Limitations
The results indicate that simple statistical modeling can perform strongly when expressive vision-foundation features are available.
Source: §5 · p. 8The method assumes normal patch features lie near a low-dimensional linear subspace and anomalies have large residuals outside it.
Source: §3.1 · p. 3
Abstract
from arXiv · showhide
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.
1. Introduction
Industrial anomaly detection is constrained by the scarcity of clean examples, while many few-shot approaches add training, tuning, or memory-bank complexity. SubspaceAD instead models normal variation with PCA over foundation-model features and reports strong few-shot results.
1. Introduction
- Figure 1 shows predicted anomaly masks for test samples across all 15 MVTec-AD categories using one normal reference image per category.The predicted masks are overlaid in dark blue.Source: Figure 1 · p. 1, §1 · p. 2
- Few-shot anomaly detection addresses the practical setting where only a small number of normal images are available to define category-specific normal appearance.Full-shot methods may require hundreds of defect-free images per category, while zero-shot methods can struggle with subtle, non-semantic defects.Source: §1 · p. 1
- Many recent methods require augmentation, tuning, multi-stage training, auxiliary objectives, or large memory banks, complicating deployment and maintenance.The introduction asks whether such complexity remains necessary given the dense, transferable features of foundation vision models such as DINOv2.Source: §1 · p. 2
- SubspaceAD fits a PCA subspace to normal appearance and treats reconstruction residuals—deviations from that subspace—as anomaly indicators.The method relies on foundation-model features to capture normal variation from a few images.Source: §1 · p. 2
- SubspaceAD combines frozen DINOv2 features with PCA for training-free few-shot anomaly detection, outperforming reconstruction-, memory-bank-, and VLM-based approaches across the evaluated settings.The method is described as interpretable and parameter-free, requiring one normal image per category and one forward pass per test image.Source: §1 · p. 2
2. Related Work
Prior few-shot anomaly-detection work spans reconstruction, memory banks, vision-language prompts, and training-free methods. SubspaceAD follows the push to reduce supervision but models normal variation with a PCA subspace rather than relying on memory banks or prompt tuning.
2.1. Reconstruction-Based Approaches
- Reconstruction-based methods use reconstruction error to flag deviations from learned normal appearance, but require training and careful tuning or balancing of reconstruction quality and anomaly sensitivity.Approaches range from autoencoders and generative models to perceptual-loss, diffusion-prior, feature-regression, and transform-matrix methods.Source: §2.1 · p. 2
2.2. Memory Bank-Based Anomaly Detection
- Memory-bank methods detect anomalies by nearest-neighbor matching against stored normal patch features, but may store thousands to millions of descriptors and incur costly inference search.SPADE and PatchCore are described as training-free few-shot examples; PatchCore selects a compact core set to reduce memory redundancy.Source: §2.2 · p. 2
2.3. Foundational Models and VLM-Based Approaches
- Vision-language approaches use prompts or language alignment for anomaly detection, but often depend on prompt tuning, auxiliary data, or domain-specific textual priors.Examples include manually designed prompts, learned prompt adapters, and prompts generated from normal instances.Source: §2.3 · p. 3
2.4. Few-Shot and Training-Free Anomaly Detection
- Few-shot methods reduce supervision through stored patch features, learned feature distributions, prompts, or collective test-set statistics; SubspaceAD instead models normal variation with a PCA subspace.The cited approaches include training-free retrieval, fine-tuned parametric models, language-guided detection, and batched zero-shot frameworks.Source: §2.4 · p. 3
3. Method
SubspaceAD models normal patch-feature variation with PCA and detects anomalies from test-feature reconstruction residuals. It uses frozen DINOv2-G features and a compact, training-free fitting and inference pipeline.
3. Method
- SubspaceAD fits a PCA subspace to normal patch features and detects test-image anomalies from reconstruction residuals.The method uses frozen DINOv2-G features and requires no memory bank, prompt tuning, or external data.Source: §3 · p. 3
3.1. Problem Formulation
- The few-shot task assumes normal patch features lie near a low-dimensional linear subspace, while anomalous regions have large residuals outside it.The goal is to predict anomaly likelihood at every test-image spatial position.Source: §3.1 · p. 3
3.2. Feature Extraction
- Frozen DINOv2-G features average tokens from intermediate layers to combine semantic and spatial detail for patch-level representations.Features from layers 22–28 are mean-pooled; fitting also uses 30 randomly rotated augmented views per normal image.Source: §3.2 · pp. 3–4
3.3. Subspace Modeling of Normal Features
- Deterministic PCA models normal features with a mean and top-eigenvector basis, retaining components that explain at least 99% of variance.The squared residual orthogonal to the subspace defines the anomaly score.Source: §3.3 · p. 4
3.4. Anomaly Scoring and Localization
- Each test patch is projected onto the normal subspace and scored by its squared reconstruction residual.These patch scores form a low-resolution anomaly map.Source: §3.4 · p. 4
- Image-level scores average the top 1% of patch scores; localization maps are upsampled and Gaussian-smoothed.Normalized maps are for visualization, while AUROC and PRO use raw scores.Source: §3.4 · p. 5
3.5. Complexity and Memory Analysis
- PCA fitting requires O(nD^2) covariance computation and O(D^3) eigendecomposition, and the model typically occupies less than 1 MB per category.On a 672×672 image, inference takes about 300 ms on an NVIDIA H100 GPU, including about 226 ms for DINOv2-G and 74 ms for projection and scoring.Source: §3.5 · p. 5
4. Experiments
SubspaceAD is evaluated on MVTec-AD and VisA in few-shot settings against methods from three major paradigms, with additional batched 0-shot evaluation and ablations. It achieves state-of-the-art average performance across few-shot metrics, while ablations assess the effects of resolution, feature aggregation, backbone scale, and PCA threshold.
4.1. Datasets
- Evaluations use normal-only training samples and labeled test instances from 15 MVTec-AD categories and the broader, higher-resolution VisA benchmark.Performance is measured at image and pixel levels; five-seed runs use frozen DINOv2-G features averaged across layers 22–28, with 672 px inputs and rotation augmentation, against memory-bank, reconstruction, and VLM baselines.Source: §4.1 · p. 5, §4.2 · p. 5, §4.3 · p. 5
4.5. Comparison to the State-of-the-Art
- 97.1% image-level and 97.5% pixel-level AUROC on MVTec-AD, and 93.2% image-level AUROC and 95.5% PRO on VisA in 1-shot; SubspaceAD leads prior methods.On VisA, it surpasses AnomalyDINO by 5.8% in image-level AUROC and 3.0% in PRO; it maintains its lead across metrics as reference samples increase.Source: Table 1 · p. 6, §4.5 · p. 6
4.6. Batched 0-Shot Performance
- Batched 0-shot evaluation fits one PCA subspace to all unlabeled test-set patch tokens per category, assuming most patches are anomaly-free, and scores reconstruction residuals.It models the test set jointly rather than storing patches for nearest-neighbor retrieval; the paper contrasts this with approaches that may suppress anomaly scores or remain sensitive to category contamination.Source: §4.6 · pp. 6–7
4.5. Comparison to the State-of-the-Art
- Qualitative comparisons report sharper, more precise anomaly maps with fewer false activations and better ground-truth alignment than PromptAD and AnomalyDINO across both benchmarks.The paper also notes representative failure modes in Appendix F.Source: §4.5 · p. 6, Figure 3 · p. 7
4.6. Batched 0-Shot Performance
- 94.1% image-level AUROC on VisA matches MuSc and surpasses AnomalyDINO in batched 0-shot evaluation; MVTec-AD AUROC is 96.6%.The reported comparison is image-level AUROC; Table 2 summarizes the batched 0-shot results.Source: §4.6 · pp. 6–7, Table 2 · p. 7
4.7. Ablation Study
- 672 px is the reported performance peak on both datasets, while results are largely stable above 448 px once sufficient spatial detail is available.VisA performance improves from 256 px before saturating; on MVTec-AD, resolutions above 448 px perform comparably across metrics.Source: Figure 4 · p. 7, §4.7 · p. 7
- Mean-pooling layers 22–28 gives the best overall aggregation results, reaching 95.0% PRO on MVTec-AD and 94.1% image-level AUROC on VisA in 4-shot.Using only the last layer substantially reduces VisA image-level AUROC to 89.3%; concatenating layers 22–28 yields higher MVTec-AD image-level AUROC (98.6%) but is less robust across benchmarks.Source: §4.7 · pp. 7–8, Table 3 · p. 8
- Larger DINOv2 backbones consistently improve performance, while SubspaceAD adds negligible computational overhead and can also use smaller, edge-friendly encoders.DINOv3 backbones perform slightly worse in this setting.Source: §4.7 · p. 8, Figure 5 · p. 8
5. Conclusion
SubspaceAD uses frozen DINOv2-G patch features and a PCA subspace to detect anomalies through reconstruction residuals, without training or feature memory banks. It achieves state-of-the-art performance on MVTec-AD and VisA across one- and few-shot settings.
5. Conclusion
- SubspaceAD models normal variation with a PCA subspace fitted to patch-level features from a frozen DINOv2-G encoder.Anomalies are detected through reconstruction residuals.Source: §5 · p. 8
- The method requires no training, memory banks, auxiliary datasets, or prompt tuning.Source: §5 · p. 8
- SubspaceAD achieves state-of-the-art performance across one- and few-shot settings on both MVTec-AD and VisA.Source: §5 · p. 8
A. Per-Category Few-Shot Results
Per-category results show strong but variable few-shot performance, while the DINOv3-7B backbone does not improve on DINOv2-G overall. The reported limits include weaker Transistor localization and greater difficulty on diverse VisA categories.
A. Per-Category Few-Shot Results
- Tables 5 and 6 report per-category few-shot performance on MVTec-AD and VisA.Source: A. Per-Category Few-Shot Results · p. 11
- With one normal image, several MVTec-AD categories reach perfect or near-perfect image-level AUROC, while Transistor has a 1-shot Pixel PRO score of 68.9%.The passage attributes the Transistor limitation to patch-based detection focusing on local appearance rather than logical or structural anomalies.Source: A. Per-Category Few-Shot Results · p. 11
- On VisA, 1-shot image-level AUROC is 97.7% for Cashew and 99.2% for Chewing Gum, versus 80.4% for Macaroni2 and 86.5% for PCB3.The passage attributes weaker results to defect-like background artifacts and high intra-class variability among normal samples.Source: A. Per-Category Few-Shot Results · p. 11
B. Performance of DINOv3 Backbones
- Using 4096-dimensional DINOv3-7B features from layers 22–28 with 16×16 patch tokens did not improve over DINOv2-G, which remained stronger overall, especially on localization metrics.Source: B. Performance of DINOv3 Backbones · p. 11
C. Full-Shot Setting Analysis
In the full-shot comparison, SubspaceAD is competitive with AnomalyDINO on MVTec-AD and surpasses it across the reported VisA metrics. Unlike AnomalyDINO’s dense feature storage and K-NN retrieval, SubspaceAD uses a forward pass and lightweight subspace projection.
C. Full-Shot Setting Analysis
- On VisA, SubspaceAD exceeds AnomalyDINO on image-level AUROC (98.2% vs. 97.6%), image-level AUPR (98.3% vs. 98.0%), pixel-level AUROC (99.1% vs. 98.8%), and Pixel PRO (96.9% vs. 96.1%).Source: C. Full-Shot Setting Analysis · p. 11
- On MVTec-AD, AnomalyDINO has higher I-AUROC (99.5% vs. 99.2%), both methods have Pixel AUROC of 98.2%, and SubspaceAD has higher Pixel PRO (95.6% vs. 95.0%).Source: C. Full-Shot Setting Analysis · p. 11
- AnomalyDINO stores dense patch features and uses K-NN retrieval, whereas SubspaceAD needs no feature memory bank and uses a single forward pass plus lightweight projection.The AnomalyDINO memory is typically on the order of 106 feature vectors per VisA category.Source: C. Full-Shot Setting Analysis · p. 11
D. Inference Time Analysis
Scoring-head latency is comparable in the few-shot regime, and SubspaceAD’s projection time is invariant to support-set size once PCA components are determined. End-to-end wall-clock timings are not directly comparable because the methods were measured on different hardware.
D. Inference Time Analysis
- End-to-end wall-clock comparisons are inappropriate because AnomalyDINO was measured on an NVIDIA A40 and SubspaceAD on an NVIDIA H100; both methods’ total inference time is primarily backbone-forward-pass time.SubspaceAD uses only the backbone and a lightweight projection, with no feature-memory storage or search.Source: D. Inference Time Analysis · p. 11
- On an H100, few-shot scoring-head latency is approximately 74 ms per image for SubspaceAD and 80 ms for AnomalyDINO.Source: D. Inference Time Analysis · p. 11
- SubspaceAD’s subspace projection time is invariant to support-set size once PCA components are determined.Source: D. Inference Time Analysis · p. 11
E. Additional Qualitative Results
The section extends the paper’s qualitative experiments with detailed anomaly maps from VisA and MVTec-AD, illustrating localization across varied categories and anomaly types.
E. Additional Qualitative Results
- Detailed anomaly maps extend the paper’s qualitative experiments with representative VisA and MVTec-AD samples.The section presents examples from both datasets.Source: E. Additional Qualitative Results · p. 11
- VisA examples illustrate localization performance across diverse object categories and anomaly types.The maps are shown in Fig. 6.Source: E. Additional Qualitative Results · p. 11
- MVTec-AD examples likewise illustrate localization performance across diverse object categories and anomaly types.The maps are shown in Fig. 7.Source: E. Additional Qualitative Results · p. 11
F. Failure Cases and Limitations
The section describes limitations of patch-based few-shot modeling and examines rotation-agnostic preprocessing. On orientation-dependent Transistor anomalies, adding rotated support samples reduces performance relative to the aligned baseline.
F. Failure Cases and Limitations
- The patch-based method models local appearance and texture but lacks explicit global spatial relationships and semantic rules, so a missing component may be mistaken for normal texture.In the Transistor example, exposed circuit-board background may be identified as normal because the model does not know a component should occupy that location.Source: F. Failure Cases and Limitations · p. 12
- High normal variation can prevent a compact subspace from forming from few shots, while unseen benign background artifacts such as shadows or debris may be flagged as anomalies.The text identifies Macaroni2 and PCB3 as challenging examples.Source: F. Failure Cases and Limitations · pp. 12–13
- The authors suggest geometric or semantic priors as a future direction for addressing logical and structural anomalies.The outlook also notes the potential of foundation-model representations paired with lightweight, interpretable modeling.Source: F. Failure Cases and Limitations · p. 13
- Qualitative failure cases include missed structural defects, incorrect cable-swap detections, and false positives from intra-class variation or background clutter.Figure 8 shows examples of these failure modes.Source: Figure 8 · p. 13
G. Impact of Rotation-Agnostic Preprocessing
- 7.5 percentage points (1-shot Image AUROC, 96.6% to 89.1%) and 6.3 percentage points (1-shot Pixel PRO, 68.9% to 62.6%); 4-shot Pixel PRO falls 8.3 percentage points, 72.7% to 64.4%.The rotation-agnostic protocol is compared with the standard aligned baseline; Table 11 reports the protocol results and Table 5 the detailed standard results.Source: Table 5 · p. 12, G. Impact of Rotation-Agnostic… · p. 14, Table 11 · p. 14
Related papers
This paper cites
- Learning Transferable Visual Models From Natural Language Supervision2021
- A Simple Framework for Contrastive Learning of Visual Representations2020
- Deep Learning for Anomaly Detection: A Review2020
- GANomaly: Semi-Supervised Anomaly Detection via Adversarial Training2018
- Sub-Image Anomaly Detection with Deep Pyramid Correspondences2020