Welcome to Kunshan EEK Automation Equipment Co., Ltd.
Home/Technical Guides/How many defect samples are enough? The sample threshold for deep learning inspection

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"

The Short Answer

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

Relationship between field of view, working distance and focal lengthExplains that working distance and focal length together determine the field of view (FOV) size, which in turn affects per-pixel sampling capability.Camera + LensField of view FOV: H × V (depends on focal length and working distance)Working Distance WDLonger focal lengthSmaller field of viewSingle-pixel SamplingHigher capabilityPixel sampling value ≠ inspection accuracy: the lens / light source / workpiece / mounting distance / mechanical stability / algorithm together determine the final result
FOV / working distance / focal length relationship diagram — increasing the focal length narrows the field of view and raises the pixel sampling capability per unit area; but the pixel sampling value cannot be taken directly as 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.

ScenariosSample StrategyDescription
The defect form is uniform and obviousA small number of samples is enough to startBut must still cover the variety of conforming parts
Diverse defect morphologiesCollect by morphology categoryEach form needs representative samples
Rare defects (seldom occur)Supplemented by few-shot generation or synthesisThe actual effectiveness of synthetic samples must be validated
Very strict judgement criteriaExpand the sample set + conservative thresholdsAccept a certain over-rejection rate in exchange for low escapes

Light Source and illumination

Three illumination methods illustrated: front, side and backlightThree common industrial vision illumination methods and their applicable scenarios.Front LightingcameraContour and surface details, best versatilityWorkpiece (Illustrative)Side LightingcameraEmphasizes bumps, scratches and edges while suppressing reflectionsWorkpiece (Illustrative)BacklightingcameraProduces a clear contour, suitable for presence/absence and dimensionsWorkpiece (Illustrative)The equipment comes standard with a white light source, with infrared light and polarizing filters available as options; the actual illumination method must be determined together with the workpiece material and reflection characteristics
Three Common Illumination Methods — The same workpiece shows very different visual features under different illumination methods; reflective metal parts, black parts, and transparent parts usually require tailored 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?
There is no fixed number. [To be added] The deciding factor is the diversity of defect morphology and how strict the judgement is, not the total count. It is recommended to provide a batch of representative samples for a feasibility validation first, and then assess how many more are needed based on the validation results.
What If There Are Only a Few Defect Samples?
There are several paths: use anomaly detection to learn only normal samples; use transfer learning to reduce sample requirements; or use few-shot generation to supplement scarce morphologies. These methods can mitigate the problem but cannot eliminate it—if a defect morphology has no samples at all, there is no basis for detecting it.
Do I also need to provide good-part samples?
Very important. The model needs to know "what normal looks like". Insufficient conforming samples keep the over-rejection rate high, and the normal variation between batches must be covered.
Can Samples Be Photographed with a Phone?
Not recommended. The imaging conditions of the samples must match those on site, otherwise the features the model learns do not hold on site. If an industrial camera with a specific light source is used on site, the samples should also be acquired under the same conditions.
How Detailed Does the Annotation Need to Be?
It depends on the inspection target. If only presence/absence is judged, labeling the category is enough; if the defect position and size have to be output, bounding boxes or pixel-level segmentation are needed. The latter costs much more, so whether it is required should be determined early in the project.
Will my samples be leaked?
This falls within the scope of commercial and confidentiality terms; it is recommended to agree explicitly on the scope of use, storage method, and ownership of samples and data before cooperating. The technical solution itself can have its data management designed around your confidentiality requirements.

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.

JPG / PNG supported, multiple files allowed
Each file must not exceed 20 MB
    JPG / PNG supported, multiple files allowed
    Each file must not exceed 20 MB
      JPG / PNG supported, multiple files allowed
      Each file must not exceed 20 MB
        A solution engineer will contact you within 1 business day after submission

        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.

        Online support WhatsApp
        WeChat
        Scan the QR code to add us on WeChat
        Call us Back to top