AI Adoption GuideManufacturingInspect
Inline Vision-Based Defect Detection
CNN models inspect 100 percent of output at line speed, detect surface defects below 0.3 mm, and automatically reject units without human involvement.
Manufacturing processPlanSourceMakeInspectPackShipServiceReturn
By Don, DoneThat’s AI coach · updated
What this use case delivers
Inline vision-based defect detection puts a trained CNN (or equivalent deep vision model) on the production line so every unit is scored for surface and appearance defects before it leaves the station. The model runs at line speed: frames are captured, classified or segmented, and a pass/fail or grade decision is returned in time for the reject actuator or PLC handshake.
Typical surface classes include scratches, dents, discoloration, missing material, foreign particles, flash, and incomplete finish. The system can drive auto-reject for high-confidence fail calls. Ambiguous scores stay in a hold or rework path so a quality technician can override or confirm. That human-in-the-loop gate is part of the control plan, not an afterthought.
Common commercial platforms in this space include Cognex, Keyence, and Instrumental. Build-vs-buy usually turns on cycle time, lighting control, model lifecycle tooling, and how tightly you need PLC and MES integration. Do not treat vendor marketing claims about minimum defect size as proven on your product until you validate on your own golden set and line conditions.
When it is worth deploying
Use inline vision when defects are visible in a controlled image, escape cost is high, and sampling alone leaves too much risk. High mix or frequent changeovers raise the bar: you need lighting recipes, fixtures, and model versions that track SKU and tooling changes.
It is usually a poor fit when the primary failure mode is internal (not in camera view), when cycle time leaves no budget for capture and inference, or when you cannot keep illumination and camera pose stable. If operators already catch nearly every visible defect and scrap cost is low, start with offline audit cameras or unlabeled anomaly monitoring before committing to full inline reject.
Pair this work with related inspect outcomes when you need coverage beyond labeled surface classes: Unlabeled Anomaly Detection for novel or rare defects without a full taxonomy, First-Pass Yield Prediction when you want upstream signals before final visual fail, and Vision-Based Label and Contents Verification for packaging and identity checks that sit beside cosmetic inspection.
Data, labeling, and model setup
Start from a defect taxonomy that quality already uses on the floor, then map each class to image evidence: region of interest, lighting angle, and severity bands. Collect both good units and known defect examples across shifts, lots, and tooling states. Stratify by SKU, color, finish, and camera station so the train/val split reflects real line variance.
Labeling should be reviewed by process or quality engineers, not only by contractors who have never seen the product. Track inter-rater disagreement on borderline scratches and cosmetic grades; those cases often become the override queue in production. Version every dataset slice with camera serial, lens, exposure, and light recipe IDs so you can explain drift later.
Choose classification when the decision is whole-unit pass/fail or grade. Prefer detection or segmentation when you need defect location for root-cause work or when multiple defect types can appear on one frame. Keep a hold-out golden set that never enters training; use it for gate reviews after every model or lighting change. Thresholds belong in the quality plan: set separate cutoffs for auto-reject, auto-pass, and human review rather than a single brittle boundary.
Line integration and reject policy
The vision node is only useful if reject policy is explicit. Define what happens for clear fail, clear pass, low-confidence, timeout, and system fault. Auto-reject should fire only when confidence and class meet the written criteria and the reject mechanism is confirmed healthy. Ambiguous calls go to hold, quarantine, or manual inspection, never to silent pass.
Empty or hold the lane when camera calibration fails, when lighting intensity or uniformity drifts outside recipe limits, or when the vision service does not answer within the cycle budget. Prefer fail-safe behavior: stop or divert rather than shipping unverified product. Wire heartbeats and recipe-ID checks into the PLC so a mismatched model or light bank cannot run under the wrong SKU program.
Synchronize decisions with station ID, unit serial or barcode, and timestamp in MES or quality records. Retain enough images (or compressed crops) for failed and overridden units to support MRB and customer complaints. Rate-limit image retention for clear passes if storage is constrained, but keep enough to audit false rejects after changeovers.
Validation, monitoring, and change control
Validate on the line, not only in the lab. Measure false reject rate, false accept rate (from audit sampling or seeded defects), override rate, and cycle-time headroom under peak takt. Run a short parallel period where the model scores but does not reject, then enable reject for the highest-confidence classes first.
Monitor live drift: confidence histograms, reject rate by SKU and shift, lighting telemetry, and calibration health. Spike in overrides or sudden drop in confidence often means dirt on the lens, bulb aging, fixture wear, or a process change that altered surface appearance. Treat model updates like process changes: change request, golden-set retest, limited pilot, then full enablement.
Retrain when taxonomy, materials, or cosmetics standards change, or when audit finds systematic misses. Document who owns thresholds, who may override, and how overrides feed the next labeling cycle. Keep vendor firmware and your model artifacts on a controlled bill of materials so a station rebuild can restore a known-good stack.
Common failure modes and how to avoid them
Unstable lighting and glare create the largest share of false rejects. Lock mechanical fixtures, use polarized or structured lighting when finish varies, and alarm on intensity drift instead of waiting for scrap spikes. Dirty optics and loose mounts produce the same symptom: rising low-confidence rates without a real process change.
Overfitting to a narrow golden lot fails at the next color or supplier change. Include hard negatives and near-miss cosmetics in training. Over-aggressive auto-reject without an override path destroys trust; operators will bypass the system. Under-specified reject policy during camera or light faults is worse: units can ship uninspected. Codify empty/hold on calibration and lighting failure before you enable actuators.
Finally, do not publish or design to a specific millimeter defect size as a proven result unless your own MSA and golden-set study support it for that product, camera, and lighting. Capability is product- and setup-specific. Prove it on your line, then lock the recipe and model version that delivered it.
Is this worth automating for you?
Whether this pays back depends on how much time it takes your team today. Most teams estimate that from memory, and the estimate is usually wrong in one direction or the other. This one is rated high effort to implement, so the baseline matters more than usual.
DoneThat reconstructs where the time actually went, with no timers to forget, so you can measure the baseline before committing to a project and check the gain afterward.
Measure the baseline first