Two very different machines learned what a good bottle looks like — a classic pattern-matcher (PCA) and a small neural network. Neither ever saw a defect during training. Then 63 defects walked in.
Five bottles drawn at random from the real test set both models were judged on. You'll be timed per image — call each one OK or defect as fast as you can, then see how you compare.
The neural net judges a bottle in 30 ms and catches 98.4% of defects. Here's what you're hunting for:
Large breaka big chunk missing from the rim or body
Small breaka small chip or crack, usually at the rim
Contaminationdebris or residue sitting on the baseYou'll get 5 random bottles from the real test set — some good, some defective. Your timer starts when the first one appears.
Top-down photos of a glass bottle from the MVTec AD benchmark. Three kinds of defect exist — large breaks, small breaks and contamination — but during training the models only ever see good bottles. That's the whole point: on a real production line you have thousands of photos of good parts and almost none of defects.

| split | images | OK | BAD | role |
|---|---|---|---|---|
| train | 125 | 125 | 0 | learn what "normal" is |
| validation | 41 | 41 | 0 | set the alarm level |
| test | 126 | 63 | 63 | final exam, taken once |
Both models use the same split, and each one's alarm level is fixed in advance using only good bottles it hadn't trained on. No defective image ever influences training or the alarm level — the test set is graded exactly once.
Both models work on the same idea: learn to rebuild good bottles, then flag anything they can't rebuild well. A defect is, by definition, something the model has never seen — so its rebuild of a defective photo comes out wrong, and the size of that error is the alarm signal.



Same photos, same final exam. Here's the whole story in one table:
| Neural net | PCA | |
|---|---|---|
| defects caught | 62 / 63 (98.4%) | 60 / 63 (95.2%) |
| good bottles wrongly flagged | 4 / 63 (6.3%) | 6 / 63 (9.5%) |
| breaks caught | 42 / 42 (all) | 41 / 42 |
| what it missed | 1 contamination | 2 contamination + 1 small break |
Both charts use the same axis: each bottle's score divided by that model's alarm level, so the dashed alarm line sits at 1.0 in both. Good bottles pile up left of the line, defective ones right of it. Where a defect curve leaks left of the line, that's a miss; where a good curve leaks right, that's a false alarm.


They're much closer than we expected. The neural net edges it — two more defects caught, two fewer false alarms, and every single break caught — but a well-built PCA gets within a whisker using nothing but classic linear algebra.
The craft matters more than the model class: a plain PCA baseline on the same data caught 51 of 63. The same technique with evened-out lighting, a second alarm dial and sensible settings catches 60 of 63. The gap was never just "deep learning vs PCA" — it was the craft around it.
Neither model just says "defect" — each points at the pixels that set off the alarm. That's what makes the alarms checkable by a human. Flip through the neural net's four outcomes:
The PCA model explains itself the same way — original, rebuild, and where the rebuild missed:

Breaking the worst tile's error down by filter shows the golden diff — the difference from an "average good bottle" template — does most of the work, for every defect type.

PCA's big setting is how many patterns to keep. Keep too few and it can't rebuild even good bottles — false alarms everywhere. Keep too many and it rebuilds defects too — and the alarm goes quiet. Drag the slider to move along the real curve from the notebook:
The first few patterns capture the big shapes, so the curve climbs fast, then flattens as later patterns only add fine detail. The shipped setting of 50 patterns keeps about 88% of the detail in a good-bottle photo; reaching the 95% mark would take about 113. Staying deliberately below that mark is what keeps defects poorly rebuilt — and therefore visible.

Pointed at a fussier product — transistors, whose three metal legs shift slightly from photo to photo — the bottle recipe simply didn't transfer. It took three real attempts before good and defective scores separated. The same score-curve charts tell the story:
Why the third attempt won: PatchCore never rebuilds the image at all. It compares each patch against a memory bank of known-good patches, so ordinary part-to-part variation is recognised instead of punished. The product didn't get worse between attempts — it was just a harder object, and it needed a method built for subtle, local defects.
