
Defective samples are hard to find on a production line. How anomaly detection and active learning work with good samples only.
The biggest obstacle in computer vision projects is data. Defective products are rare on a production line; that is good news for the factory but bad news for training a model. Instead of waiting months to collect thousands of defective samples, two approaches can be combined.
Anomaly detection: with good samples only
In this approach the model learns the visual distribution of the ‘good’ product. If a new image does not fit this distribution it is flagged as an anomaly. Defect types never seen before are also caught. 200–500 good images are often enough.
Pretrained foundation models
General visual representations are learned beforehand from millions of images. Ilmek Vision uses these representations and does only the line-specific fine-tuning. This cuts training time from weeks to hours.
Active learning: using the expert’s time efficiently
The model asks the expert about images it is unsure of. Instead of labelling thousands of random images, the expert labels only the most informative 100–200. After each round the model improves and needs to ask less.
Synthetic data and augmentation
For rare defect types, adding synthetic defects (scratch, stain, crack texture) and lighting/angle variation makes the model robust. But synthetic data complements rather than replaces real data; final evaluation must always use real samples.
Field realities
- Lighting consistency matters more than the model: set up controlled, repeatable lighting.
- Camera resolution should be chosen so the smallest defect covers at least 3–5 pixels.
- Run in shadow mode: for two weeks the model is compared with the operator without deciding.
- Threshold setting: the balance between the cost of false rejects (lost product) and missed defects (customer returns) is set with the business unit.
In our pilots, with this approach we collect a week of data at the line for a new product and validate in shadow mode on the live line within two weeks.
Success criteria
Visual inspection has two kinds of error with different costs: false rejects (a good product is removed) and missed defects (a defective product reaches the customer). At the start of the pilot set targets for both rates; for example missed-defect rate below 1% and false-reject rate below 3%. Threshold tuning balances the two and is set according to a cost calculation with the business unit.
Also monitor model drift over time: raw material, machine wear and lighting changes can alter performance. Monthly revalidation reduces this risk.
Related Posts
How to Measure ROI in AI Projects: A Framework from Pilot to Production
Baseline, control group and hidden costs: how to measure the true return on AI investments.
