AI quality inspection: when the camera says “pass” or “reject”

Visual inspection with AI does not replace your quality staff. It takes the thousand identical parts so people can look at the twenty that are in doubt. Here is what such a model must learn from, why the two kinds of error cost different amounts, and a pilot you can stop before it gets expensive.

Last checked:

Step by stepHow many example images?
  1. Collect bad parts on purpose
  2. Label everything the same way
  3. Keep a test set apart

Four ways to see a defect

An inspection station is a fixed camera, fixed light and a part that passes the same spot every time. That is the best situation for computer vision you can imagine. The question is what kind of answer you need:

  • Classification – good or bad. The model looks at the whole image and gives one label. Simple and fast, but it does not say where the defect is.
  • Detection – where is the defect. The model draws a box around the scratch, the missing screw or the crooked label. Useful when there are several defect types and the operator needs to see them.
  • Segmentation – exact shape. The model colours every pixel that belongs to the defect. Needed when the size decides whether a part passes.
  • Anomaly detection – learn only the good. The model is trained on flawless parts only and flags anything that deviates. That suits production where defects are rare and varied. The open library Anomalib is built for exactly this and is released under the Apache 2.0 licence according to its GitHub page.

The accuracy you measure depends on what has to be found. When we measured our own house model on 26 photos with 111 hand-drawn masks, it found floors with an IoU of 0.92, but doors only 0.46 and window frames 0.15. Thin, narrow things are hard – that goes for a crack in a casting too.

How many example images?

Ultralytics’ own training tips aim high: at least 1,500 images and 10,000 labelled objects per class, every instance labelled in every image, and 0–10 % background images with no objects to reduce false positives. Those are figures for a model that must be robust in many situations. On a fixed station with fixed light a pilot can often show the direction with far fewer – but the number has to be proven in your own test, not borrowed from another factory.

Three practical tips on the images:

  1. Collect bad parts on purpose. Defects are rare. Keep rejected parts in a box and photograph them at the station. Without them the model cannot learn them.
  2. Label everything the same way. Write a short labelling guide: what counts as a scratch, how small it may be, what does not count. Two people labelling differently give a model that disagrees with itself.
  3. Keep a test set apart. Put 10–20 % of the images aside and never train on them. It is the only honest measure of how good the model is.

We do the same on our own image projects: we publish the weak numbers too, because that tells you where to check by hand.

Two kinds of error, two kinds of bill

An inspection model can be wrong in two ways, and they cost different amounts:

  • False reject. A good part is scrapped or sent to manual inspection. That costs time and material.
  • Missed defect. A bad part slips through. That costs a complaint, a return or at worst a recall.

The model gives each image a confidence between 0 and 1. Where you set the threshold moves errors from one basket to the other: a low threshold gives more false rejects, a high threshold more missed defects. The threshold is a business decision, not a technical detail.

Worked example: what the errors cost per day

ItemThreshold 0.3Threshold 0.6
Parts per day10,00010,000
Of which bad (1 %)100100
Caught by the model9892
Missed defects28
False rejects30090
Missed × DKK 500DKK 1,000DKK 4,000
False × DKK 5DKK 1,500DKK 450
Total per dayDKK 2,500DKK 4,450
Made-up figures for illustration. Formula: daily cost = missed defects × cost per complaint + false rejects × cost per manual check

In the example the “cautious” threshold is cheapest even though it rejects many good parts, because a complaint is expensive. With other prices the picture flips. Put in your own numbers before you choose.

A lesson from our own work: when we gave a house model an automatic “second opinion”, doors got worse – the check removed real glass doors. Now fixed rules apply: real doors and windows are never removed, and a mask may at most double in size. The same holds on a line: an extra AI check needs rules it may not break, and it must be measured, not just switched on. When we use a vision model as a checker of AI-generated images, it may fix them automatically at most twice – then it stops.

An eight-step pilot plan

From idea to production without stopping the line

A pilot must be stoppable after every step. The model rejects no parts until step 7 is approved.

  1. Defect list and requirements. Write down the defect types to find and how many missed defects are acceptable.
  2. Camera and light. Fixed mounting, fixed distance, its own light and a shield against daylight. Take test images across shifts.
  3. Image collection. Save images of all parts for a couple of weeks and photograph rejected ones separately.
  4. Labelling. Label by the guide and have a second person check a sample.
  5. First model. Train and measure on the test set: caught defects, missed defects, false rejects.
  6. Shadow mode. The model runs alongside manual inspection for 2–4 weeks without rejecting anything. Every disagreement is saved.
  7. Decision. Compare shadow mode with the worked example above and choose the threshold.
  8. Production with a human on rejects. The model sorts, a person looks at the doubtful ones, and new defect types are labelled as they appear.

What it costs – the elements

We do not give a total price, because it depends on the line. But the cost items are the same every time:

  • Optics and light. An industrial camera or an ordinary network camera, lens, lighting and mounting. Light often matters more than the camera.
  • Compute. An edge computer at the line, ideally with a graphics card or an AI chip if there are many parts per second.
  • Labelling. Hours of a person drawing boxes around defects. Often the largest item in a pilot.
  • Training. Free on your own machine or paid in the cloud. Azure, for example, charges USD 20 per training hour for custom object detection (about DKK 135.99 at Danmarks Nationalbank’s rate of DKK 6.7997 per USD on 19.11.2026).
  • Licence. Open models under AGPL require a commercial licence if you do not want to release your code – see the vision tools page.
  • Integration. A signal to a PLC that pushes the part out, or a line in your quality system.
  • Maintenance. A new product, a new colour or a new raw-material supplier means new images and new training.

Two rules that save money. A camera that sees only the product and no people is not TV surveillance under Datatilsynet’s guidance – so angle it so the operator’s face is not in view. And if the vision model becomes a safety component of a machine, it may fall under the AI Act’s high-risk rules for products, which after the Digital Omnibus apply from 2 August 2028. Ordinary cosmetic inspection is not a safety function.

Honest status: we have not built an inspection system for a production line, and no camera model of ours runs in production. Our experience comes from image analysis and segmentation in our own products – for example the image analysis in our image plugin, which also looks at where the image sits on the page – and from Ultralytics’ YOLO guides, which we have used since 14.11.2026.

Questions about AI quality inspection

What is AI visual inspection?

A camera at a fixed station photographs each part and a model decides whether it is good or where the defect is. The result goes to a person or to a machine that sorts the part out.

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

Ultralytics recommends at least 1,500 images per class for a robust model. A pilot on a fixed station can show the direction with fewer, but only a test on your own images tells you whether it holds. If defects are rare, consider anomaly detection trained on good parts only.

Can AI find defects it has never seen?

Anomaly detection can flag that something is different without knowing the defect type. A classification or detection model can only find the defect types it was trained on.

Does the AI Act apply to quality inspection?

Usually not as high-risk. That changes if the model is a safety component of a product or machine under EU product-safety rules.

Sources

Last reviewed: 2026-12-03

Fixed price, no commitment

Get a concrete answer

Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.

  • A fixed price before we start
  • An answer by e-mail, no calls
  • Your details are used only to answer you

Fields marked with * are required.

What is it about?