PatchCore
PatchCore remembers normal patches as a compact memory bank and calls a new patch strange when it sits far from every remembered normal patch.
Why Does This Exist?
Factories hold thousands of good images and almost no labeled defects. Supervised detectors starve. Yet good texture repeats: brushed metal, woven cloth, clean solder. A new scratch breaks the repeat in one small patch.
PatchCore exists for that one class setting. Input is normal only images for memory plus a test image. Output is an image score plus a patch heatmap. The line context is industrial vision; the supervised cousin is defect detection. Whole image sorting is image classification.
Use it when normal is plentiful and defects are rare or unseen. Use supervised detection when you own many labeled defect shapes.
Think of It Like This
A fabric shop memory wall
A fabric clerk pins one swatch of every normal cloth on the wall. A customer brings a scrap. The clerk holds it against each pin and measures the worst mismatch in weave and shade.
The memory bank is the pin wall. Coreset sampling keeps one pin per weave family instead of every bolt. The analogy stops at place: the clerk forgives a shifted pattern that PatchCore flags when alignment slips, so fixturing still matters.
How It Actually Works
Extract dense patch features from a pretrained backbone at two scales, then subsample normal patches into a coreset memory that covers the normal manifold. At test time each query patch scores by distance to its nearest memory neighbor: . The image score is the max patch score, and the heatmap is the per patch upsampled to pixels. A query with clean patches at and distance but one scratched patch at gets image score and a hot spot on the scratch.
Worked example
Memory holds three normal edge patterns. A clean test patch lands from its nearest neighbor. A second clean patch lands away. A scratched patch lands away because no normal edge looks like a bright gouge. Max pooling gives image score . A threshold at passes the first two and flags the third, with the heat peak sitting on the scratch pixels.
Watch Out For
Misalignment that reads as novelty
A part shifted by pixels puts a normal edge onto background memory. Distances spike everywhere along the contour. The symptom is heat rings around every edge. Fix it with tight fixturing and by matching memory built at the same pose.
Memory that forgets rare normal
Coreset pruning can drop an uncommon but legal texture like a brushed variant. Its patches then score high forever. The symptom is one good variant always flagged. Fix it by stratifying the coreset across variants and by auditing which memory points serve the most queries.
The Quick Version
- PatchCore stores normal patch features as a compact memory bank.
- Patch score is nearest neighbor distance .
- The fixture flags against clean and at a cut.
- Image score is the max patch score; the heatmap localizes the flaw.
- Fixture parts tightly or edges become false novelties.