How many defect samples are enough? The sample threshold for deep learning inspection
How many defect samples does deep learning visual inspection need? This article explains how sample quantity relates to defect morphology complexity and judgement strictness, and the feasible paths and necessary preconditions for small-sample scenarios.
Clarify One Thing First
It is not about having more, but about "covering enough"
There is no fixed number of samples required for deep learning defect inspection: the more varied the defect shapes and the stricter the judgement requirement, the more samples are needed. The key is not the total sample count but the coverage; every defect shape, every batch difference and every allowed normal texture variation must be covered. When samples are insufficient, narrow the inspection scope or explicitly acknowledge the boundary rather than forcing the model into use.
"How many samples are needed" is one of the most frequently asked questions, and also the one most likely to get a perfunctory answer. The honest answer is: there is no fixed number; it depends on the morphology complexity of the defect and the strictness of judgement.
More important than the count is coverage If a defect has 5 different forms and you provide samples of only 1 of them, the other 4 will most likely be missed at inspection — even if you provide 1000 images of that one form.
Another easily overlooked point is Variability of conforming parts The model needs to know "what is normal", and the texture, batch-to-batch color difference and illumination fluctuation range of good parts must all be covered; otherwise normal variation is judged as a defect, causing a large amount of over-rejection.
selection Factors
Defect Morphology Complexity
Single-form defects (such as regular holes) need few samples; variable-form defects (such as scratches and wrinkles) need many.
Defect Severity Range
Cover everything from slight to severe. Providing only extremely obvious defects leads to escapes of borderline defects.
Variety of Conforming Parts
Normal samples from different batches, under different lighting conditions and with different textures must all be covered, otherwise the over-rejection rate is high.
Judgement Strictness
When an extremely low escape rate is required, more complete samples and more conservative thresholds are needed, and the over-rejection rate rises.
Whether Pixel-Level Positioning Is Required
Judging only "whether it exists" requires fewer samples than "where and how big". Pixel-level segmentation has a much higher annotation cost.
Field of View and Pixel Sampling
Do Not Mistake Pixel Scale for Inspection Accuracy
In practice, collecting samples is often more time-consuming than training the model. Many projects start out believing that "the algorithm is the hard part", and only halfway through do they discover that the real bottleneck is "not being able to gather samples with full coverage".
We therefore recommend making sample collection a separate task at the project kickoff stage, specifying which party is responsible, by what criteria samples are collected, and how often a batch is delivered.
| Scenarios | Sample Strategy | Description |
|---|---|---|
| The defect form is uniform and obvious | A small number of samples is enough to start | But must still cover the variety of conforming parts |
| Diverse defect morphologies | Collect by morphology category | Each form needs representative samples |
| Rare defects (seldom occur) | Supplemented by few-shot generation or synthesis | The actual effectiveness of synthetic samples must be validated |
| Very strict judgement criteria | Expand the sample set + conservative thresholds | Accept a certain over-rejection rate in exchange for low escapes |
Light Source and illumination
Sample Imaging Conditions Must Match the Site
If samples are captured under ideal laboratory conditions while site lighting and vibration differ, the model's performance on site will drop noticeably.
Samples Must Cover Real Batch Variation
The color, texture, and reflection of the same material may differ between batches. Training on only one batch can lead to widespread false calls when the batch changes.
Labeling Quality Sets the Ceiling
Inconsistent annotation (the same appearance annotated in some cases but not others) directly limits model performance. Annotation rules must be defined in advance and enforced consistently.
Negative Samples Matter Equally
If only defect samples are provided without enough good samples, the model tends to judge everything as a defect.
algorithm Selection
A small sample set is not completely unworkable, but it has clear preconditions and limits. The reasonable path is to use the small sample set to quickly validate feasibility, then decide from the validation result whether to keep adding samples or to adjust the inspection scope.
Anomaly Detection
Learn only the distribution of normal samples and treat deviations as anomalies.
- Low demand for defect samples
- Requires high coverage of conforming samples
Transfer Learning
Fine-tuning based on a pretrained model reduces the requirement on sample size.
- Can significantly reduce the number of samples required
- Still needs to cover key forms
Data Augmentation
Expand the sample set by rotation, brightness perturbation and similar methods.
- Improve robustness
- Cannot substitute for missing form coverage
Few-Shot Generation
Use generation methods to supplement scarce defect samples.
- Mitigates the rare-defect problem
- The effectiveness of generated samples must be validated by measurement
Communication and interlocking
Sample collection requires cross-departmental collaboration: production provides the physical parts, quality defines the standard, and engineering handles imaging and annotation. Managing this as a project task rather than "collecting whatever comes along" is the key to whether the project can be deployed on schedule.
- 01 Define defect types and quantified criteria
- 02 Agree on who is responsible for sample collection and on the batch plan
- 03 Capture and label according to the standard
- 04 Quickly validate feasibility with the first batch of samples
- 05 Assess gaps based on the results
- 06 Add samples or adjust the inspection scope
- 07 Freeze the model and judgement thresholds
- 08 Run a trial on site and count escapes and over-rejections
Common Question
How Many Samples Are Actually Needed?
What If There Are Only a Few Defect Samples?
Do I also need to provide good-part samples?
Can Samples Be Photographed with a Phone?
How Detailed Does the Annotation Need to Be?
Will my samples be leaked?
Submit sample testing
We recommend running a feasibility validation with a batch of representative samples first, then assessing the sample gap on that basis. Please provide several OK and NG samples and your defect classification criteria.
Submitted successfully
We have received your sample testing request. A solution engineer will contact you within 1 business day via contact you.
Need to assess imaging conditions, defect criteria and cycle time item by item? Go to the Full Requirement Assessment →
The Most Effective Step in Selection: Test Your Own Sample
For the same workpiece, the inspection result differs greatly with different lenses, light sources, mounting distances and algorithm combinations. Sending us samples for measurement is more reliable than extrapolating from a specification table.