TL;DR
Standard few-shot anomaly detection relies exclusively on normal examples to spot defects, completely ignoring historical examples of anomalies you might already have on hand. Simply feeding those known anomalies into a detector, however, causes it to overfit—treating a scratch as the only kind of defect and missing a dent. IDEAL solves this by using both normal and anomalous references to learn the underlying directions of how defects deviate from normality, allowing a single generalist model to cleanly spot both familiar and completely unseen anomalies on the fly.
What Problem Does This Paper Address?
Imagine setting up an automated quality inspector on a factory line. Gathering thousands of defect-free images to train a model is tedious, which led researchers to Few-Shot Anomaly Detection (FSAD)—spotting defects using just a handful of normal reference images at test time.
In the real world, though, you rarely have only normal images. You usually have a few confirmed anomalies lying around in historical logs—a cracked lens, a misprinted circuit, or a flagged tumor scan. Yet conventional FSAD methods throw these away because they are built strictly to match against normality.
The authors formalize discriminative FSAD, where a small number of both normal and abnormal references are available during inference without retraining the model. The catch? Anomalies are wildly diverse. If you use a single reference of a scratched bottle cap as a literal template, your detector will overfit to scratches and miss a missing label, or produce noisy false alarms when textures don't quite line up.
Methods
Instead of asking "Does this test image look like my anomalous reference?", the authors' framework—IDEAL (Intrinsic Deviation Learning)—asks: "In what fundamental ways do anomalies break away from normal patterns?"
Starting with standard patch features extracted from a frozen, pre-trained visual encoder (like CLIP or DINOv2), IDEAL introduces two clever, lightweight modules:
- Normal Variation Eraser (NVE): Not all differences matter. Shifts in lighting, camera angle, or background texture create "nuisance" deviations between a test image and a normal reference. NVE finds the local neighborhood of normal reference patches, runs Principal Component Analysis (PCA) on the fly to find the primary axes of benign, everyday variation, and mathematically projects them out. What remains are denoised deviations.
- Intrinsic Deviation Encoder (IDE): Next, IDEAL uses a cross-attention mechanism with a small set of learnable vectors to distill the denoised abnormal references into intrinsic deviation vectors. Driven by a custom dual loss, these vectors are forced to be mutually orthogonal (capturing distinct, non-redundant modes of failure) and tightly aligned with true abnormal shifts.
At test time, IDEAL takes a query image, erases its nuisance normal variations via NVE, and projects the remaining deviations onto the learned intrinsic deviation vectors. If a large chunk of the deviation survives that projection, you have an anomaly.
Datasets
To prove generalist capability—training once and deploying anywhere without fine-tuning—the authors evaluate across eight real-world datasets spanning industrial manufacturing and medical imaging:
- Industrial: MVTecAD, VisA, AITEX, MPDD, BTAD, KSDD, and MVTec3D.
- Medical: BraTS (brain tumor segmentation).
To prevent data leakage when testing on MVTecAD, the model is pre-trained on VisA, and for all other datasets, it is pre-trained on MVTecAD. No new datasets are introduced, though existing benchmarks are adapted to evaluate both general settings and strict "unseen anomaly" splits (holding out specific defect classes during reference selection).
Key Insights and Ideas
- Anomalies shouldn't be templates; they are compasses: Even if an unseen defect looks nothing like your reference defect at the pixel level, they often share relative deviation directions away from the normal manifold in feature space. Projecting onto orthogonal deviation directions generalizes where similarity matching fails.
- Subtracting "normal noise" is half the battle: Raw feature residuals between normal and abnormal images are surprisingly tangled because benign variations (like glare on metal) can have huge magnitudes. Stripping away local PCA subspaces of normality cleanly separates normal clusters from anomalies before any deep learning even happens.
Key Results
Across all eight datasets and various few-shot combinations (such as 1-normal/1-abnormal N1A1 up to N8A4), IDEAL consistently outperforms state-of-the-art normal-only, abnormal-only, and joint-reference baselines.
- Boost from a single anomaly: Under the
N1A1setting, IDEAL hits 96.3% image-level / 96.8% pixel-level AUROC on MVTecAD and 90.8% / 97.8% on VisA, beating normal-only methods by substantial margins (often 3%–10% gains on harder datasets like MPDD and BraTS). - Generalizing to unseen defects: When tested strictly on anomaly types never seen in the reference set, competing joint-reference methods suffer steep accuracy drops (e.g., NAGL drops up to 13.4% on MPDD), whereas IDEAL experiences minimal degradation (often less than 1% on MVTecAD) because its orthogonal vectors capture broader deviation subspaces.
Limitations and Future Work
Not discussed in the paper. (Note: Only the first two pages of the manuscript text were provided in the document alongside the extracted figures and tables, which did not include the concluding limitations section.)
Summary updated