Skip to content
INDUSTRY 4.0 AND SMART MANUFACTURING intermediate

AI Visual Inspection Fails at the Lighting Long Before the Model

Classical vision still wins geometric checks. Learned models earn their place on variable and rare defects. Accuracy is set by lighting, fixturing and the false-reject threshold you can afford.

August 1, 2026
10 min read
Francis Okafor
AI Visual Inspection Fails at the Lighting Long Before the Model

An operator on a housing line in Bao'an showed me how she decided. Pick up the part, tilt it about fifteen degrees under the bench light, rotate once, drop it in a bin. Under two seconds. When I asked what she was looking for she used a word I had to check afterwards, 磨花, the fine scuffing that only shows when light rakes across a brushed surface at the right angle. The AI visual inspection cell two metres upstream had passed that same part at 0.97 confidence. It had never seen the defect, because the ring light bolted above the conveyor could not produce that angle.

That is the whole problem in one part. Most of the accuracy in machine vision quality control is decided before a single tensor gets allocated, and almost none of the vendor material is organised around that fact.

Classical machine vision still wins the checks it was built for

Rule-based automated optical inspection gets dismissed too quickly. For a well-defined geometric check it remains the better tool, and by a wide margin.

Put a part on a backlight and a subpixel edge caliper returns a dimension with a stated uncertainty in microns, repeatable across shifts, in a few hundred microseconds, with no training data and no GPU. Presence and absence. Hole count. Pin pitch. Connector seating, fill level, label skew, blob area against a fixed threshold. All solved. They are also auditable, which matters more than engineers like to admit: when a customer challenges a shipped lot you can hand over the algorithm, the tolerance and the calibration record. A convolutional model hands over a number between zero and one plus a heatmap.

The rough test I use. If the accept criterion can be written as an inequality on a measurable quantity, use classical vision. If the criterion is "it looks wrong to a trained person", you are in learned-model territory.

An inspection cell in five stages. The encoder or sensor trigger fires the strobe and the camera together, fixturing fixes part pose, the model scores the image inside the per-view latency budget, a threshold converts a continuous score into a binary verdict and the PLC diverts the part. Accuracy is created at stages one and two, where the defect either does or does not modulate light into the sensor. Stage four is where the money is decided, because the threshold sets the ratio of escapes to false rejects.
An inspection cell in five stages. The encoder or sensor trigger fires the strobe and the camera together, fixturing fixes part pose, the model scores the image inside the per-view latency budget, a threshold converts a continuous score into a binary verdict and the PLC diverts the part. Accuracy is created at stages one and two, where the defect either does or does not modulate light into the sensor. Stage four is where the money is decided, because the threshold sets the ratio of escapes to false rejects.
The threshold belongs to the plant, not to the vendor.

Where learned models actually earn their place

Three conditions. The defect class is visually variable: porosity, weld spatter, contamination, cosmetic scuffing. The good part is itself variable, as with castings, textiles, wood or coated surfaces where legitimate texture swamps any fixed threshold. Or the defect is rare enough that nobody wrote the rule because nobody has characterised it yet.

Options as of August 2026, where the licence matters more than the benchmark table. Ultralytics YOLO26 shipped in January 2026 with an NMS-free one-to-one head and Distribution Focal Loss removed, reporting 40.9 to 57.5 mAP on COCO across the n to x scales at 1.7 to 11.8 ms T4 TensorRT latency. It is AGPL-3.0 by default, and Ultralytics states plainly that the licence covers the weights your training run produces, not only the training code. On a factory inference server that is a conversation with legal rather than a footnote. RF-DETR from Roboflow releases all code and the nano through large detection models under Apache-2.0, with the XL and 2XL sizes gated behind rfdetr[plus] under a separate PML 1.0 licence. For a plant that will never publish source, Apache-2.0 removes an entire category of argument before it starts.

Roboflow's platform splits commercial rights by deployment method, with self-hosted inference on the paid tier and deployment outside their ecosystem under an enterprise agreement. Read that clause before standardising your tooling, because "we run it on our own edge boxes" is exactly the case that gets gated.

A good line produces almost no defects

Here is the arithmetic that breaks most projects. A line running at 200 defective parts per million produces one defect for every 5,000 good parts. Run half a million parts in a month, and you have collected roughly 100 defects spread unevenly across maybe nine failure modes, with the two modes you care about most represented by three images each. Supervised detection wants hundreds per class. Waiting will not get you there.

Train on normal only. Anomaly detection methods model what good looks like and score deviation from it. PatchCore keeps a coreset memory bank of patch features and scores by nearest neighbour. EfficientAD, out of MVTec, reported 95.4 percent AU-ROC for detection and 92.5 percent AU-PRO for localisation averaged over 32 dataset categories at 2.2 ms latency and 614 images per second, roughly 24 times faster than the previous best method while also more accurate. Intel's Anomalib packages both with OpenVINO export. This is the correct default when you have good parts and almost nothing else.

Then read the benchmark honestly. MVTec AD, 5,354 images across 15 categories, is saturated: leading methods sit above 99 percent image AUROC and separate by less than a point. MVTec AD 2, published in the International Journal of Computer Vision in 2026, was built to break exactly that. Over 8,000 high-resolution images across eight industrial scenarios including transparent and overlapping objects, dark-field and backlight illumination, very small defects and test images captured under lighting conditions absent from the training set. On that benchmark the paper reports the best methods staying below 60 percent average AU-PRO. Same algorithms. Harder optics and a lighting shift.

Generate the defects you do not have. Diffusion-based defect synthesis has become usable rather than academic. AnomalyDiffusion (AAAI 2024) learns anomaly appearance and mask distribution from a handful of examples, DefectFill (2025) frames the problem as inpainting so the masks align with the pixels they claim, SeaS at ICCV 2025 binds several anomaly types into one fine-tuned model. Useful. Also a trap, because a generator trained on the defects you already have will produce more of the defects you already have. It cannot invent the failure mode that appears when a supplier switches resin.

Spend labelling effort where it moves the decision boundary. Active learning is unglamorous and it works: route low-confidence and near-threshold parts to a human, label those, retrain. The images worth labelling are never a random sample. They are the ones the current model is least sure about.

Lighting and fixturing decide AI visual inspection accuracy

Vendors underplay this because they sell cameras and software. Practitioners know it because they have watched four points of accuracy arrive from a sixty dollar polariser.

The physics is not negotiable. If the defect does not modulate light into the sensor, it is not in the image, and no quantity of parameters recovers it afterwards. Dark-field low-angle illumination makes scratches and raised particles glow against a black field. Backlight turns a part into a silhouette with edges measurable to a fraction of a pixel. Coaxial light finds flaws on specular surfaces a dome would wash flat. A diffuse dome kills the specular hot spots on curved reflective parts that otherwise generate a false reject on every cycle. Photometric stereo with four strobed angles recovers surface normals and separates a printed mark from a dent, which no single exposure can do.

Fixturing does the same work in the spatial domain. If part pose varies by five degrees, the model spends capacity learning that nuisance variation instead of learning the defect. A hard stop, a vacuum nest or an encoder-triggered line-scan pass removes the variance for the price of a machined fixture, once, permanently.

Vision China takes 20,000 square metres at Shenzhen World this October with over 300 exhibitors. Walk it and count the floor area given to cameras, GPUs and software against the area given to illumination and mechanics. The ratio is inverted from where the accuracy actually comes from.

The inference budget is smaller than you think

Work backwards from the line. Never forwards from the model.

A line at 120 parts per minute gives 500 ms per part. Four camera views means 125 ms per view, and that budget covers exposure and settle time, transfer, debayer, preprocessing, inference, post-processing and the handshake back to the PLC. The model gets perhaps 30 to 40 ms. Note also which number goes in the spec: the PLC does not care about mean latency, it cares about p99.9, because one late verdict is a stopped line or an unsorted part.

Resolution drives cost, not parts per minute. A 20 megapixel line-scan image of a panel does not go into a 640 pixel network. You tile it, and now you run 40 inferences per part instead of one. Inference cost scales with pixels.

Hardware sets the ceiling. A Jetson Orin Nano Super developer kit is 249 dollars for 67 sparse TOPS, 8 GB of memory and 102 GB/s of bandwidth in a 25 W envelope. That runs a small detector at line rate comfortably. It does not run a 1024 pixel transformer across four views at 120 parts a minute, and pretending otherwise is how a pilot passes and a deployment fails. Export through ONNX Runtime or TensorRT, quantise to INT8 and measure on the actual box under thermal load in a cabinet, not on a workstation in an office.

False rejects are what actually kill the deployment

Chinese vendor spec sheets are more honest about this than English marketing. They quote two numbers: 漏检率, the miss rate, and 过杀率, the overkill rate. The miss rate is almost always guaranteed at zero. The overkill rate is the one you negotiate, and everyone in the room understands that is where the money sits.

Documented overkill above 20 percent is not unusual for rule-based AOI running under real production conditions. Do the arithmetic on a line at 500,000 parts a month. Twenty percent overkill routes 100,000 parts to a manual re-verification station. That is two or three operators doing the job the system was purchased to eliminate, plus work in progress, plus handling damage, plus the credibility cost the first time a quality engineer pulls a perfectly good part out of the scrap bin.

The threshold is a business decision, not a model property. An anomaly score is continuous. AUROC summarises every operating point and you deploy exactly one of them. What matters is the false positive rate at the recall your quality standard demands. A model at 99.6 percent image AUROC can still throw 8 percent false rejects once recall is pushed to 99.9, and quality departments always push recall to 99.9.

The cost of a false reject is not universal either. In Shenzhen a scrapped housing is replaced from a supplier in Bao'an the same afternoon. I have watched the same calculation run in Nigeria, where the replacement arrives in a container weeks later and has to be paid for in dollars somebody must first find. The identical model at the identical threshold is economically correct in one plant and close to negligent in the other. The threshold belongs to the plant, not to the vendor.

The strongest case against putting a model on the line

It runs like this, and it is mostly right.

A trained inspector plus a properly tuned classical AOI station is cheaper to deploy, faster to validate, easier to explain to a customer auditor and does not degrade silently. The human catches the novel defect no dataset contains, because that is what humans are for. The learned system needs image storage, labelling labour, retraining, drift monitoring and one person on site who understands why the score moved last Tuesday. If the product changes twice a year, revalidation eats the payback before it arrives. Plenty of plants have bought AI visual inspection, run it in parallel with the existing station for four months and then quietly left it in parallel forever.

I have seen that outcome more than once and I do not read it as a failure of nerve. It is a correct read of the economics.

The case turns on three conditions, and only three. First, when the defect sits below reliable human resolution: sub-100-micron cosmetic flaws on a specular surface, contamination visible only under a specific excitation wavelength. Second, when the requirement is consistency rather than peak accuracy. A good inspector beats a model on any single part. Across three shifts, a night rotation and a Friday afternoon, the model does not get worse and the inspector does. Third, when you need evidence. A vision cell writes an image, a score and a timestamp for every serialised part, and that is a traceability record you can produce two years later in a field-failure investigation. No human inspection process produces that.

If none of those three apply, keep the inspector and buy better lighting.

What nobody has solved yet

Logical defects. The component is present, correctly manufactured, undamaged and in the wrong orientation. Or there are seven screws where the drawing calls for eight. Every part in the frame is a good part and the assembly is scrap. Pixel-level anomaly scoring is close to blind here, because nothing looks anomalous locally. MVTec's LOCO dataset exists precisely because this class resisted the methods that flattened surface defects, and it has not fallen yet.

Then drift. A model trained on one resin batch quietly loses sensitivity when procurement changes supplier. The false reject rate moves, and somebody notices within a shift, because rejected parts pile up in a bin where people can see them. The miss rate moves and nobody notices at all.

That asymmetry belongs on the wall of every inspection project. Your overkill number is measured continuously, for free, by the operators standing at the re-verify station. Your escape rate is measured by your customer, months later, in an email with photographs attached.

Tools referenced

Ultralytics YOLO26, reviewed here: Ultralytics YOLO26 review.

Roboflow, reviewed here: Roboflow review.

ONNX Runtime, reviewed here: ONNX Runtime review.

CVAT, reviewed here: CVAT review.

Label Studio, reviewed here: Label Studio review.

FiftyOne, reviewed here: FiftyOne review.

Sources

The MVTec AD 2 Dataset: Advanced Scenarios for Unsupervised Anomaly Detection (arXiv): https://arxiv.org/abs/2503.21622

EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies (WACV 2024): https://openaccess.thecvf.com/content/WACV2024/papers/Batzner_EfficientAD_Accurate_Visual_Anomaly_Detection_at_Millisecond-Level_Latencies_WACV_2024_paper.pdf

Ultralytics YOLO26 model documentation: https://docs.ultralytics.com/models/yolo26/

Ultralytics licensing (AGPL-3.0 and Enterprise): https://www.ultralytics.com/license

RF-DETR repository and licence (Roboflow): https://github.com/roboflow/rf-detr

Anomalib anomaly detection library (Intel / open-edge-platform): https://github.com/open-edge-platform/anomalib

AnomalyDiffusion: Few-Shot Anomaly Image Generation with Diffusion Model: https://arxiv.org/pdf/2312.05767

NVIDIA Jetson Orin Nano Super Developer Kit: https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-orin/nano-super-developer-kit/

Frequently Asked Questions

Why does AI visual inspection work in the pilot and fail in production?

Almost always because the imaging conditions changed rather than the model. Pilots are run with fixed lighting, clean fixtures and a curated image set. Production adds ambient light leakage, lamp ageing, part pose variation, new supplier material and camera drift. The MVTec AD 2 benchmark quantifies this directly: it includes test images captured under lighting conditions absent from training, and on that dataset the best published anomaly detection methods stay below 60 percent average AU-PRO, against above 99 percent image AUROC on the older MVTec AD. Fix the lighting and fixturing first, then retrain.

How many defect images do you need to train a defect detection model?

For supervised detection, roughly a few hundred labelled examples per defect class, which most well-run lines cannot supply because they produce very few defects. The practical alternative is anomaly detection trained on normal parts only: PatchCore and EfficientAD build a model of good parts from a few hundred defect-free images and score deviation from it. EfficientAD reported 95.4 percent AU-ROC detection at 2.2 ms latency across 32 dataset categories. Supplement with diffusion-based synthetic defect generation and active learning that routes low-confidence parts to a human for labelling.

What counts as a good false reject rate for automated optical inspection?

A false reject, also called overkill or 过杀 in Chinese industry usage, is a good part classified as defective. Rule-based AOI under real production conditions has been documented above 20 percent overkill, and tuned deployments target under 1 percent. The number that matters is the false positive rate at the recall your quality standard requires, not the headline AUROC, since a model at 99.6 percent AUROC can still reject 8 percent of good parts once recall is pushed to 99.9 percent. Cost the overkill in operator hours at the re-verification station before signing off.

Read next

China's University Major Cuts Are AI Policy, and Nigeria Should Read the Fine Print

The latest analysis essay.

Keep reading

Working on something in this space?

If this analysis is close to a problem you're thinking about, say so. I read every message personally.

Start a conversation