Exploring Intrinsic Normal Prototypes within a Single Image for Universal Anomaly Detection

Wei Luo, Yunkang Cao, Haiming Yao, Xiaotian Zhang, Jianan Lou, Yuqi Cheng, Weiming Shen, Wenyong Yu

Abstract

Unsupervised Anomaly Detection (AD) typically relies on comparing test samples to a library of "normal" training data. However, variations in pose, lighting, and scale often lead to false positives due to misalignment. We propose INP-Former, a framework that extracts Intrinsic Normal Prototypes (INPs) directly from the test image. By leveraging the fact that even anomalous images are predominantly composed of normal regions, INP-Former creates a perfectly aligned reference on-the-fly. Our method demonstrates superior performance across MVTec-AD, VisA, and Real-IAD benchmarks, particularly in multi-class and few-shot scenarios.

Introduction

The primary challenge in Unsupervised Anomaly Detection is identifying subtle defects without prior exposure to specific anomalies. Traditional prototype-based methods store features from a training set to define "normality." However, these methods frequently struggle with intra-class normal variation (e.g., orientation changes) and inter-class confusion in multi-class settings. When a test image's viewpoint differs from the training data, the model may incorrectly flag the discrepancy as an anomaly.

Comparison between existing prototype-based methods and the proposed INP approach, highlighting how INPs eliminate misalignment issues.

Methodology: The INP-Former Framework

INP-Former addresses the alignment problem by extracting reference prototypes from the test image itself. The architecture is built upon Vision Transformers (ViTs) and comprises four key components:

1. INP Extractor

Instead of a massive external memory bank, the INP Extractor uses a small set of learnable tokens (typically 6) to aggregate normal information from the test image via cross-attention. These tokens become the Intrinsic Normal Prototypes (INPs), capturing the specific lighting, scale, and texture of the current sample.

2. INP Coherence Loss ($L_c$)

To ensure that the extracted prototypes represent the underlying normal distribution rather than capturing anomalous noise, the $L_c$ loss constrains the INPs to remain close to the actual feature distribution of the image.

3. INP-Guided Decoder

The decoder is designed for reconstruction. It attempts to rebuild the original image tokens using only the extracted INPs as a guide. Since INPs represent the "normal" essence, the decoder successfully reconstructs normal regions but fails on anomalies, producing a high reconstruction error that serves as the anomaly score.

4. Soft Mining Loss ($L_{sm}$)

This loss function prioritizes "hard" normal regions during training, preventing the model from over-focusing on easily reconstructed areas like uniform backgrounds.

Detailed architecture of the INP-Former, highlighting the INP Extractor, the INP-Guided Attention mechanism, and the reconstruction pipeline.

Experimental Results

INP-Former was evaluated on three major benchmarks: MVTec-AD, VisA, and Real-IAD.

  • Multi-Class Performance: On the Real-IAD dataset, INP-Former improved the state-of-the-art by 1.2% in Image-AUROC and 4.7% in Pixel-Average Precision (AP).
  • Few-Shot Learning: In 4-shot scenarios, the model outperformed specialized few-shot methods like WinCLIP and PromptAD across all datasets.
  • Efficiency: The INP-Guided Attention mechanism reduces computational complexity from $O(N^2)$ to $O(NMC)$, where $M$ (number of INPs) is much smaller than $N$ (number of patches). This makes the model significantly more memory-efficient than standard Transformers.

Conclusion

INP-Former introduces a paradigm shift by looking inward for normality. By extracting intrinsic prototypes, the model achieves superior alignment and robustness across diverse tasks. While the current model may struggle with logical anomalies (e.g., a correctly shaped component in the wrong location), future work aims to integrate these intrinsic references with global semantic knowledge to create a truly universal anomaly detection system.

Summary updated

BibTeX
@inproceedings{luo2025exploring,
  author = {Wei Luo and Yunkang Cao and Haiming Yao and Xiaotian Zhang and Jianan Lou and Yuqi Cheng and Weiming Shen and Wenyong Yu},
  title = {{Exploring Intrinsic Normal Prototypes within a Single Image for Universal Anomaly Detection}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00932},
}
Figure