Tech Review

Few defect images? How to test anomaly detection on an inspection line

AKT Vision Β·

A tray of good parts and a handful of rejects can support a first trial. The question is whether defects score higher than ordinary variation in good parts. A new finish batch, a rotated part or a dirty fixture can all look unfamiliar to a model.

Illustrative test scores for eight good parts (circles) and four defective parts (diamonds). Rejecting scores at or above 0.60 catches three defects, misses one and rejects one good part. Scores are illustrative units, not probabilities.

Decide what counts as an acceptable part

Start with an inspector’s acceptance criteria. A visible polishing line may be acceptable while a shallow dent is cause for rejection. Keep both examples. A normal-only approach such as PatchCore compares local image features against a collection of features from good training parts. It can flag unfamiliar regions without having seen an example of every defect. A high score still needs to be interpreted against the inspection specification.

Split the trial by physical part and production lot

Build the reference set from confirmed good parts covering the finishes, shifts and positions you expect. Keep all views of one physical part together. Otherwise a near-duplicate frame in the test set can make the trial look easier than production.

Reserve a separate validation set to choose a cutoff against the cost of missed defects and good-part rejects. Freeze the model, crop and cutoff. Then run a held-out lot containing both good parts and independently confirmed defects. Record the score, decision and physical part ID. If several cameras inspect each part, report the final part-level decision.

Read the two errors separately

In the illustrated test, the cutoff gives one miss in four defective parts (25%) and one false reject in eight good parts (12.5%). Lowering it to 0.50 catches the fourth defect but rejects two good parts. That trade-off can be hidden in a single accuracy number. Four defects are enough to illustrate the calculation, far too few to establish a dependable miss rate.

Inspect the difficult cases first. If heatmaps repeatedly highlight the fixture, try a tighter crop and evaluate again on fresh parts. If scratches vanish even in the raw image, revisit illumination before tuning the model. For a useful pilot, run the frozen decision alongside human inspection and log disagreements by lot and defect type.

References

Camera resolution for scratch inspection

Copyright 2026 AKT Vision. All rights reserved.