Defect Detection
Defect detection spots scratches, dents, and missing pieces on products by learning what good looks like and flagging pixels that break the pattern.
Why Does This Exist?
Good parts outnumber bad ones a thousand to one, and defects hide as hairline scratches under glare. Human inspectors tire by hour three and disagree by shift. Shipping one cracked seal can recall a batch.
Defect detection exists to find rare flaws at line speed. Input is a lit product image. Output is defect boxes or masks plus a pass or fail call. The line umbrella is industrial vision; the box skill is object detection and the whole image call is image classification.
Use it when good appearance is stable enough to learn. Use manual sampling when defects are undefined or good varies more than bad.
Think of It Like This
Proofreading a printed page you know by heart
You know one paragraph so well that a missing comma jumps out without reading every word. You circle the line, not the whole page, and you forgive paper flecks you have seen a hundred times.
Good appearance is the memorized paragraph. The defect mask is the circled line. The analogy stops at novelty: a proofreader spots a brand new typo class at once, while a model trained only on old scratches can miss a new crack shape entirely.
How It Actually Works
Collect good parts until lighting and pose variation are covered, then add every defect type you can stage. Label tight boxes or masks, because loose boxes teach the model to include good metal. Train with heavy imbalance handling: oversample defect crops, weight the loss, and validate on line prevalence, not balanced splits. Contract is image in, boxes plus score out, with a threshold set on false reject cost. A part run with true defects where the model flags regions ( right, wrong) gives precision and recall .
Worked example
A seal line inspects caps with cracked seals. The model flags caps. Six flags cover real cracks, two flag glare streaks. Precision means one in four stops is a false alarm. Recall means no bad cap ships. Accuracy is either way, which hides the two false stops that the plant actually feels.
Watch Out For
Balanced validation that hides line pain
A fifty fifty test set makes precision look easy. On the line at defects per , the same model fires mostly false alarms. The symptom is great lab charts plus angry operators. Fix it by validating at true prevalence and reporting precision at the shipped threshold.
Loose boxes that teach good as bad
A box twice the scratch size labels clean metal as defect. The model learns glare and brush marks as flaws. The symptom is rejects clustering on shiny zones. Fix it with tight masks, exclusion zones for known glare, and box audits before training.
The Quick Version
- Defect detection learns stable good appearance and flags breaks in it.
- Contract is image in, defect boxes plus score out, thresholded by cost.
- The fixture gives precision with recall on defects in .
- Validate at line prevalence, never on balanced splits.
- Tight labels and glare control matter more than a larger backbone.