FastRef: Fast Prototype Refinement for Few-shot Industrial Anomaly Detection

Yufei Li, Long Tian, Yuyang Dai, Wenchao Chen, Liang Bao, Xiyang LiuCVPR 2026

TL;DR

FastRef introduces an efficient, test-time prototype refinement framework designed to tackle the data-scarcity constraints of few-shot industrial anomaly detection. By iteratively transferring normal characteristics from query images while suppressing anomalies via optimal transport, it significantly boosts the accuracy of existing prototype-based models with negligible computational overhead.

What Problem Does This Paper Address?

Automated surface inspection systems often face a "cold start" problem: when a new product is introduced, it is rarely possible to collect thousands of normal images to train a traditional unsupervised Industrial Anomaly Detection (IAD) model. Few-Shot Industrial Anomaly Detection (FS-IAD) addresses this by generalizing to new products using only a handful of normal "support" images (e.g., 1 to 4 shots).

Standard FS-IAD methods extract features from these few normal images to construct fixed "normal prototypes." However, because these prototypes remain static during testing, they fail to adapt to the specific lighting, pose, or environmental variations of the incoming query image. While some recent methods attempt to refine prototypes on the fly using query image features, they fall into a dangerous trap: in a low-data regime, a model attempting to reconstruct query features can easily accidentally reconstruct the anomalies themselves, leading to false negatives.

Figure 1. The black line represents the processing flow of support- ing images, and the green line represents the processing flow of query images. Left: Traditional prototype-oriented FS-IAD meth- ods. Right: Our proposed FastRef, it refines prototypes with the query features by suppressing anomalies and transferring charac- teristics iteratively. The improved performance can be obtained thanks to the well enhanced prototypes in low data regime.

Methods

To safely incorporate query statistics without leaking defects into the reference model, the authors propose FastRef, a lightweight framework that operates via a nested optimization process during inference. It balances two core mechanics:

  1. Characteristic Transfer: FastRef dynamically adapts the normal prototypes to the query image's specific traits. It achieves this by linearly reconstructing the query features from the prototypes using an optimizable transform matrix ($W$).
  2. Anomaly Suppression: To prevent the transform matrix from mimicking defects, FastRef uses Optimal Transport (OT)—specifically the entropy-regularized Sinkhorn algorithm—to align the distribution of the newly enhanced prototypes with the original normal prototypes. This ensures that the refined prototypes remain strictly representative of normal data.

Crucially, the authors derived a closed-form solution for updating the transform matrix ($W$) at each iteration. This mathematical shortcut eliminates the need for expensive backpropagation during inference, allowing the algorithm to converge in as few as two iterations ($L=2$). FastRef is entirely plug-and-play and was integrated into three state-of-the-art prototype-based methods: PatchCore, WinCLIP, and AnomalyDINO.

The interplay between the transform matrix $W$ and transport probability $T$ to suppress anomalies in defective regions.

Datasets

The framework was evaluated across four widely recognized industrial anomaly detection benchmarks under 1, 2, and 4-shot settings:

  • MVTec AD: The standard benchmark containing various industrial objects and textures.
  • ViSA: A complex dataset featuring multi-object scenes and challenging poses.
  • MPDD: A dataset focused on painted metal parts with significant rotation variations.
  • RealIAD: A large-scale, real-world multi-view dataset.

No new datasets were introduced in this work.

Key Insights and Ideas

  • The Few-Shot Reconstruction Paradox: In conventional, data-abundant IAD, reconstruction-based models naturally struggle to recreate anomalies because they have never seen them. In few-shot settings, however, the limited variety of normal prototypes makes it highly probable that a simple linear combination will inadvertently fit a defect. Explicit anomaly suppression is therefore mandatory, not optional.
  • Disordered Prototypes Matter: Prior test-time adaptation methods (like FastRecon) assume that prototypes follow an ordered, isotropic Gaussian distribution. FastRef treats prototypes as a disordered set compressed via Coreset selection. This preserves structural and spatial relationships much more effectively.
  • Test-Time Adaptation for Free: FastRef demonstrates that you don't need to retrain massive backbones or deploy heavy neural network decoders to achieve strong test-time adaptation. A lightweight matrix operation optimized at the moment of inference can yield substantial performance leaps.

Key Results

FastRef consistently improved both image-level anomaly detection and pixel-level anomaly localization across all backbones and datasets:

  • PatchCore Integration (PatchCore+): Under a 1-shot setting on the ViSA dataset, PatchCore+ boosted image AUROC by +7.3% and pixel AUROC by +1.0% over standard PatchCore. On the RealIAD dataset, it achieved a +5.0% image AUROC improvement.
  • WinCLIP Integration (WinCLIP+): On the rotation-heavy MPDD dataset under 2-shots, WinCLIP+ improved image AUROC by +3.5%.
  • Efficiency: Hyperparameter analysis revealed that the framework achieves its peak performance at just $L=2$ iterations, confirming that the closed-form solution maintains real-time inference speeds suitable for production lines.
Figure 3. From top to bottom are visualizations of anomaly localization on MVTec, ViSA, MPDD, and RealIAD under 4-shots.

Limitations and Future Work

The authors note that the performance gains of FastRef are highly dependent on the strength of the underlying feature extractor. While it provides massive boosts to standard CNN-based models (like PatchCore) or moderately sized vision-language models (like WinCLIP), the relative improvements are noticeably smaller when paired with massive, highly optimized foundation models like AnomalyDINO.

Future directions are not extensively detailed, but the authors suggest that FastRef's lightweight, closed-form architecture makes it an ideal candidate as a foundational building block for scaling up few-shot anomaly detection in more complex, multi-modal inspection environments.

Summary updated

BibTeX
@inproceedings{li2026fastref,
  author = {Yufei Li and Long Tian and Yuyang Dai and Wenchao Chen and Liang Bao and Xiyang Liu},
  title = {{FastRef: Fast Prototype Refinement for Few-shot Industrial Anomaly Detection}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=uWoO75fKKC},
}
Figure