Object detectors take an image and return a list of findings: a bounding box around each object, a class label and a confidence score saying how much the model believes the finding. On an inspection line this means the model does more than call a part bad. It says where each defect is, what kind it is and how confident the model is in that call. The headline number, usually mAP, averages this behaviour over benchmark data. It does not tell you which confidence threshold to run, and performance degrades when deployment data differ from the training data. Those two gaps are where we would put the engineering effort on a real line.
How Object Detectors Find Defects with Boxes, Class Labels and Confidence Scores
Modern detectors are neural networks, typically convolutional, that learn their features end to end instead of relying on hand-designed ones. Conceptually the job has two parts: find the image regions likely to contain an object, then decide what each one is. Architectures differ in whether they split those parts into separate stages or do both at once.
In outline, the path from pixels to a reject signal looks like this:
- Feature extraction. A backbone network turns the image into feature maps. Many detectors use several resolutions so they can handle defects of different sizes.
- Candidate boxes. At every location the detection head proposes boxes. Faster R-CNN uses a region proposal network that predicts object bounds and an “objectness” score at each position, working from reference boxes called anchors (3 scales and 3 aspect ratios, so 9 per location, in the original design). YOLO divides the image into a grid, and each cell predicts boxes, a confidence and a class for objects centred in it.
- Scoring. Each box gets class probabilities and a confidence. In YOLO the confidence is defined as the probability that an object is present multiplied by the expected overlap (IoU) with the true box.
- Duplicate removal. Non-maximum suppression (NMS) removes lower-scoring boxes whose IoU with a higher-scoring box exceeds a set threshold.
- Confidence filtering. Whatever survives NMS is compared with the confidence threshold. Detections below the threshold are dropped, and those above it become your accept, reject or review decisions.
IoU (intersection over union) is the overlap between a predicted box and a reference box, and it is the basic measure of how well a detector localises. It comes up twice in this pipeline, in NMS and in evaluation, so it pays to keep the two uses apart. If you want to see where box geometry gets fixed, including axis-aligned versus oriented boxes for rotated parts, our piece on the detection head goes into that stage.
How Does Object Detection Differ from Image Classification and Segmentation?
Classification gives the whole image one label. Detection classifies and also localises each object in the image. Segmentation goes down to individual pixels. Defect-detection systems use all three levels: image classification, localisation with bounding boxes and pixel-level segmentation.
For defect inspection, the choice follows what the decision downstream needs. A pass/fail gate on a part that is either good or scrap can work with classification. Detection is the right level when you need to count defects, know which zone of the part they sit in or log the defect type. Segmentation pays off when the defect’s area or outline decides acceptance, as in crack segmentation. When segmentation follows detection, the trade-offs between SAM, MobileSAM and FastSAM are a separate decision, and instance segmentation for manufacturing inspection covers the case where each defect needs its own mask.
How a Detection Model Localises a Defect Instead of Labelling the Image
The network is trained on two tasks together. Fast R-CNN, for example, has two sibling outputs for each candidate region: probabilities over the object classes plus a catch-all “background” class, and four box coordinates for each class. A multi-task loss trains classification and box regression jointly. In evaluation, a detection only counts as correct when the class label is right and the box overlaps the ground truth above an IoU threshold. Otherwise it is a false positive, and a defect left without a matching box is a false negative.
What Does a Benchmark Score Like mAP Actually Measure, and Why Can It Mislead on a Production Line?
mAP summarises precision and recall across confidence thresholds, averaged over classes. Precision is the share of kept detections that are correct, and recall is the share of real objects the model found. Average precision (AP) is the area under the precision-recall curve as the confidence threshold sweeps through its range, computed per class, and mAP is the mean of those per-class APs. COCO’s primary metric averages AP over 10 IoU thresholds from 0.50 to 0.95 in steps of 0.05, while AP at IoU 0.50 is the older PASCAL VOC metric. Averaging over IoU thresholds rewards detectors that localise better.
The metric hides four things that matter on a line:
- Box tightness. AP does not directly measure how tight the boxes are. You cannot infer localisation quality from it.
- The shape of the trade-off. AP cannot tell apart very different precision-recall curves. In one comparison, a detector scored 7.5% lower AP than another yet had higher precision through the end of its curve.
- Where the errors come from. In the COCO analysis of a ResNet detector, AP at IoU 0.75 was 0.399. Perfect localisation would have raised it to 0.682, removing class confusion only to 0.713, and removing background false positives to 0.870. TIDE (Bolya et al., 2020) splits detection errors into six types and measures how much each one contributes, which is the kind of breakdown a single mAP cannot give.
- Your rare classes. mAP is a plain average over classes, so one weak defect class is diluted by several strong ones.
The gap shows up in practice as a detector that scores 0.94 mAP in the lab and then starts throwing false rejects on the conveyor. We trace that to a five-stage inspection pipeline where each stage fails in its own way. Published guidance is to choose the metric by application: IoU where location is critical, precision where false detections must be minimised and recall where every instance must be found.
How Do Confidence Thresholds Trade Detection Rate Against False Positives for Industrial Defects?
A lower threshold keeps more detections, some of them wrong. A higher one drops the weak detections, so false positives fall and misses rise. mAP is useful for comparing models, but it does not choose the production threshold. That choice is an error-cost decision. In high-throughput inspection, false positives reject good product or create needless review, so a higher threshold can be worth some missed difficult detections. When a miss carries the higher cost, the trade runs the other way. In safety monitoring, for example, you accept more false positives to keep recall high. How those two error types feed back into process control is the subject of QC vs QA and the feedback loop.
Worked Example: One Model, Three Thresholds
These figures come from Roboflow’s published warehouse example, not an inspection line. They show the mechanism, not a result to expect on your parts.
| Confidence threshold | Recall | What happened |
|---|---|---|
| 0.30 | 100% | Every object found, with 9 false positives |
| 0.39 | 93.6% | Precision 98.6%: the most balanced of the three |
| 0.50 | 74.4% | False positives gone, but 20 real objects missed |
Three details carry over to inspection directly. First, the effect differed by class (one class moved sharply, two barely changed), which is the argument for class-specific thresholds. The LRP work makes the same point formally, searching the confidence scores per class for the best balance of precision, recall and box quality. Second, a threshold tuned on one scene can behave differently when camera angle, lighting or object size changes, so the candidates should be tested on a golden set that represents post-deployment conditions. Third, duplicate boxes are an NMS IoU setting problem. Raising the confidence threshold to remove them also kills valid detections elsewhere. A middle confidence band can also go to human review instead of being forced into accept or reject.
Choosing Between YOLO, SSD, Faster R-CNN and DETR-Style Object Detectors
Architectures split into two-stage designs, which generate region proposals and then classify them, and one-stage designs, which predict classes and locations directly. Skipping the proposal stage makes one-stage models faster but has often cost accuracy. Lin et al. traced that accuracy gap to the extreme foreground-background imbalance in dense detectors. Their focal loss let RetinaNet match one-stage speed while surpassing the two-stage detectors of the time.
| Detector | How it works | What its authors or reviewers report |
|---|---|---|
| Faster R-CNN (two-stage) | Region proposal network generates proposals for the detector | Outperformed YOLO and SSD in one review, which blamed their localisation errors |
| YOLO (one-stage) | Single network regresses boxes and class probabilities from the full image | More localisation errors, but far fewer false detections on background |
| SSD (one-stage) | Default boxes at several scales across multiple feature maps | 72.1% mAP on VOC2007 at 58 FPS on an Nvidia Titan X (300×300 input); weak on small objects |
| RetinaNet (one-stage) | Dense detector trained with focal loss | Matched one-stage speed and beat the two-stage accuracy of its time |
| DETR (transformer) | Set prediction, with no NMS and no anchors | On par with a Faster R-CNN baseline on COCO |
| RT-DETR (transformer) | Real-time end-to-end transformer detector | 53.1% AP on COCO at 108 FPS on a T4 GPU (R50) |
So is YOLO better than SSD? The papers can’t settle that for your line. Their figures come from different benchmarks and GPUs, so the table rows do not compare with each other. The RT-DETR authors describe the YOLO series as the most popular real-time framework because of its reasonable trade-off between speed and accuracy, and they also show that NMS drags down YOLO’s speed and accuracy. Huang et al. built their speed, memory and accuracy study as a guide for picking the balance that suits a given application and platform. That is the right framing for automated visual inspection: you choose from your defect sizes, your line rate and your inference hardware, not from a leaderboard.
For inspection specifically, we would weight two things above headline AP. One is how the architecture handles small, low-contrast defects, which the industrial survey literature names as a persistent difficulty alongside multi-scale defects, real-time limits and scarce labelled samples. The other is the localisation-versus-background-error profile: YOLO makes more localisation errors but fewer false detections on background. Deployment specifics for that family are covered in YOLO inference for industrial CV inspection.
Why Off-the-Shelf Object Detectors Get Worse Once They Run in Production
Detectors are designed on the assumption that training and evaluation data come from the same distribution. In deployment the target distribution often differs, and performance degrades substantially. Lighting, viewing angle and environment are named causes of this domain shift. One form is covariate shift: the input images change while the right answer for each image stays the same, as with the same object photographed in bright and in dim light. A model trained on DSLR images may perform poorly on smartphone captures.
The measured drops are large, but they come from satellite imagery and corrupted benchmark images, not inspection lines. In a benchmark, every detector tested lost more than 35% of its mAP on two of the three out-of-distribution climate zones. Across geographic regions, the drops exceeded 52% and 62%. Michaelis et al. found that standard detectors fall to 30–60% of their original performance on images with common weather and image corruptions. They do not predict your line. The industrial survey literature does note that even strong pre-trained networks show domain shifts in industrial inspection, which is why recent work emphasises fine-tuning to the target domain.
On a line, shift arrives through changes in lighting, viewing angle or environment, and through defect types absent from training. Supervised detectors only recognise the defect categories they were trained on. The image itself is formed before any model sees it, and the weakest stage of lighting, optics, fixturing and machine vision camera capture caps the accuracy you can ever reach. Those acquisition causes are the subject of optics and lighting validation.
Our position is that off-the-shelf detectors degrade in production when deployment data differ from their training data. The mitigations in the literature include training on several source domains, which improved generalisation to unseen domains in the CVPR 2025 benchmark, stylising training images, which substantially raised robustness to corruptions, and domain adaptation methods that align features across domains. Keeping a model stable from one cell to the full line is covered in scaling AOI inspection models across the factory.
How Do I Read the Per-Defect-Class Accuracy Bands from a Feasibility Audit?
Read them one class at a time, at a stated threshold, on data that looks like your line. A single aggregate number is the least useful thing in the report. Every concept above shows up in an audit table, and this checklist ties them together:
- Is each defect class reported separately? mAP averages over classes and can hide a weak class.
- At which IoU threshold? AP at IoU 0.50 and AP averaged over 0.50 to 0.95 reward different things.
- At which confidence threshold, and how was it chosen? The production threshold is a separate decision from mAP.
- Are precision and recall both shown? On a line, low precision means good parts rejected and low recall means defects missed.
- Was the evaluation set a golden set captured under line conditions? Thresholds shift with angle, lighting and object size.
- How many samples back each band? Rare classes are exactly where labelled data is scarce, and a band resting on a handful of examples should be read as wide even if it is printed narrow.
- Does any class sit outside what the model can do? Some defects are not feasible today, and the honest output for them is “no-go”.
TechnoLynx scopes this as a CV-inspection feasibility audit. It reports per-defect-class accuracy bands and a go/no-go decision before a pilot is committed. You can find out what the deliverable contains in what a CV inspection feasibility audit delivers, and our wider computer vision R&D work covers the engineering after a “go”. The first question is whether the outcome you want is plausible at current capability. A repeatable inspection task the model can learn is a very different proposition from expecting the model to beat your best inspector. TechnoLynx’s position is that most AI projects fail, and an audit that does not say so up front does the buyer no favours. No band in such a report should be read as a promise of near-perfect detection, and no audit should claim that CV removes all manual inspection.
Once you know how a detector boxes, scores and filters defects, the feasibility question stops being whether the model is accurate enough. It becomes which defect classes the model can reliably catch at a false-reject rate your line can absorb. That is the question the parent guide to CV inspection feasibility works through, class by class.
FAQ
What Is an Anchor Box in Object Detection?
An anchor is a reference box centred at a location in the feature map, with a set scale and aspect ratio. The detector predicts adjustments relative to it. The original Faster R-CNN used 9 anchors per location. DETR drops anchors entirely.
Is YOLO Object Detection?
Yes. YOLO treats detection as a single regression from the full image to bounding boxes and class probabilities.
What Is an Acceptable False Positive Rate?
The acceptable rate depends on what a false reject costs you compared with a missed defect, and on that basis you choose a threshold region and test a few candidates on representative data.