Skip to content
AI360Xpert
Beta

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.

A test patch 3.4 standard deviations from its home Gaussian scores far above clean patches near 0.8, so position aware distance finds the flaw
A test patch 3.4 standard deviations from its home Gaussian scores far above clean patches near 0.8, so position aware distance finds the flaw

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 μ\mu and covariance Σ\Sigma from the normal samples. Score a test patch xx by Mahalanobis distance d=(x−μ)TΣ−1(x−μ)d = \sqrt{(x-\mu)^T \Sigma^{-1} (x-\mu)}, which counts standard deviations along the cloud shape. Upsample dd to pixels for the heatmap and max pool for the image score.

Worked example

A rim position holds 5050 normal embeddings in 22 dims with mean [0.2,0.5][0.2, 0.5] and tight spread. A clean test patch lands 0.80.8 deviations out. A scratch patch with a bright streak lands 3.43.4 deviations out because the streak direction is rare at that desk. A cut at 2.02.0 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 55 pixel shift puts rim texture onto plate statistics. Every edge scores 33 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 dd in shape aware standard deviations.
  • The fixture flags 3.43.4 deviations against clean 0.80.8 at a 2.02.0 cut.
  • Position awareness sharpens maps when pose stays fixed.
  • Misalignment or two mode normal breaks the single bell assumption.