TL;DR
Teaching a vision system to spot manufacturing defects from just one to four normal photos is hard, especially on complex objects like circuit boards where "normal" varies wildly from inch to inch. LocalSubspaceAD solves this without any neural network training by clustering image patches into distinct semantic regions (like solder pads vs. microchips) and fitting a specialized linear subspace (via PCA) to each one. By judging every part of a test image only against the natural variation of its own kind, it catches subtle defects that global models completely miss.
What Problem Does This Paper Address?
Imagine inspecting a printed circuit board (PCB) on a factory line using only two reference photos of a good board. A defect-free board is a chaotic place: shiny solder pads, matte green fiberglass, printed text, and dark silicon chips all have their own natural variations in appearance.
Recent few-shot anomaly detection methods extract rich patch embeddings using pre-trained foundation models (like DINOv2) and summarize "normal" appearance using Principal Component Analysis (PCA)—essentially building a single, flat mathematical subspace. If a test patch sticks out of that subspace (high reconstruction error, or residual), it gets flagged as an anomaly.
Here is the catch: a single global subspace has to accommodate the variations of every part of the object simultaneously. If shiny reflections are normal on a solder pad, that direction of variation gets baked into the global subspace. Consequently, if a weird shiny scratch appears on the matte fiberglass, the global model shrugs and reconstructs it effortlessly—letting the defect slip right through.
Methods
To give every part of an object its own tight definition of "normal," the authors introduce LocalSubspaceAD, extending single-subspace PCA into a mixture of local subspaces—completely training-free and without iterative Expectation-Maximization (EM) refinement.
Here is how the pipeline works:
- Standard Foundation Features: Support images are rotated to account for orientation changes and fed through frozen DINOv2 (averaging intermediate layers) or DINOv3 (keeping layers separate).
- Novel Local Partitioning & PCA: Instead of lumping all patch features together, they group similar patches using standard $k$-means clustering ($K=128$). Each cluster gets its own PCA subspace, retaining just enough principal directions ($r_k$) to explain 99% of that specific cluster's variance. Uniform backgrounds get tiny, strict subspaces; complex textures get larger ones.
- Scoring: At test time, we don't know which region a patch belongs to (an anomaly might belong to none!). So, each test patch is projected onto all $K$ subspaces and scored by its smallest reconstruction residual. For DINOv3, layer-wise residuals are normalized by a pooled noise variance ($\sigma^2$) so no single layer dominates. Finally, the top 1% of pixel scores are averaged to get the image-level anomaly score.
Datasets
The authors evaluate their approach in 1-, 2-, and 4-shot settings (using only defect-free support images) across three standard industrial inspection benchmarks with pixel-level defect annotations: MVTec AD, VisA, and Real-IAD (single view). No new datasets were introduced.
Key Insights and Ideas
- It’s the tilt of the subspaces, not their centers: You might guess that having 128 cluster centers simply acts like a compressed memory bank (like $k$-Nearest Neighbors). Ablations prove otherwise: throwing away the cluster centers and centering every local PCA on the single global mean performs identically (and slightly better at 4-shot!). Conversely, keeping the 128 centers while sharing one global covariance wipes out the gains. What matters is the local orientation of variance.
- Unsupervised semantic segmentation for free: Without any masks or labels, $k$-means on DINO features naturally carves objects into human-recognizable parts—separating pill rims from embossed letters, and cable strands from outer sheaths.
- Why a tiny $K$ hurts before a large $K$ helps: Curiously, using $K=2$ or $4$ performs worse than $K=1$. With just a few giant clusters, the most complex cluster retains so many PCA directions that it acts like a sponge, reconstructing almost any patch well and hijacking the minimum-residual score. Once $K \ge 16$, clusters become specific enough ($r_k \approx 312$ median directions vs. $\approx 940$ globally) that sensitivity rebounds and surpasses the baseline.
- Backbones dictate the metric: Across all experiments, DINOv2 consistently wins on image-level detection (AUROC), while DINOv3 wins on pixel-level precision (AUPR)—regardless of whether you use one subspace or 128.
Key Results
Across 1, 2, and 4 shots, LocalSubspaceAD achieves state-of-the-art results among compared methods on every dataset and metric:
- Over single-subspace (SubspaceAD): Gains +1.2 to +1.8 points in image AUROC on DINOv2 (reaching 98.58% on MVTec AD and 96.21% on VisA at 4-shot), and +1.4 to +4.4 points across image AUROC, pixel AUPR, and AUPRO on DINOv3.
- Where it shines: Grouping VisA categories reveals that gains are driven by complex, heterogeneous items: +2.78 I-AUROC / +5.86 P-AUPR on PCBs, and +1.98 I-AUROC / +8.43 P-AUPR on multi-instance objects.
- Overhead: Scoring against 128 subspaces adds only ~120 MFLOPs per patch—just a 5–10% compute bump on top of the DINOv2 backbone.
Limitations and Future Work
- Overkill for simple objects: On homogeneous, single-instance VisA categories where a single subspace already hits 97.60% I-AUROC, splitting patches into 128 clusters slightly hurts image-level detection (-0.69 points).
- Linear scaling: Inference cost scales linearly with $K$ since every patch is checked against every subspace.
- Future directions: The authors suggest speeding up inference by scoring test patches only against their nearest cluster components, scaling up to full-shot datasets, and leveraging subspace locality to catch logical anomalies (e.g., a perfectly normal microchip soldered into the wrong spot).
Summary updated