Skip to content
AI.info

Computer vision

Anomaly Detection and Industrial Inspection

Learn one-class, reconstruction, embedding, synthetic-defect, and supervised approaches for visual inspection under scarce and changing defect data.

By the end you can

Key idea

An anomaly is a deviation from modeled normality, not a universal defect

A rare but acceptable texture can receive a high anomaly score. A common safety defect can look familiar. Severity and statistical novelty have to stay separate. In regulated manufacturing that separation is not a design preference — it is written down.

Every filled container of an injectable drug is inspected one by one, and what counts as a defect is settled before the line starts. EU GMP Annex 1, rewritten in 2022, says so at paragraph 8.30: “All filled containers of parenteral products should be inspected individually for extraneous contamination or other defects. Defect classification and criticality should be determined during qualification and based on risk and historical knowledge.” Criticality is fixed at qualification, out of risk and history, before any detector has scored anything. The same paragraph requires a maintained defect library used to train inspection staff, and sends critical defects to investigation. Paragraph 8.33 asks for reject levels to be trended by defect type on statistical principles.

A batch can pass its sampling test and still be adulterated. That is the part a threshold cannot deliver, and FDA's December 2021 draft guidance on inspecting injectable products for visible particulates is blunt about it. “Each final container must be inspected (100% inspection) using a qualified method”, and extrinsic particulates “may result in product that could be considered adulterated, even if the statistical sampling acceptance criteria are met”. Severity outlives an acceptance test the batch has already passed.

So define defect taxonomies, acceptability rules and escalation paths, even when the model trains mostly on normal examples. The taxonomy is a regulated artefact in some industries and a design decision in all of them.

Benchmarks carry the same bias. They are full of scratches, dents and contamination, and short of parts that are simply in the wrong place. Bergmann and colleagues reported in 2022 that “existing datasets are biased towards local structural anomalies such as scratches, dents, or contaminations” and “lack anomalies in the form of violations of logical constraints, e.g., permissible objects occurring in invalid locations”. Their MVTec LOCO AD dataset holds “3644 images from five different categories inspired by real-world industrial inspection scenarios” and covers both kinds, including “a permissible object being present in an invalid location or a required object not being present at all”. A pixel-level scratch detector can be excellent and blind to the missing part.

Novelty is evidence for review, not a complete quality decision.

Comparison

Inspection regimes depend on which defects are known

How much data you have changes the problem more than the model family name. Supervised defect detection learns labelled examples of known defect types, and misses new failure modes. One-class or feature-distance detection models normal features and flags departures: abundant normal data, at the price of sensitivity to nuisance change. Synthetic-defect training fabricates plausible perturbations to teach localisation. It expands rare coverage and controls defect masks, and it carries simulation mismatch risk. A hybrid review system combines anomaly score, rules, known-defect heads and human judgement, which separates severity from novelty but requires policy design.

The synthetic column has a named method behind it, with a number and a candid warning. DRÆM — Zavrtanik and colleagues, 2021 — trains a defect detector on simulated anomalies only: binarised Perlin-noise masks blended with textures from the unrelated Describable Textures Dataset. Across the fifteen MVTec AD classes it reaches a mean image-level AUROC of 98.0. That is 2.5 percentage points above the previous best, and 13.4 percentage points better in pixel-level average precision. What makes it worth teaching is that its authors never claim the fabricated defects resemble real ones. The paper says the opposite: “DRÆM does not require simulations to realistically reflect the real anomaly appearance in the target domain, but rather to generate just-out-of-distribution appearances, which allow learning the appropriate distance function to recognize the anomaly by its deviation from normality.” The simulator is teaching a distance, not a defect.

The risk in that column is measurable too, not just rhetorical. Engineers at Valeo and Intel re-ran DRÆM alongside ten other models over nine datasets in 2025. The generation-reliant discriminative methods were the ones that failed on the harder real-production sets. Choose the synthetic route knowing what it optimises: an out-of-distribution boundary, validated against real defects you did not draw.

FigureComparison · 4 columns

Supervised defect detection

Train on labeled examples of known defect types.

  • Strong known-class performance
  • Needs representative defects
  • Misses new failure modes
  • Example: scratch detector

One-class or feature-distance detection

Model normal features and flag departures.

  • Uses abundant normal data
  • Supports unknown defects
  • Sensitive to nuisance changes
  • Example: texture inspection

Synthetic-defect training

Create plausible perturbations to teach localization or discrimination.

  • Expands rare coverage
  • Controls defect masks
  • Simulation mismatch risk
  • Example: fabricated dents

Hybrid review system

Combine anomaly score, rules, known-defect heads, and human judgment.

  • Separates severity from novelty
  • Supports triage
  • Requires policy design
  • Example: factory QA

Case

Inspection benchmarks train on normal images and meet defects only at test time

The public inspection benchmarks are built on one asymmetry: abundant normal images, rare defects. MVTec AD ships “5354 high-resolution color images of different object and texture categories”, divided by MVTec's own dataset page into fifteen object and texture categories. Each category holds “normal, i.e., defect-free images intended for training and images with anomalies intended for testing”. The defects appear only at test time. They “manifest themselves in the form of over 70 different types of defects such as scratches, dents, contaminations, and various structural changes”.

VisA is larger. Released in 2022, it holds “10,821 high-resolution color images (9,621 normal and 1,200 anomalous samples) covering 12 objects in 3 domains”. Defects are 11.1 per cent of the set — eight normal images for every anomalous one, about a hundred defective examples per object. A model that answers “normal” every time scores 89 per cent. That ratio is the problem in miniature, and it is why inspection is judged per-pixel and per-region rather than by accuracy.

The subtler problem is that these benchmarks have already been won. PatchCore's authors reported in 2022: “On the challenging, widely used MVTec AD benchmark PatchCore achieves an image-level anomaly detection AUROC score of up to 99.6%, more than halving the error compared to the next best competitor.” By 2025 MVTec's own successor paper declares the family exhausted. Performance on MVTec AD and VisA “has started to saturate in terms of segmentation AU-PRO, with state-of-the-art models often competing in the range of less than one percentage point”.

A leaderboard where the field competes inside a single percentage point has stopped ranking methods and started ranking noise. Nothing in the 99.6 per cent tells you which of these detectors survives a new lamp, a new lot, or a defect nobody photographed for the test set.

Figure

Answering “normal” every time scores 89 per cent on this split, which is why inspection is judged per-pixel and per-region rather than by accuracy.

Visual

The camera sees process variation as well as defects

A robust inspection system models several sources of change stacked on top of each other: acquisition variation (illumination, focus, exposure, vibration, lens contamination), product variation (colour, lot, supplier, material, orientation, acceptable texture), process state (machine, tool wear, shift, line speed, maintenance event), defect evidence (scratch, crack, missing part, contamination, deformation), and the decision policy on top — accept, rework, stop line, sample review, or investigate.

The first layer of that stack is the one that has now been measured, and it is expensive. MVTec AD 2, published by MVTec in 2025, is a set of eight industrial inspection scenarios built from “more than 8,000 high-resolution images”. Its test splits deliberately contain lighting conditions that are not necessarily present in training. The abstract states the intent plainly: “Additionally, our dataset provides test scenarios with lighting condition changes to assess the robustness of methods under real-world distribution shifts.”

Then comes the number to carry away. State-of-the-art anomaly detection methods — the same families that compete within one percentage point of each other on MVTec AD — score below 60 per cent average AU-PRO on MVTec AD 2. The VAND 3.0 challenge at CVPR 2025, run by Voxel51 with Intel and MVTec, made this its first category: distribution shifts caused by lighting, camera angle and noise.

Acquisition variation is therefore not a preliminary to the modelling work. Moving a lamp costs more performance than any architecture choice in this literature has ever gained.

FigureLayers · 5 layers
  1. 01

    Acquisition variation

    Illumination, focus, exposure, vibration, lens contamination.

  2. 02

    Product variation

    Color, lot, supplier, material, orientation, acceptable texture.

  3. 03

    Process state

    Machine, tool wear, shift, line speed, maintenance event.

  4. 04

    Defect evidence

    Scratch, crack, missing part, contamination, deformation.

  5. 05

    Decision policy

    Accept, rework, stop line, sample review, or investigate.

Analogy

A quality inspector learning the normal hum of a machine

An inspector notices when a machine sounds different from its usual operating range. The change deserves attention. A harmless maintenance adjustment can sound unusual too.

A hum is one signal in time; visual anomalies are spatial and acquisition-dependent. The analogy also breaks in the direction the lighting experiments exposed. A machine does not sound completely different because someone moved a lamp. An inspection camera does see a different image, everywhere at once, for exactly that reason. Deviation detection and defect diagnosis stay separate questions, and the second one needs evidence the score never carried.

Anomaly score and defect severity require different evidence.

Example

False alarms often come from the imaging process

Before changing the neural architecture, inspect these sources. Each one changes the image without changing the product. That is the same kind of shift that separates saturated scores on MVTec AD from below 60 per cent average AU-PRO on MVTec AD 2.

  • Specular shift: a light moves and creates a bright line that looks like a scratch. MVTec AD 2 built exactly this perturbation into its test scenarios, and state-of-the-art methods fall below 60 per cent average AU-PRO there.
  • Focus drift: vibration blurs edges across an entire production run, so the anomaly score rises for every part rather than for a defective one.
  • Fixture change: a clamp or tray appears in a new position and enters the model's notion of normal appearance, without any product having changed.
  • Lot variation: acceptable material texture changes with the supplier. A defect library classifies that change as acceptable; a distance function cannot.
  • Lens contamination: dust creates stationary spots in every frame. A one-class method absorbs them into normality if the reference set is refreshed while the lens is dirty.
  • Background leak: the model keys on conveyor marks associated with past defects, scoring the conveyor rather than the part.

One threshold rarely serves every defect and production mode

A low threshold catches subtle anomalies and increases review or line stoppage. A high threshold reduces false alarms and lets weak defects through. The threshold, not the architecture, is where the model meets the plant's budget.

Benchmark scores cannot choose it for you, and that is now a published finding. Valeo and Intel ran eleven state-of-the-art anomaly detection models across nine datasets and seven metrics in 2025, and concluded: “Our extensive experiments across nine datasets, eleven SOTA models, and seven metrics reveal that current evaluation practices may not reliably predict deployment success, as models with 99.9% image-level AUROC on MVTecAD show significant degradation on real-world data.”

Their remedy is to report an operating point rather than an area under a curve. Presorted Good at 2 per cent — PG2 — is the share of good parts correctly cleared while 2 per cent of bad parts are missed, with its counterpart PB2 beside it. That is a sentence a production manager can price: this many parts skip human review, at this rate of escape. An image-level AUROC of 99.9 per cent is not.

A separate group arrived at the same place from the other side. Real-IAD is a 150,000-image, 30-object multi-view dataset, presented at CVPR 2024. It was built precisely because saturation above 99 per cent AUROC on mainstream datasets such as MVTec had left a significant gap between public datasets and actual application scenarios.

Use severity-aware policies, product variants, operating modes and review capacity. Calibrate thresholds on chronological or lot-based splits that resemble deployment.

Report the operating point, not the curve: how many good parts clear while 2 per cent of bad parts are missed.

Steps

Validate inspection over products, lots, machines, and time

Random image splits can leak nearly identical production conditions, so the plan runs in five moves. Split by production unit rather than by adjacent frames. Test known defects by severity and size, for classification and localisation. Test unknown deviations by holding out defect families or introducing controlled process changes. Audit false alarms for acquisition, acceptable variation and recurring nuisance clusters. And measure operations: review load, escaped defects, rework, downtime and threshold changes.

Steps two and five are not house style. For automated inspection of sterile products they are binding, in EU GMP Annex 1 paragraph 8.32: “Where automated methods of inspection are used, the process should be validated to detect known defects (which may impact product quality or safety) and be equal to, or better than, manual inspection methods. The performance of the equipment should be challenged using representative defects prior to start up and at regular intervals throughout the batch.” Note the shape of that sentence. Validation is periodic and adversarial — representative defects presented again during the batch, not an acceptance test signed once. And the bar is manual inspection, not a leaderboard. Paragraph 8.31 governs the acquisition side of manual inspection, requiring “suitable and controlled conditions of illumination and background” at qualified inspection rates.

Step two cannot end in a yes or a no, and FDA's draft guidance explains why in a footnote: “Visual detection of a particulate is a probabilistic process that depends on, among other things, the product and the size and shape of the particulate”. The guidance therefore asks for operating characteristic curves for each defect classification, alongside accept and reject criteria, an AQL and a rejectable quality limit. One curve per defect class, showing detection as a function of how bad the defect is. That is what step five's cost accounting looks like once it reaches a plant, and it is the same object as the operating-point metrics the Valeo and Intel team asked researchers to publish.

FigureProcess · 5 steps
  1. 1. Split by production unit

    Separate lots, runs, machines, or time windows instead of adjacent frames.

  2. 2. Test known defects

    Measure class and localization performance by severity and size.

  3. 3. Test unknown deviations

    Hold out defect families or introduce controlled process changes.

  4. 4. Audit false alarms

    Review acquisition, acceptable variation, and recurring nuisance clusters.

  5. 5. Measure operations

    Track review load, escaped defects, rework, downtime, and threshold changes.

Key idea

The normal training set may already contain defects

One-class methods assume their reference data represents acceptable production. Hidden defects, mixed product variants or mislabelled rework teach the model to accept failures. The ICML 2022 paper on Latent Outlier Exposure opens with the flat version of this: “A common assumption is that clean training data (free of anomalies) is available, which is often violated in practice.”

The cost has been measured rather than feared. SoftPatch, at NeurIPS 2022, injected anomalous images into the MVTec AD training folders at ratios from 0 to 15 per cent, then watched what happened to a detector that assumes they are not there. Under the no-overlap setting, PatchCore loses up to 3.7 percentage points of pixel-level AUROC as the injected-noise ratio increases. That is the same PatchCore that reported up to 99.6 per cent image-level AUROC on the clean version of the benchmark.

So the reference set is a curated object with provenance, not a folder. Use sampling plans, expert review, clustering and iterative cleanup. Record why each example was admitted into the normal reference set. That record is what Annex 1's defect library, maintained and used to train the people who inspect, already is on the manual side.

Normality is a curated operational standard, not merely the majority of images.

Example

Practice: design inspection for molded plastic seals

A line produces many acceptable texture variants and very few examples of leakage-causing microcracks. Design the system the way the evidence above forces you to: a taxonomy before a threshold, an operating point before an AUROC, and a reference set whose contents you can account for.

  • Define product, lot, machine and time groups for splitting, and write down which lighting and fixture states each group contains — the shift that pushed state-of-the-art methods below 60 per cent average AU-PRO on MVTec AD 2.
  • Choose a supervised, one-class, synthetic or hybrid strategy and justify it. If you choose synthetic defects, say what DRÆM's authors say: the simulation generates just-out-of-distribution appearances rather than realistic ones. Then validate on real microcracks you did not generate.
  • List acquisition controls for illumination, focus and fixture alignment. Re-challenge the installed system with representative defects before start-up and at regular intervals throughout the batch, as Annex 1 paragraph 8.32 requires of regulated lines.
  • Set separate policies for cosmetic anomalies and leakage risk. Determine criticality from risk and historical knowledge rather than from the score distribution, and give critical defects an escalation path.
  • Create a review loop that turns recurring false alarms into data improvements. Report it as an operating point — good seals cleared at the missed-defect rate you agreed to tolerate — plus escaped defects, rework and downtime, not as an image-level AUROC.

Key takeaways