Original paperSourceNo author review
Make your paper interactiveCreate

Text from the interactive explanation

INP-Former++: Advancing Universal Anomaly Detection via Intrinsic Normal Prototypes and Residual Learning

Wei Luo, Haiming Yao, Yunkang Cao, Qiyu Chen, Ang Gao, Weiming Shen, Wenyong Yu

An interactive guide to INP-Former++

Could one inspector catch flaws in any product, even one it has never been shown? This approach looks for the answer inside the very picture it is checking.

On the bench: a hazelnut

Anomaly score –

Patch grid: the picture cut into 28 × 28 = 784 small pieces.

Six orbs: normal prototypes distilled from this item alone; each fills with the average colour of the patches it gathers.

Scan bar: rebuilds every patch using only those six prototypes.

Heat: whatever could not be rebuilt. That is the flaw.

Simplified illustration Live, simplified illustration of the paper’s idea: toy colour-and-texture features stand in for the paper’s pretrained vision transformer.

Factories photograph every hazelnut, cable and bottle that leaves the line; hospitals scan patients. Anomaly detection is the job of spotting what is wrong in those pictures, and pointing to where, after learning mostly from examples in which nothing is wrong. Flaws are rare and endlessly varied, so nobody can collect them all.

The paper behind this page, INP-Former++ by Wei Luo and colleagues, aims at universal anomaly detection: one approach that keeps working whether there are many normal examples, only four, many products mixed together, a handful of real defects, or, to a degree, none at all. Its starting point is something you already do without thinking. Let’s begin there.

01

Spot the odd one out

Thirty-six tiles cut from one surface. One of them is flawed. Nobody will show you a perfect example first.

Round 1 of 3 · leather

Tap the one tile that looks wrong.

How did you know?

Nobody gave you a catalogue of flawless tiles. The other thirty-five showed you what normal looks like here: this material, this angle, this light.

That is the observation at the heart of the paper. Most defects are local , so even a defective image is mostly normal, and that normal part is perfectly matched to the defect: same object, same pose, same lighting.

02

The trouble with a memory of normal

Most automatic inspectors work from memory. During training they store snippets of normal images; later they compare every patch of a new image with its closest stored snippet and flag anything without a good match. Researchers call such stored summaries of normal appearance prototypes .

That works as long as new images look like the stored ones. Change the conditions and see.

Reference shelf (training images)

Three flawless hazelnuts, one pose, warm light.

Test item, with anomaly heat

Dashed ring: where the real defect is.

0% of the item’s normal patches wrongly flagged

Defect caught

Predict first: if the light changes, will the stored-reference inspector raise more false alarms, fewer, or about the same?

Turned or relit: false alarms

A hazelnut turned another way, or lit by a cooler lamp, is still a perfectly good hazelnut. But its patches no longer resemble the stored snippets, so healthy shell gets flagged. The paper calls this misalignment caused by intra-class variation : the same product can simply look different.

Many products at once: missed defects

When one inspector serves several products, normal snippets of one product can resemble a defect on another. A brown stain on a cable looks like ordinary hazelnut shell, so it finds a “match” and slips through. This is multi-class confusion .

The fix: ask the image itself

Prototypes taken from the test image itself avoid both problems. They always share its pose, its light and its product. The paper calls them Intrinsic Normal Prototypes , or INPs.

Simplified illustration Both inspectors here use the same toy colour-and-texture features; the stored-reference one mimics a nearest-neighbour memory bank.

03

Six prototypes from one picture

INP-Former++ first cuts the picture into a 28 × 28 grid: 784 patches. A pretrained vision network turns each patch into a list of numbers, called a token , that describes what the patch looks like.

Then six learned queries sweep across all 784 tokens. Each query gathers a weighted blend of the patches it finds most relevant, and that blend becomes one prototype. Because flaws are small, they barely contribute to the blends; during training, a rule (more on it in section 05) teaches the queries to cover normal patches.

The prototypes (tap one)

Average rebuild error on normal patches: –

–

The authors tried 1, 4, 6, 8, 12 and 200 prototypes. Image-level results level off once there are more than four; pixel-level results keep improving with more. They chose six as the balance between accuracy and computing cost. Their visualisations show different prototypes attending to object regions, object outlines and background, much like the toy here.

04

Rebuild only what is normal

Now the trick. The system rebuilds the picture’s tokens using only the six prototypes as ingredients. Ordinary patches can be rebuilt, because they resemble the prototypes. A flaw cannot: there is no scratch among the ingredients. Wherever the rebuild fails, the difference lights up.

Image score –

In the paper, the rebuilding is done by an eight-layer INP-guided decoder working on the network’s deep tokens, and it may consult only the six prototypes. The authors also removed one internal shortcut connection that would have let the flaw’s own features flow straight through to the output. To turn the map into a single verdict, they average the hottest 1% of it, exactly what the score above does (the hottest 8 of 784 patches).

Simplified illustration The rebuilt picture shows each patch painted with the blended average colours of the prototypes it was rebuilt from.

05

The shortcut trap

How do the queries learn to pick good prototypes? During training, a rule, known as a loss , rewards them when every normal patch lies close to some prototype. The conference version of this work used the simplest rule: each patch should be close to its nearest prototype. The authors then found a loophole.

Reported in the paper Bar heights: patch counts reported in the paper (Fig. 4). Illustration Coloured grid: illustration.

Under the old rule (the INP coherence loss), the extractor can satisfy the rule lazily: make one prototype sit close enough to everything, and every patch picks it. INP-Former++ replaces it with a soft rule (the soft INP coherence loss): each patch is rebuilt as a weighted blend of all six prototypes, with more weight on the more similar ones, and the blend has to match the original patch. Now spreading out pays off.

In the test on products the model had never seen, region coverage (AUPRO) rose from 77.3 with the old rule to 79.6 with the soft one.

06

Practice on fake flaws: the “++”

A system trained only on normal images has never seen a flaw. Its difference maps carry faint background speckle, and real flaws come out blurry. The second upgrade in INP-Former++ is residual learning : practise on flaws you made yourself.

Step 1 · Make a fake flaw

Following an established recipe (DRAEM), the paper cuts random blob shapes with Perlin noise and fills them with textures from a texture library. Because the system made the flaw, it knows its exact outline.

Step 2 · Train the sharpener

A small segmentation head learns to read the residual, the difference between the original and rebuilt tokens, and to answer “flaw here” or “not here”. It trains on twenty practice flaws with an overlap (Dice) loss.

Step 3 · A real-looking flaw, before and after

One safeguard: the stop-gradient

The fake flaws should teach only the sharpener. If they were also allowed to adjust the rebuilder, it would learn that flaw-like patterns are things worth reproducing, and real flaws would start to survive the rebuild. The paper blocks that path with a stop-gradient .

Pixel precision (P-AP) on MVTec-AD Reported in the paper

Because practice flaws are already part of training, real ones can join them. With just ten real defect images per product (the semi-supervised setting), the paper reports region coverage (AUPRO) of 96.8 on MVTec-AD.

Simplified illustration The sharpener here is a tiny logistic model trained in your browser on toy residuals; the paper’s head is a small convolutional network on deep features.

07

Why six is cheap

Many modern vision networks use self-attention : every patch compares itself with every other patch, so the work grows with the square of the number of patches. INP-guided attention lets each patch consult just six prototypes instead.

The lines show a random sample of the comparisons; the counts are exact.

For one attention map in the decoder, the paper counts about 943 million multiply-add operations with full self-attention and about 7.2 million with INP-guided attention, reducing both computation and memory by nearly 99.2% .

08

What the experiments showed

The authors tested INP-Former++ on standard benchmarks of photographed products and of medical scans, in six different situations, against the strongest earlier methods. Every number in this section is a measured result reported in the paper.

09

Back to the question

Could one inspector catch flaws in any product, even one it has never been shown? Invent a product nobody has seen, then draw a flaw on it. There are no reference images and no examples of this item: only its own six prototypes.

Simplified illustration The same toy pipeline as above, with nothing to compare against except the item itself.

One approach, more and more examples

The paper’s own answer to the universal question is a ladder. Below is the overall score (mAD) of INP-Former++ on each benchmark as more information becomes available: no examples of the product at all (trained on a different dataset), four normal images, many normal images, and many normal images plus ten real defects per product.

Reported in the paper mAD values from the paper’s scalability analysis (Fig. 11).

Performance climbs as examples are added, and it starts from something even at zero. It is not universal yet: on products it has never seen, detectors guided by language still sort defective from normal images better, and the authors’ next step is to add language prompts. But the direction is clear. A compact inspector could serve many products on one factory line, and medical scans too, by asking each image what normal looks like.

So: can one inspector catch flaws in a product it has never been shown? Increasingly, yes, as long as it is willing to ask the image itself.

Source and credits

Wei Luo, Haiming Yao, Yunkang Cao, Qiyu Chen, Ang Gao, Weiming Shen and Wenyong Yu. “INP-Former++: Advancing Universal Anomaly Detection via Intrinsic Normal Prototypes and Residual Learning.” arXiv preprint arXiv:2506.03660v2 [cs.CV], 2025. https://arxiv.org/abs/2506.03660v2

It extends the authors’ conference paper “Exploring intrinsic normal prototypes within a single image for universal anomaly detection” (CVPR 2025), called INP-Former in the paper. Benchmarks used in the paper: MVTec-AD, VisA, Real-IAD and Uni-Medical.

All visuals are original illustrations drawn in code. The interactive inspectors are simplified models of the paper’s principle (toy colour/texture features, no trained network); benchmark numbers are as reported in the paper.

Typefaces: Fraunces, Inter and IBM Plex Mono, used under the SIL Open Font License.

Topics in this iPaper

Computer science
we propose INP-Former, a novel method that extracts Intrinsic Normal Prototypes (INPs) directly from the test image

Abstract, page 1

Engineering
Anomaly detection (AD) is essential for industrial inspection and medical diagnosis

Abstract, page 1

anomaly detection
Unsupervised image anomaly detection (AD) [1], [2], [3] seeks to identify abnormal patterns in images and localize anomalous regions

Section 1 Introduction, page 1

industrial defect detection
This technique has seen widespread application in industrial defect detection [4], [5] and medical disease screening [6]

Section 1 Introduction, page 1

vision transformer
INP-Former++ adopts ViT-Base/14 with DINO2-R [47] weights as the default pre-trained encoder

Section 4.1.3 Implementation Details, page 7

prototype learning
In contrast, our INPs are dynamically extracted from the test image, providing more aligned alternatives for normality representation

Section 2.2 Prototype Learning, page 4

feature reconstruction
Following RD4AD [28] and Dinomaly [12], we adopt a feature reconstruction framework

Section 3.1 Overview, page 4

few shot learning
As shown in Tab. 5, INP-Former++ substantially outperforms existing methods specifically designed for few-shot anomaly detection

Section 4.2.3 Few-Shot Anomaly Detection, page 8

semi supervised learning
we conduct performance comparison experiments under a semi-supervised setting, where each category includes 10 anomalous samples

Section 4.2.5 Semi-Supervised Anomaly Detection, page 9