PaDiM
PaDiM models every patch position as its own normal bell curve and flags test patches that land far in the tails of their home position curve.
Why Does This Exist?
One global normal model blurs where things belong: a screw patch and a plate patch share one cloud and both look odd. Factory parts sit fixtured, so position carries meaning. A dark thread belongs at the hole, never on the rim.
PaDiM exists to keep that place knowledge. Input is normal only images at fixed pose. Output is a per position anomaly map. The line setting is industrial vision; the supervised alternative is defect detection. The memory bank sibling is PatchCore.
Use it when pose is fixed and normal patches cluster per position. Use place free memory when parts shift or rotate freely.
Think of It Like This
A seating chart for textures
A teacher knows each desk: Maya sits front left, Jonas back right. An unfamiliar face at Maya desk is news. The same face in the hallway means nothing.
PaDiM keeps one seating chart per patch position with a mean face and allowed wobble. Mahalanobis distance is the surprise at seeing the wrong sitter at a known desk. The analogy stops at shape: real patch clouds stretch diagonally, so plain Euclidean surprise misranks what Mahalanobis gets right.
How It Actually Works
Extract patch embeddings from normal images and group by spatial position. Fit a multivariate Gaussian per position with mean and covariance from the normal samples. Score a test patch by Mahalanobis distance , which counts standard deviations along the cloud shape. Upsample to pixels for the heatmap and max pool for the image score.
Worked example
A rim position holds normal embeddings in dims with mean and tight spread. A clean test patch lands deviations out. A scratch patch with a bright streak lands deviations out because the streak direction is rare at that desk. A cut at passes the clean patch and flags the scratch. The map peak sits on the streak pixels while the field stays cool.
Watch Out For
Pose jitter that moves desks
A pixel shift puts rim texture onto plate statistics. Every edge scores plus deviations. The symptom is glowing outlines on good parts. Fix it with rigid fixturing and by verifying alignment on edges before fitting Gaussians.
Gaussian faith on multimodal normal
A position that alternates between two legal finishes forms two clouds, not one bell. One Gaussian centers between them and flags both finishes. The symptom is chronic false alarms on one variant. Fix it with more components or a memory method that keeps both modes.
The Quick Version
- PaDiM fits one Gaussian per patch position from normal images only.
- Score is Mahalanobis distance in shape aware standard deviations.
- The fixture flags deviations against clean at a cut.
- Position awareness sharpens maps when pose stays fixed.
- Misalignment or two mode normal breaks the single bell assumption.