Instance segmentation gives each defect a class label and a pixel-level outline. Object detection does not give an accurate pixel-level outline, and semantic segmentation cannot tell apart two defects of the same class. In manufacturing inspection, that extra output is worth its cost when the acceptance spec depends on a defect’s area, extent or shape (coating coverage, scratch length, size gating). It adds little when a label or a box already drives the reject decision. Before you trust the system to replace a human inspector, you have to validate three things separately: the optics and lighting that decide whether the defect appears in the image at all, the metrics that decide whether misses show up in the numbers, and the quantised model that actually runs on the line.
That validation sits inside a wider system. If you want the full chain from camera to reject gate, start with how computer vision systems for manufacturing work. Everything below concerns the segmentation stage and how you prove it works.
What Instance Segmentation Adds over a Detector in Manufacturing Inspection
NIST frames defect inspection as either object detection (a tight box around each defect) or instance segmentation, where every defect pixel is classified and assigned to one particular defect. Trained on both tasks, NIST’s Mask R-CNN system reached 0.957 box mAP on GDXray castings; with the segmentation module removed, it reached 0.931. The authors credit multi-task learning: the box and mask heads share one representation of the image.
Those gains come at a cost. The same NIST system ran about 12% slower and needed 9% more GPU memory at inference (9.72 GB) than detection alone. Its authors also concluded that instance segmentation needs a large amount of training data: accuracy improved markedly when the training set grew from about 1,100 to 2,308 images. In the original Mask R-CNN paper, a ResNet-101-FPN model runs at 195 ms per image on an Nvidia Tesla M40 GPU, plus 15 ms of CPU time. On a line with a fixed cycle time, a two-stage segmenter has to earn its place.
Mask R-CNN extends Faster R-CNN with a branch that predicts a small binary mask for each region of interest. Its RoIAlign step removes the quantisation misalignment of the older RoIPool. That improves mask accuracy by 10% to 50% in relative terms, with larger gains under stricter localisation metrics. The architecture and segmentation trade-offs of Mask R-CNN in production are covered separately.
Boxes have a geometric accuracy ceiling. HabileData’s analysis shows that a perfect bounding box around an object with a 3:1 aspect ratio, rotated 30 degrees, reaches at most 41% IoU against the object’s true extent. A thin diagonal crack is the extreme case: almost all of the box is background, so any area figure taken from the box is meaningless.
Choosing the architecture is a validation question too. In a Scientific Reports comparison on PCB laser cleaning, Mask R-CNN (ResNet-50) scored 84.1% mAP50 on masks at 1.52 FPS, and YOLOv8-seg (l) scored 82.8% at 3.98 FPS. On a new test set with unseen patterns, YOLOv8-seg held 69% while Mask R-CNN fell to 36.91%. The familiar test set alone would have picked Mask R-CNN, the model that generalised worse. TechnoLynx’s view is that models which look solved in a demo fail on the edge cases, lighting conditions and throughput of actual deployments.
Which Output Does the Defect Spec Need?
| What the spec decides on | Output that fits | Why |
|---|---|---|
| Whether a defect class is present on the part | Classification label | Location adds nothing to a pass/fail on presence. |
| Where defects are, and how many | Detection boxes | A box localises and counts at lower annotation and inference cost. |
| Defect area, coverage percentage, length or size gating | Instance masks | A box over- or under-counts area on irregular or elongated shapes. |
| Several overlapping defects of the same type, each measured separately | Instance masks | Semantic masks merge same-type defects that occur in the same image. |
If the spec fits the first two rows, how an image detection model works in industrial inspection is the better starting point.
Paying for Masks: Annotation Cost Against Boundary Needs
On COCO, a bounding box takes about 7 seconds to annotate, a box plus 10 points about 16 seconds, and a polygon mask about 79.2 seconds. The same pointly-supervised study found that Mask R-CNN trained on a box and 10 points per object reached 94% to 98% of its fully supervised performance. HabileData prices polygons at 4 to 8 times the cost of boxes per object. It also warns that box-supervised segmentation falls further behind on low-contrast, specialised industrial data. The ZJU-Leaper fabric defect benchmark treats masking every defect in a large set as the last resort.
One pattern HabileData describes: box the whole dataset, then draw polygons on a 10 to 20% subset chosen for hard cases such as thin objects and classes the model confuses. Thin cracks belong in that subset, because boundary precision is the reason masks were worth buying for them. Crack segmentation for industrial inspection goes into that defect class in depth.
Is the Ring Light Causing Poor MTF on Foam Seat Trim, and Is That a Lighting Fix or a Camera Fix?
Ring-light geometry can be the root cause of poor MTF and weak contrast on a textured material like foam seat trim. When it is, the fix is to redesign the lighting, not to buy a new camera. MTF describes how well the system transfers contrast, but the lighting creates the contrast on the object in the first place.
TechnoLynx can take on that diagnosis as engineering work. That means defining the trim defect types and sizes that must be caught, building a controlled rig that separates lighting effects from lens and sensor effects on the actual foam, and deriving the acceptance threshold the redesign is judged against.
The angle of the light changes what the camera sees. Advanced Illumination describes bright-field ring lights, above 45 degrees from horizontal, as good at showing cracks and scratches on uneven, non-reflective surfaces. Dark-field lighting between 0 and 45 degrees suits reflective surfaces and edge effects. Low-angle rings create shadows and bright spots that reveal changes in depth and surface texture. On foam, that texture response may be the noise burying the defect rather than the signal. Francis Okafor’s field notes make the same physical point: if the defect does not modulate light into the sensor, no model recovers it, and a diffuse dome removes the specular hot spots that cause false rejects on curved reflective parts.
Isolate the cause with the camera held fixed:
- Measure MTF with a resolution target under the current ring-light geometry, camera and lens unchanged.
- Repeat under one or two alternative geometries, changing angle, diffusion or standoff distance only.
- If MTF improves materially, lighting geometry is the root cause and the lighting is what gets redesigned.
- The lens itself also limits contrast: aberrations and f-number both affect contrast at a given resolution.
- Before blaming geometry, rule out noise from the sensor, lighting or electronics, which makes low-contrast features harder to detect.
- Confirm on real trim parts, including colour variants and worn surfaces, because a flat target will not show the shadows and hot spots a new geometry can create on curved foam.
The same discipline carries into production. Okafor’s account attributes pilot-to-production failures almost always to changed imaging conditions: ambient light, lamp ageing, pose variation and new supplier material. He cites MVTec AD 2, where the best anomaly detection methods stay below 60% average AU-PRO on images taken under lighting absent from training. The same methods score above 99% image AUROC on the original MVTec AD. Lighting, fixturing and conveyor conditions belong in the CV inspection site survey before any model is chosen.
How Do You Set an MTF and Noise Acceptance Threshold from the Smallest Defect?
Start from the smallest defect the station must catch, in micrometres. Opto Engineering calls this the single most important parameter in the design. That feature must span at least two pixels to be sampled reliably, and the Nyquist frequency in line pairs per millimetre is 1000 divided by twice the pixel size in micrometres. One pixel-count guide gives 3 pixels per feature for detection and 10 for recognition. From there, the lens and sensor must deliver enough contrast at the resulting spatial frequency. Opto Engineering’s rule of thumb is a minimum of 20%, with the lens MTF showing 30% contrast at 67% of the Nyquist cutoff as a check on lens-sensor matching.
The 20% margin exists because real illumination, extra components, irregular defect shapes and noise all erode contrast beyond what an MTF calculation predicts. “Sufficient contrast” is ultimately set by the algorithm and the task. Derive the threshold on the material itself, with the noise floor set by the false-accept and false-reject rates you need, and derive it again for each trim part.
Which Metric Shows Missed Thin Cracks: Dice, IoU, Boundary F1 or Hausdorff Distance?
Boundary F1 and Boundary IoU are better suited than region metrics to thin structures such as cracks; report them alongside Dice or IoU, not instead of them. Region metrics such as IoU and Dice hide boundary errors when an object’s interior is large, and under extreme class imbalance the background dominates the score. In one whiteboard-stroke study with foreground at about 1.8% of pixels, a model predicting all background scored above 98% pixel accuracy. Defect imagery is similar: in structural inspection data, cracks are thin and elongated, and some defect classes cover less than 1% of image area.
Boundary metrics work by scoring only a band around the contour. Boundary F1 computes precision and recall on that band. Boundary IoU restricts IoU to a band 2% of the image diagonal wide, so it measures contour placement rather than interior fill. Cheng and colleagues showed Boundary IoU is much more sensitive than mask IoU to boundary errors on large objects, without over-penalising small ones. HabileData notes that a mask can score 0.95 IoU while its boundary is visibly wrong.
| Metric | What it shows | Blind spot |
|---|---|---|
| Pixel accuracy | Share of correctly classified pixels | Background dominates; an all-background prediction can exceed 98%. |
| Dice / IoU | Overlap of predicted and true masks | Boundary errors hidden when the interior is large. |
| Boundary F1 | Precision and recall on the contour band | Scores only the contour band, so report it with region metrics. |
| Boundary IoU | IoU inside a narrow contour band | Ignores pixels outside the band; report it with region metrics. |
| Hausdorff distance | Shape similarity | The gland benchmark reports it beside F1 and ObjectDice, not on its own. |
Missing defects and over-segmenting are different failures. In the PCB comparison, Mask R-CNN had higher recall but over-segmented some regions, while YOLOv8-seg was more precise. Choose which error to weight by what each one costs downstream, not by habit. Two physical limits also show up in these metrics. Doubling input resolution improved boundary F1 by 19 points in the whiteboard study, and its most prominent failure mode was low-contrast strokes under heavy directional glare.
Stratifying the Test Set by Lighting Condition and Defect Class
A single aggregate score can be carried by the easy images. The same study found mean F1 dominated by easy, high-contrast images, and its protocol reports median, interquartile range and worst-case scores per image. The PCB study shows how this looks in practice: YOLOv8-seg reached 69% mAP50 overall on the new test set but only 50.6% on the rare Severe-Damage class. The VISION Datasets authors note that their datasets cannot reproduce every real lighting condition and camera angle.
For stratified evaluation of a segmentation model, tag every test image with its lighting condition and defect class, then report each metric per cell of that grid as well as overall. Slicing a test set two ways thins every cell, so publish the count per cell and either merge sparse lighting conditions or collect more data for rare classes.
How Do You Prove a Defect-Detection Model Catches Defects Before It Replaces Manual Inspection?
Prove it on evidence the model never trained on. Use a challenge set of parts with known defects, compare the model against human inspectors on those same parts, and check it against the line’s historical record of escapes. Held-out labelled images alone are not enough. NIST’s zero-shot test shows why this matters: on an unseen X-ray of a jet turbine blade, a part type absent from the training data, the system found four of five casting defects.
A human baseline is useful only if it is measured on the same challenge set, not taken from an assumed figure. The decision also depends on the role: supplementing manual review allows thresholds calibrated against historical escape data, validated on the full historical record.
In an aerospace NDI study using instance segmentation on ultrasonic scans, the authors reached an average precision above 80% at an IoU of 0.5. Even so, they argued that sensitivity must take priority over precision, because a false positive is preferable to a missed defect. The VISION Datasets authors use a combined mAP and mAR metric for the same reason: in manufacturing, both overkills and escapes carry real costs.
What Recall Threshold Should the System Meet Before Rolling Out Across the Line?
No universal number exists. The threshold follows from the cost of an escape against the cost of a false reject on your line, set with explicit risk and regulatory input. Okafor’s field notes put it plainly: the threshold sets the ratio of escapes to false rejects, and it is a business decision, not a property of the model. What to check is the false positive rate at the recall your quality standard requires. He gives the case of a model at 99.6% image AUROC still rejecting 8% of good parts once recall is pushed to 99.9%. He also notes that rule-based AOI has been documented above 20% overkill under production conditions, while tuned deployments target under 1%.
One asymmetry should shape the rollout plan. False rejects pile up where operators see them within a shift, but escapes are reported by the customer months later. A gate that tracks only overkill will miss the failure that matters most. The method for setting a defensible, cost-weighted threshold for defect detection and for re-tuning it has its own treatment. Watching the live rates afterwards is the job of statistical process control charts for CV defect detection.
Does the Quantised Model on the Edge Device Still Catch the Same Defect Classes as the Lab Reference?
Not by default. An accuracy figure measured before quantisation does not guarantee the same accuracy from the quantised, deployed model.
LynxBenchAI publishes results comparing edge devices on public model architectures and precisions, so the first step is to check those results for your candidate hardware before running the parity test on your own trained model.
TechnoLynx builds this on-device validation for inspection deployments. The work starts by agreeing the fault classes, the tolerance against the lab baseline and the timing budget, then runs a paired edge-versus-reference comparison on the target hardware and turns it into a repeatable gate for every retrain, as part of TechnoLynx’s AI engineering for manufacturing. This kind of validation is reliability engineering, distinct from model accuracy: its deliverables are eval harnesses, regression suites and release gates that catch silent regressions before customers do.
The evidence that quantisation shifts segmentation accuracy is direct. In the YolactEdge work, NVIDIA TensorRT conversion to INT8 or FP16 trades accuracy against speed differently for each network component. Converting the prediction head to INT8 always caused a large loss of instance segmentation accuracy. Even with the best configuration, the gap between FP32 training and FP16/INT8 inference was not fully closed. The speed is real: YolactEdge reached up to 30.8 FPS on a Jetson AGX Xavier, and an industrial edge benchmark found TensorRT cut YOLOv8 latency by roughly 30% to 56% against the next-best framework on NVIDIA GPUs. Masks also carry the extra latency and memory cost NIST measured.
Timing deserves its own test. That benchmark measured network inference only, excluding pre- and post-processing and discarding warm-up runs. Line timing is end-to-end, so a published latency figure cannot rule out dropped frames or buffer overflows under sustained load. Motion blur is another source of error in edge video segmentation.
Edge Parity Checklist
- The tested artefact uses the same quantisation, compiler, runtime and input pipeline as production.
- The comparison is paired: edge and reference models score the same production-representative captures.
- Results are reported per fault class, not only in aggregate.
- Rare classes are covered by known-defect challenge sets or synthetic defects where natural rates are too low for statistical confidence.
- The tolerance and the statistical test are agreed before the run, not chosen after seeing the numbers.
- Live streamed scoring is compared with offline scoring on the same captured data, logging dropped frames and buffer overflows.
- Timing is tested under sustained load, not only in short runs.
- The whole protocol reruns on every retrain or firmware update.
Passing shows that the fault classes are still caught in that deployed environment. It is not a guarantee for other lines, other hardware revisions or future drift. Keeping parity across lines and camera revisions after go-live is covered in the reliability artefacts that keep a line-side CV model running.
Who Can Validate a Segmentation Inspection System Before We Commit to a Pilot?
TechnoLynx engineers validation for vision-based defect inspection, from lighting diagnosis to on-device parity. It diagnoses the optics and lighting chain, derives defect-size acceptance thresholds, and builds on-device parity tests for the quantised model. The first step is a feasibility check: is the defect catalogue detectable at realistic capability, and does the expected outcome justify the cost? If the open question is which edge hardware to buy, LynxBenchAI publishes results comparing devices on public model architectures and precisions. Those results measure the hardware, not your trained inspection model.
Image Quality First, Then Metrics, Then the Deployed Artefact
The order of these checks is not arbitrary. A boundary-aware benchmark run on images where the ring light washes out the defect measures the lighting, not the model. A parity test against a reference model that was scored only on its easy strata proves that two models fail the same way. Each stage gives valid evidence only if the stage before it held. The question to settle for your own line is which stage you have actually measured, and which one you have so far only assumed.