Foundation Visual Encoders Are Secretly Few-Shot Anomaly Detectors

Guangyao Zhai, Yue Zhou, Xinyan Deng, Lars Heckler-Kram, Nassir Navab, Benjamin Busam

Introduction

Industrial safety inspection relies heavily on detecting anomalies—such as scratches, missing components, or stains—on manufactured goods. In real-world manufacturing, "normal" data is plentiful, but "anomalous" data is rare and unpredictable. This imbalance makes Few-Shot Anomaly Detection (FSAD) highly desirable. FSAD aims to learn to spot defects from just one or a few clean examples, but it remains technically difficult.

Existing methods often rely on complex ensembles, massive Vision-Language Models (VLMs) that require manual text prompting, or heavy reconstruction-based architectures. These approaches can be computationally expensive and struggle with "category-agnostic" settings, where a single model must simultaneously handle many different types of objects (e.g., bottles, cables, and transistors).

To address these inefficiencies, researchers introduce FOUNDAD (Foundation Anomaly Detector). FOUNDAD reveals that large-scale foundation visual encoders "secretly" encode the distance to a natural image manifold. By training a lightweight, non-linear projector to map features back onto this manifold, the authors achieve state-of-the-art few-shot anomaly detection performance with a fraction of the parameters used by existing heavyweights.

Methods: Projecting onto the Natural Image Manifold

The core hypothesis behind FOUNDAD is that foundation models (like DINOv3 or SigLIP) have already learned a "natural image manifold" during their massive pre-training phases. Normal images sit neatly on this manifold, while anomalies fall off it.

Conceptual overview of FOUNDAD, illustrating how anomalous features are projected back onto a pre-trained natural image manifold to detect defects.

The FOUNDAD architecture consists of four primary components:

  1. A Frozen Foundation Encoder: The system utilizes a pre-trained visual encoder (DINOv3 ViT-B performed best in testing). The encoder is kept frozen to preserve its general "knowledge" of natural images without catastrophic forgetting.
  2. Anomaly Synthesis: Because real defect data is scarce, the system trains using a modified "CutPaste" strategy. Patches of a normal image are shifted or altered to create synthetic anomalies.
  3. The Manifold Projector: This is the core innovation—a lightweight, 6-layer Vision Transformer (ViT). During training, it learns to take an anomalous feature and project it back toward its "normal" counterpart on the manifold.
  4. Inference via Distance: To find a defect during inference, the model compares the original feature embedding with its projected version. A large L2 distance between the two indicates an anomaly. This distance is then upsampled to create a precise spatial "heatmap" of the defect.

Key Insights and Discoveries

FOUNDAD's development yielded several fascinating insights into how foundation models process visual information:

  • The "Secret" Correlation: The authors discovered a clear, linear-like correlation between the area of an anomaly (in pixels) and the L2 distance in the foundation model's embedding space. The more "wrong" an image is, the further it drifts from the manifold.
The correlation between synthetic anomaly area and L2 feature distance in foundation models like DINOv2 and SigLIP.
  • Geometry over Reconstruction: Unlike traditional methods that attempt to reconstruct raw pixels (which is computationally heavy and prone to blurring), FOUNDAD operates entirely in the latent feature space. It treats anomaly detection purely as a geometric projection problem.
  • Text is Not All You Need: Many recent state-of-the-art methods use text prompts (e.g., "an image of a scratched bottle") to guide detection. FOUNDAD proves that pure visual features from foundation models are powerful enough to beat these prompt-based methods without any linguistic input.
  • Layer 10 is the Sweet Spot: In an ablation study of DINOv3, the authors found that middle-to-late layers (specifically Layer 10) provide the optimal balance between high-level semantic understanding and the spatial precision required for accurate defect localization.

Performance and Efficiency

The authors evaluated FOUNDAD on several standard industrial benchmarks, including MVTec-AD (15 categories of objects/textures), VisA (12 categories with complex structures), BTAD, and DTD.

FOUNDAD sets new benchmarks for efficiency and accuracy in the challenging "multi-class-one-model" setting:

  • Superior Accuracy: In 1-shot settings, it achieved 96.1% I-AUROC on MVTec-AD and 92.6% on VisA, outperforming much larger models like IIPAD and LogSAD.
  • Pixel-Perfect Localization: It achieved a near-perfect 99.7% Pixel-AUROC on the VisA dataset.
  • Extreme Efficiency: FOUNDAD uses only 97.8M parameters—roughly 10x to 13x fewer than competitors like IIPAD (1.0B) or LogSAD (1.3B).
  • Speed: It processes images at approximately 128ms per image (~7.8 FPS) on a single RTX 3090, making it highly viable for real-time industrial deployment.

Limitations and Future Work

Despite its impressive efficiency and accuracy, FOUNDAD has a few limitations. Because the model is trained on limited "normal" samples, it exhibits orientation sensitivity; it can fail if a test object is oriented differently than the training sample (e.g., a screw rotated 90 degrees). Additionally, appearance extremes like severe lighting changes or overexposure can push features too far from the learned manifold, leading to false positives.

Finally, due to its non-generative nature, the projector maps features rather than generating pixels. It lacks a strong "prior" on specific defect morphologies, which can occasionally lead to less precise segmentation masks for highly complex defect shapes. Future work will likely explore more diverse anomaly synthesis strategies to help the model generalize better to unseen orientations and lighting conditions.

Summary updated

BibTeX
@inproceedings{zhai2026foundation,
  author = {Guangyao Zhai and Yue Zhou and Xinyan Deng and Lars Heckler-Kram and Nassir Navab and Benjamin Busam},
  title = {{Foundation Visual Encoders Are Secretly Few-Shot Anomaly Detectors}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=YRrlJ8oVEH},
}
Figure