Unsupervised Visual Anomaly Detection for Manufacturing: PatchCore, PaDiM, EfficientAD and Anomalib in Production (2026)

Unsupervised Visual Anomaly Detection for Manufacturing: PatchCore, PaDiM, EfficientAD and Anomalib in Production (2026)

Unsupervised Visual Anomaly Detection for Manufacturing: PatchCore, PaDiM, EfficientAD and Anomalib in Production (2026)

Most factories cannot train a defect detector the textbook way, because they do not have the defects. A well-run line might produce a cracked housing once in ten thousand parts, and each new failure mode looks different from the last. Visual anomaly detection manufacturing teams therefore flip the problem: learn what a good part looks like from a few hundred defect-free images, then flag anything that does not fit. Methods such as PatchCore, PaDiM and EfficientAD now score near the ceiling of the MVTec AD benchmark, and Intel’s open-source Anomalib library packages them with OpenVINO export. Yet benchmark AUROC says almost nothing about the two numbers a plant manager cares about: how many good parts you scrap, and how many bad parts you ship. This guide closes that gap. You will leave with the mechanism behind each method, worked memory and latency math for edge hardware, a threshold procedure that works on good-only data, and a line integration pattern that survives real lighting.

What this covers: why unsupervised defect detection wins on rare defects, how PatchCore, PaDiM, EfficientAD and normalizing flows work, coreset math, metrics that matter, threshold calibration, Anomalib training and OpenVINO deployment code, PLC and MES integration, drift and lighting failure modes, and a decision table.

Context and Background

Industrial visual inspection has three established families. Rule-based machine vision measures edges, blobs and gauge dimensions with hand-tuned tools. Supervised deep learning trains classifiers, detectors or segmenters on labelled defect images. Unsupervised anomaly detection, the subject here, trains only on normal images and scores deviation. Our earlier piece on industrial machine vision defect detection with edge AI covers the supervised route and the camera stack in depth. This article deliberately stays on the good-only side and on what it takes to run it on a line.

The field coalesced around one dataset. Bergmann, Fauser, Sattlegger and Steger of MVTec Software published MVTec AD at CVPR 2019. It holds 5,354 high-resolution colour images across 15 categories: five textures (carpet, grid, leather, tile, wood) and ten objects such as bottle, screw and transistor. Training images contain only defect-free samples, and the test set covers 73 defect types with 1,888 pixel-precise annotated regions. That design made the MVTec AD benchmark the common yardstick for unsupervised defect detection.

Amazon’s VisA dataset, released with the SPot-the-Difference paper at ECCV 2022, added harder scenes: 10,821 images (9,621 normal, 1,200 anomalous) across 12 subsets, including four PCB types and several multi-instance objects such as candles and capsules. In 2025 MVTec released MVTec AD 2 (Heckler-Kram, Neudeck, Scheler, König and Steger), with more than 8,000 high-resolution images across eight scenarios. It targets transparent and overlapping objects, dark-field and back-light illumination, high variance in normal data and extremely small defects. Its test sets also include lighting changes, and the authors report that state-of-the-art methods stay below 60% average AU-PRO. That one sentence is the most honest summary of where the field stands: near-solved on the 2019 benchmark, far from solved on conditions that resemble a real plant.

On the tooling side, Anomalib has become the default open-source library. It now lives under Intel’s Open Edge Platform organisation on GitHub, and version 2.7.0 shipped on PyPI on 6 October 2026, requiring Python 3.10 or later.

How Visual Anomaly Detection in Manufacturing Works: A Reference Architecture

Visual anomaly detection in manufacturing learns a model of normal appearance from defect-free images only, then scores each new image by how far its local features deviate from that model. High-scoring regions form a heatmap; the maximum score is compared against a calibrated threshold to accept or reject the part. No defect labels are needed to train.

Almost every high-performing method today shares the same skeleton. A convolutional or transformer backbone pretrained on ImageNet turns each image into a grid of feature vectors, one per patch. A density model, a memory bank or a student network then learns what normal patches look like. At inference the per-patch deviation becomes the anomaly map, and the image score is usually its maximum. The methods differ mainly in the middle box, and that choice drives memory, latency and accuracy.

Visual anomaly detection manufacturing pipeline using PatchCore memory bank and coreset subsampling

Figure 1: PatchCore pipeline. Good images pass through a frozen backbone; locally pooled patch features fill a memory bank that greedy coreset sampling shrinks; test patches are scored by nearest-neighbour distance.

The diagram shows two paths through the same frozen backbone. The training path, along the top, extracts mid-level features from good images, pools each patch with its 3×3 neighbourhood, stores every vector in a memory bank, and then reduces that bank with greedy coreset sampling. The inference path sends a test image through the identical backbone and searches the coreset for each patch’s nearest neighbour. Those distances form the anomaly map, and the largest one becomes the image-level score.

Why good-only training is the right default

Supervised detectors need examples of every defect class, in roughly balanced numbers, captured under production lighting. On a mature line, that requirement is close to impossible. A defect rate of 500 parts per million means you inspect 2,000 parts to see one bad one, and that one is a single example of a single failure mode. Collecting 200 examples per class across eight classes would take months, and the ninth failure mode, the one nobody has seen yet, would still slip past.

Good-only methods turn that economics around. A day of production yields thousands of normal images. The model needs no idea what a crack looks like, only that this texture has never appeared on a good part. That is why the approach handles novel defects, and also why it struggles with one thing: a defect that looks locally normal. A missing screw on an otherwise perfect assembly is the classic example, which the field calls a logical anomaly.

PaDiM: one Gaussian per pixel position

PaDiM, by Defard, Setkov, Loesch and Audigier of CEA List (arXiv 2011.08785, ICPR 2020 workshops), models each patch position with its own multivariate Gaussian. It concatenates features from the first three stages of a pretrained backbone, randomly keeps a subset of channels, and fits a mean and covariance at every spatial location across the training images. A covariance regulariser of 0.01 times the identity keeps the matrices invertible. The anomaly score at each location is the Mahalanobis distance of the test patch to that location’s Gaussian.

The mechanism has a useful property and a costly one. The useful property is that memory does not grow with the training set; a thousand images cost the same as a hundred. The costly property is that memory grows with resolution and the square of feature dimension. For a 224 x 224 input, the first stage of a ResNet gives a 56 x 56 grid, so there are 3,136 positions. With the paper’s Wide ResNet-50 setting of 550 kept dimensions, each covariance is 550 x 550 floats. That is 3,136 x 302,500 x 4 bytes, about 3.8 GB, which matches the 3.8 GB the authors report in their memory table. The ResNet-18 variant with 100 dimensions needs about 0.17 GB.

The paper reports 95.3% image AUROC, 97.5% pixel AUROC and 92.1 PRO on MVTec AD for the Wide ResNet-50 variant. PaDiM also assumes good parts are spatially aligned, because each position has its own statistics. A part that drifts 20 pixels on the fixture lands features at the wrong Gaussian and inflates scores everywhere.

PatchCore: a memory bank you can shrink

PatchCore, by Roth, Pemula, Zepeda, Schölkopf, Brox and Gehler (CVPR 2022), drops the per-position assumption. It takes features from blocks 2 and 3 of a Wide ResNet-50, pools each with its neighbourhood (patch size p = 3), and stores every patch vector from every good image in one shared memory bank. Because the bank is position-free, a good patch at any location can explain a test patch anywhere. That makes PatchCore far more tolerant of small misalignment than PaDiM.

The raw bank is large, so PatchCore subsamples it with a greedy coreset. The algorithm approximates a minimax facility-location objective: repeatedly add the bank vector that is farthest from the current coreset. That keeps rare but legitimate normal patterns, which random sampling would discard. To make the distance computations cheap, the selection runs in a randomly projected lower-dimensional space, justified by the Johnson-Lindenstrauss lemma.

At inference each test patch finds its nearest coreset neighbour, and the image score is the largest such distance. PatchCore then reweights that maximum by how isolated the matched memory vector is among its own neighbours. Segmentation maps are bilinearly upsampled and smoothed with a Gaussian of sigma 4. The authors report image AUROC of 99.1%, 99.0% and 99.0% on MVTec AD for 25%, 10% and 1% coresets, pixel AUROC around 98.1%, and PRO around 93.4. The often-quoted 99.6% comes from an ensemble of three backbones at 320-pixel input, not from the default model.

EfficientAD: a student that cannot fake anomalies

EfficientAD, by Batzner, Heckler and König (WACV 2024), was built for speed. Its feature extractor, the patch description network, is a four-layer CNN with a 33 x 33 pixel receptive field and 384 output channels. A teacher version is distilled from the Wide ResNet-101 features PatchCore uses. A student with the same architecture then learns to predict the teacher’s outputs on good images only. Where the student fails to predict the teacher, something is anomalous.

Two training tricks make that discrepancy reliable. A hard-feature loss backpropagates only the worst-predicted outputs, with a mining factor of 0.999. A penalty on random ImageNet images stops the student from generalising to imitate the teacher on things it never saw. A small autoencoder runs alongside to catch logical anomalies by reasoning over the whole image. Both maps are normalised using quantiles (0.9 and 0.995) computed on validation images.

The paper reports image AUROC of 98.8% for EfficientAD-S and 99.1% for EfficientAD-M on MVTec AD, with 2.2 ms and 4.5 ms latency at batch size 1 on an NVIDIA RTX A6000. That latency includes the CPU-to-GPU transfer and uses float16. On MVTec LOCO, which focuses on logical anomalies, the S variant reports 85.8 for logical and 94.1 for structural anomalies, which shows both the autoencoder’s value and its limits.

Normalizing flows: FastFlow and CFlow

A fourth family fits an invertible network that maps normal features to a standard Gaussian, so the likelihood of a test feature becomes the anomaly score. FastFlow by Yu and colleagues (arXiv 2111.07677) applies 2D flows directly on feature maps and reports 99.4% image AUROC and 98.5% pixel AUROC on MVTec AD with a CaiT-M48 transformer backbone. CFlow-AD by Gudovskiy, Ishizaka and Kozuka (WACV 2022) uses conditional flows with positional encoding. Flows are compact at inference, but training is less forgiving than PatchCore’s single pass, and their headline numbers depend heavily on large backbones that eat the edge budget.

Edge Sizing: Worked Memory and Latency Math

Benchmark tables rarely tell you whether a model fits a fanless box beside the conveyor. The arithmetic below uses PatchCore because its cost depends on choices you control. Every figure in this section is illustrative, derived from first principles with stated assumptions, not a measured benchmark.

Memory bank size

Assume a 224 x 224 input and features from blocks 2 and 3 of a Wide ResNet-50, which give a 28 x 28 patch grid after the block-3 map is upsampled. That is 784 patches per image. Assume each patch vector has 1,536 dimensions, the concatenated channel count of those two blocks; some implementations project this down, so check your configuration.

Train on 200 good images and the full bank holds 200 x 784 = 156,800 vectors. In float32 that is 156,800 x 1,536 x 4 bytes, about 963 MB. A 10% coreset keeps 15,680 vectors, about 96 MB. A 1% coreset keeps 1,568 vectors, about 9.6 MB. Storing the bank in float16 halves each figure, and the PatchCore paper shows accuracy barely moves between 10% and 1% on MVTec AD.

Nearest-neighbour compute

Each test image issues 784 queries against the coreset. With a 10% coreset, an exact search costs 784 x 15,680 x 1,536 multiply-accumulates, about 18.9 billion. A Wide ResNet-50 forward pass at 224 pixels is commonly cited at roughly 11 GFLOPs, so the search alone can cost more than the backbone. At a 1% coreset the search drops to about 1.9 billion multiply-accumulates, well below the backbone.

This is the single most useful lever on an edge device. The coreset ratio is a latency dial, not just a memory dial. The paper’s own GPU timings show the same direction: 0.6 s per image with the full bank, 0.22 s at 10% and 0.17 s at 1%, including the backbone.

Training cost of the coreset

Greedy selection is not free. Each of k iterations computes distances from all N bank vectors to the newest coreset member, so cost is roughly N x k x d’, where d’ is the projected dimension. With N = 156,800, k = 15,680 and an illustrative d’ of 128, that is about 315 billion operations. On a laptop GPU that is seconds; on an embedded ARM CPU it can be many minutes. Plan to fit on a workstation and ship the bank, not to rebuild it on the line controller.

Line-rate budget

Now map that to a line. Assume a conveyor at 0.5 m/s and parts pitched 0.25 m apart, giving two parts per second. The inference node has 500 ms per part on average, which sounds generous. However, the camera exposure, image transfer over GigE Vision, preprocessing and result transmission all share that window, and jitter matters more than the mean. If the reject gate sits 0.6 m downstream of the camera, the decision must arrive within 1.2 s of the trigger every time, including the 99.9th percentile.

That latency profile favours EfficientAD or a 1% PatchCore on modest hardware. A full-bank PatchCore on a CPU-only box is where projects quietly fail. For a deeper comparison of accelerators, see our analysis of FPGA vs GPU vs NPU for industrial machine vision inference.

Metrics That Matter on a Line

Image AUROC is the area under the ROC curve for the image-level score. It measures ranking quality across every possible threshold. A 99% AUROC means a random defective image outscores a random good image 99% of the time. It does not tell you the false reject rate at the threshold you will actually ship.

Pixel AUROC does the same per pixel, and it is inflated by design. Defect pixels are a tiny fraction of each image, so a method can paint broad blobs and still score well because nearly all pixels are true negatives. That is why Bergmann and colleagues introduced the per-region overlap metric, PRO. PRO averages overlap per connected defect region, so small scratches count as much as large stains, and it integrates only up to a 30% false positive rate. MVTec AD 2 reports AU-PRO for this reason.

For production, the decision metric is a pair: the false reject rate on good parts and the escape rate on defective parts, both at one fixed threshold. F1 at a threshold combines precision and recall into one number, which is useful for comparing models but hides the asymmetry. Shipping a defect to an automotive customer can cost a containment action; scrapping a good bracket costs cents. Your threshold should reflect that asymmetry explicitly.

Here is why it matters numerically. At two parts per second over an eight-hour shift, a line inspects 57,600 parts. A 1% false reject rate sends 576 good parts per shift to the rework bin. Operators will bypass a system that does that within a week. A model with 99% image AUROC can easily sit at that operating point.

Threshold Selection with Good-Only Data

The threshold is where unsupervised methods meet production reality, and it is where most pilots stall. You cannot pick it on the defect data you do not have. You can, however, control the false reject rate rigorously using only good parts.

Threshold calibration workflow for unsupervised defect detection on good-only data

Figure 2: Calibration workflow. Good images split into training and calibration sets; a conformal quantile of calibration scores sets the threshold for a target false reject rate; a small defect set estimates escape rate.

The flow separates two questions. The calibration branch answers “how often will a good part be rejected” using only held-out good images, which you have in abundance. The defect branch, fed by whatever real or seeded defects you can gather, answers “how often will a bad part pass” at that same threshold. Only when both answers are acceptable does the threshold go to the line.

Conformal quantile for false reject rate

Split your good images: one part fits the model, a disjoint calibration part is only scored. Sort the n calibration scores ascending. For a target false reject rate alpha, set the threshold to the score at rank ceil((n + 1) x (1 – alpha)). Under exchangeability, the split-conformal guarantee says a new good part exceeds that threshold with probability at most alpha. Our guide to conformal prediction and coverage guarantees explains the proof and its assumptions.

Worked example: with n = 199 calibration images and alpha = 0.01, the rank is ceil(200 x 0.99) = 198. The threshold is the second-highest calibration score. With fewer than 99 calibration images, no rank satisfies a 1% target, which is a useful sanity rule: you need at least 1 / alpha calibration images. For a 0.1% target you need roughly a thousand good images held out, not a hundred.

The guarantee is marginal and depends on exchangeability. If the calibration images all came from one morning, one batch of material and one lamp temperature, the line’s afternoon output is not exchangeable with them. Collect calibration images across shifts, material lots and operators. That single change usually matters more than swapping models.

Estimating escape rate without many defects

The false reject guarantee says nothing about escapes. You still need defective examples, but you need far fewer than supervised training would. Pull every scrapped part from the quality lab for a few weeks. Where that is too slow, seed defects deliberately: scratch, dent or contaminate good parts, and label them. Synthetic pasting of defect textures helps for coverage testing, but treat its escape estimate as optimistic.

With 50 defects and zero escapes, the one-sided 95% upper bound on the true escape rate is still about 6% by the rule of three (3 / 50). That is sobering, and it is honest. It tells you whether to tighten the threshold, add a second camera angle, or move a defect class to a supervised detector.

Training and Deploying with Anomalib

Anomalib wraps all four method families behind a common Lightning-based Engine, data modules for MVTec-style and custom folders, and export to ONNX and OpenVINO IR. The code below follows the documented 2.x API. Argument names have shifted between major versions, so pin your version and check the reference docs for it.

The folder layout is simple: a directory of good images, and optionally a directory of known defects for testing. Keep the calibration images in a separate folder that the training job never sees.

# pip install "anomalib[openvino]"   # pin the exact version you validated
from anomalib.data import Folder
from anomalib.models import Patchcore
from anomalib.engine import Engine
from anomalib.deploy import ExportType

datamodule = Folder(
    name="bracket_cam1",
    root="./datasets/bracket_cam1",
    normal_dir="good",        # defect-free training images
    abnormal_dir="defect",    # optional: real or seeded defects, test only
)

model = Patchcore(
    backbone="wide_resnet50_2",
    layers=("layer2", "layer3"),
    coreset_sampling_ratio=0.01,   # latency dial, see sizing section
    num_neighbors=9,
)

engine = Engine()
engine.fit(datamodule=datamodule, model=model)
results = engine.test(datamodule=datamodule, model=model)
print(results)

# Export to OpenVINO IR for CPU, iGPU or NPU inference
engine.export(model=model, export_type=ExportType.OPENVINO)

The test step reports image and pixel metrics when an abnormal folder exists. Treat those as a sanity check, not as your operating point. Then calibrate the threshold yourself on held-out good images, using the exported model so you calibrate exactly what you deploy.

import math
from pathlib import Path
import numpy as np
from anomalib.deploy import OpenVINOInferencer

inferencer = OpenVINOInferencer(path="results/Patchcore/bracket_cam1/latest/weights/openvino/model.xml",
                                device="CPU")

def score(path: Path) -> float:
    pred = inferencer.predict(image=str(path))
    return float(np.asarray(pred.pred_score).ravel()[0])

calib = sorted(Path("./datasets/bracket_cam1/calib_good").glob("*.png"))
scores = np.sort([score(p) for p in calib])

alpha = 0.01                         # target false reject rate
n = len(scores)
rank = math.ceil((n + 1) * (1 - alpha))
if rank > n:
    raise ValueError(f"Need at least {math.ceil(1/alpha) - 1} calibration images for alpha={alpha}")
threshold = scores[rank - 1]
print(f"n={n} rank={rank} threshold={threshold:.4f}")

# Escape check on labelled defects
defects = sorted(Path("./datasets/bracket_cam1/defect").glob("*.png"))
escapes = sum(score(p) <= threshold for p in defects)
print(f"escapes {escapes}/{len(defects)}  rule-of-three upper bound ~{3/max(len(defects),1):.1%} if zero")

Two details deserve attention. Anomalib normalises scores by default, so the threshold it learns internally may not match yours; use the raw or normalised score consistently and record which. The exported path above is illustrative; your run directory structure depends on version and configuration. OpenVINO can target Intel CPUs, integrated GPUs and NPUs from the same IR, which our note on OpenVINO 2026.4 changes covers in more detail.

Anomalib 2.7.0 removed the legacy ONNX exporter in favour of the PyTorch dynamo path, according to its PyPI release notes. If your deployment target consumes ONNX, re-validate the exported graph against the PyTorch model on your calibration set before trusting it. A changed exporter can shift scores slightly, and a shifted score distribution invalidates a calibrated threshold.

Line Integration: Trigger, Verdict, Reject, Record

A model is not an inspection system. The system is the chain from the part arriving to the reject gate firing and the record landing in the MES, and each link has its own timing and failure modes.

Line integration sequence for visual anomaly detection in manufacturing with PLC trigger, camera, inference node, reject gate and MES

Figure 3: Line integration sequence. The PLC triggers the camera with a part ID, the inference node returns a verdict for that ID, a shift register tracks the part to the reject gate, and both sides log to the MES.

The sequence keeps the PLC as the authority over physical action. The inference node never fires the gate directly. It returns a verdict tagged with the part ID, and the PLC’s encoder-driven shift register decides when that part reaches the gate. Asynchronous messages to the MES carry the evidence: score, heatmap reference and model version.

Triggering and image acquisition

Use a hardware trigger from a photo eye or encoder position, not a free-running camera with software selection. Hardware triggering pins exposure to part position and makes timing deterministic. GenICam-compliant cameras over GigE Vision or USB3 Vision expose trigger, exposure and strobe control in a standard way. Synchronise a strobed LED with the exposure; it freezes motion and swamps ambient light, which is the cheapest drift protection you will ever buy.

Pass a part identifier with the trigger. The simplest form is a counter the PLC increments and the inference node echoes back. Without it, a single dropped frame shifts every subsequent verdict onto the wrong part, and the line rejects good parts while passing the defective one.

Verdict path and fail-safe behaviour

Return the verdict over a deterministic channel the PLC already trusts: digital I/O for the simplest cells, or a fieldbus such as PROFINET or EtherNet/IP for richer data. OPC UA suits the metadata path to supervisory systems. Define what happens when no verdict arrives in time. On most safety-relevant lines, a missing verdict must mean reject, so that a crashed inference process fails closed.

Add a gate-confirmation sensor. Without it, a jammed pneumatic gate silently passes everything, and the logs claim every defect was rejected.

Logging for traceability and retraining

Log every inspection, not only rejects: part ID, timestamp, score, verdict, threshold, model version, camera ID and a pointer to the stored image. Keep full images for rejects and a sampled fraction of passes. Those passes are tomorrow’s calibration set and your evidence when a customer complaint arrives. Link records to the MES lot or serial so quality engineers can trace a field failure back to the image the system saw.

Trade-offs, Gotchas, and What Goes Wrong

The failure modes of unsupervised inspection are predictable, which means they are preventable. Most come from treating “normal” as fixed when production keeps redefining it.

Drift and lighting failure-mode decision flow for visual anomaly detection in manufacturing

Figure 4: Drift response flow. Rolling score statistics on passed parts trigger a golden-sample check; the outcome routes to an optics fix, a threshold recalibration, or a memory-bank rebuild before shadow deployment.

The flow starts from a signal you get for free: the score distribution of parts that pass. When its median or the reject rate shifts, a golden sample, a known-good part kept at the station, separates hardware problems from genuine process change. Hardware problems go to optics and lighting. Process change goes to recalibration or retraining, and every new model runs in shadow before promotion.

Lighting drift is the top failure mode. LED output decays with hours and temperature, ambient light changes with skylights and shifts, and a technician may bump a diffuser. Feature-based methods respond to global intensity shifts with raised scores across the whole image. The result looks like a sudden epidemic of defects. MVTec AD 2 includes lighting changes in its test sets precisely because benchmarks without them overstate robustness.

New material lots look like anomalies. A supplier change can alter surface texture or colour within specification. The model has never seen that texture, so it flags it. This is the system working as designed, and it is also why a quality engineer must own the decision to add new normal images. Our guide to ML model monitoring for data and concept drift covers PSI and KS tests you can apply to score distributions.

Contaminated training data silently lowers sensitivity. If 1% of “good” training images contain a subtle defect, PatchCore’s memory bank happily stores those defect patches as normal. Future instances of that defect will score low. Coreset selection makes this worse, because it deliberately keeps rare patches. Have a person review the training set, or train once and inspect the highest-scoring training images, which is a cheap self-audit.

Logical anomalies escape local methods. A missing component, a swapped label or a reversed connector can consist entirely of normal-looking patches. PatchCore and PaDiM will usually miss them. EfficientAD’s autoencoder helps, as its MVTec LOCO numbers show, but for assembly verification a rule-based presence check or a supervised detector is often cleaner.

Resolution versus defect size. At 224 pixels, a 2 mm scratch on a 200 mm part covers about two pixels and vanishes inside a 3×3 patch neighbourhood. Tiling the image, raising input resolution or narrowing the camera’s field of view fixes this, but every option multiplies memory and latency. Do the sizing math before buying cameras.

Zero-shot models are not yet a substitute. CLIP-based methods promise inspection without any training images. WinCLIP (CVPR 2023) reports 91.8% zero-shot image AUROC on MVTec AD and 78.1% on VisA; AnomalyCLIP (ICLR 2024) reports 91.5% and 82.1%. Those numbers are impressive for zero training, and useful for triage or bootstrapping. They remain well below the 98 to 99% that good-only methods reach with a few hundred images, and an escape rate several times higher is rarely acceptable.

Decision Table: Which Method for Which Line

The table summarises paper-reported MVTec AD image AUROC and the qualitative trade-offs from the mechanisms above. Numbers come from each method’s original paper under its own protocol, so treat small differences as noise rather than ranking.

Method MVTec AD image AUROC (paper) Inference cost driver Alignment tolerance Best fit
PaDiM, WRN50 95.3% Per-position covariances, up to GB scale Low; needs fixtured parts Tightly fixtured parts, fast setup, CPU-only cells
PatchCore, 1 to 10% coreset 99.0 to 99.1% Nearest-neighbour search over coreset Moderate General first choice, strong localisation, few hundred images
EfficientAD-S / M 98.8% / 99.1% Small CNN, about 2 to 5 ms on a workstation GPU Moderate High line rate, edge GPUs and NPUs, some logical anomalies
FastFlow, CaiT backbone 99.4% Large transformer backbone plus flow Moderate Accuracy-first stations with GPU budget
WinCLIP / AnomalyCLIP zero-shot 91.8% / 91.5% Large vision-language encoder High Triage, new product introduction before data exists
Supervised detector Not comparable Detector size High Known, recurring defect classes with labels

A practical pattern is to combine rows rather than pick one. Many lines run PatchCore or EfficientAD as a catch-all novelty gate and a supervised detector for the three or four defect classes that dominate scrap. The anomaly model catches what nobody has labelled yet; the detector gives operators a defect name and a cause.

Practical Recommendations

Start with the optics, not the model. Fixed mounts, a strobed light source, a shroud against ambient light and a repeatable fixture will improve every method more than any architecture change. Then pick PatchCore with a small coreset as the baseline, because it trains in a single pass, needs no hyperparameter search to be competitive, and localises defects well enough for operator trust. Move to EfficientAD when the line rate or the hardware budget demands millisecond inference.

Treat the threshold as a governed artefact. Calibrate it on held-out good images collected across shifts and lots, record the target false reject rate, and version it alongside the model. Estimate escape rate on real or seeded defects and report its upper bound, not just the point estimate. When the plant asks why a part was rejected, show the heatmap and the threshold that produced the decision.

Finally, plan operations before launch. Decide who approves new normal images, how often the golden sample runs, and which score shift triggers recalibration. Run every new model in shadow mode against the current one for at least a shift. Our article on edge MLOps pipelines for industrial IoT covers the deployment mechanics.

A short checklist before go-live:

  • Hardware trigger with part ID echo, strobed lighting and a shroud are in place.
  • Training images are human-reviewed and span shifts, lots and operators.
  • At least 1 / alpha held-out good images set the threshold for the target false reject rate.
  • Escape rate and its upper bound are measured on real or seeded defects.
  • A missing verdict fails closed, and a gate sensor confirms each reject.
  • Every inspection logs score, threshold, model version and an image reference to the MES.
  • Golden-sample checks and score-drift alerts run every shift.

Frequently Asked Questions

What is unsupervised visual anomaly detection in manufacturing?

It is a family of methods that learn the appearance of defect-free parts from normal images alone and flag anything that deviates. A pretrained backbone extracts patch features; a memory bank, Gaussian model or student network represents normal patches; and the deviation per patch becomes a heatmap. Because no defect labels are needed, these methods catch novel defect types and suit lines where defects are rare, varied and expensive to collect. The trade-off is weaker performance on logical anomalies, such as missing components.

How many good images does PatchCore need?

PatchCore is designed to work from a few hundred good images, and MVTec AD categories train on a few hundred each. More useful than a raw count is diversity: collect images across shifts, material lots, operators and lighting states, because the model can only treat as normal what it has seen. You also need a separate held-out set for threshold calibration, at least 1 divided by your target false reject rate. A 1% target therefore needs about 100 extra good images; 0.1% needs about 1,000.

Is PatchCore or EfficientAD better for edge deployment?

EfficientAD is usually the better fit when latency is tight, because inference is a small CNN forward pass with no nearest-neighbour search. Its paper reports 2.2 ms per image for the small variant on a workstation GPU. PatchCore can match it on accuracy and often localises defects more cleanly, but its search cost scales with coreset size. With a 1% coreset and an accelerator, PatchCore is viable on many edge boxes. Size both against your actual line rate and hardware before deciding.

What does a 99% AUROC on the MVTec AD benchmark mean for my line?

It means the model ranks a random defective test image above a random good one 99% of the time on that dataset. It does not give your false reject rate or escape rate at any specific threshold. MVTec AD also uses controlled lighting and well-centred parts. On MVTec AD 2, which adds lighting changes and harder materials, the authors report state-of-the-art methods below 60% average AU-PRO. Always measure your own operating point on your own parts.

Can Anomalib models run on CPUs without a GPU?

Yes. Anomalib exports most models to OpenVINO intermediate representation, which runs on Intel CPUs, integrated GPUs and NPUs. PaDiM and PatchCore with a small coreset often run acceptably on a modern CPU at modest line rates. Whether that is fast enough depends on resolution, coreset size and throughput, so benchmark the exported model on the target box under load. Always calibrate the threshold on the exported model, since export can shift scores slightly.

Do zero-shot CLIP-based methods replace training on good images?

Not yet for most production lines. WinCLIP reports 91.8% zero-shot image AUROC on MVTec AD and AnomalyCLIP reports 91.5%. That is remarkable without any training images, and useful during new product introduction or for triage. Good-only methods trained on a few hundred images reach roughly 98 to 99% on the same benchmark, which translates to far fewer escapes. A sensible pattern is to start zero-shot while collecting good images, then switch.

Further Reading

References

  1. Bergmann, P., Fauser, M., Sattlegger, D., Steger, C. “MVTec AD: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection.” CVPR 2019. https://openaccess.thecvf.com/content_CVPR_2019/papers/Bergmann_MVTec_AD_–_A_Comprehensive_Real-World_Dataset_for_Unsupervised_Anomaly_CVPR_2019_paper.pdf
  2. Heckler-Kram, L., Neudeck, J.-H., Scheler, U., König, R., Steger, C. “The MVTec AD 2 Dataset: Advanced Scenarios for Unsupervised Anomaly Detection.” arXiv 2503.21622, 2025. https://arxiv.org/abs/2503.21622
  3. Zou, Y., Jeong, J., Pemula, L., Zhang, D., Dabeer, O. “SPot-the-Difference Self-Supervised Pre-training for Anomaly Detection and Segmentation” (VisA dataset). ECCV 2022. https://github.com/amazon-science/spot-diff
  4. Defard, T., Setkov, A., Loesch, A., Audigier, R. “PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.” arXiv 2011.08785. https://arxiv.org/abs/2011.08785
  5. Roth, K., Pemula, L., Zepeda, J., Schölkopf, B., Brox, T., Gehler, P. “Towards Total Recall in Industrial Anomaly Detection.” CVPR 2022. https://arxiv.org/abs/2106.08265
  6. Batzner, K., Heckler, L., König, R. “EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies.” WACV 2024. https://arxiv.org/abs/2303.14535
  7. Yu, J. et al. “FastFlow: Unsupervised Anomaly Detection and Localization via 2D Normalizing Flows.” arXiv 2111.07677. https://arxiv.org/abs/2111.07677
  8. Gudovskiy, D., Ishizaka, S., Kozuka, K. “CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows.” WACV 2022.
  9. Jeong, J. et al. “WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation.” CVPR 2023. https://arxiv.org/abs/2303.14814
  10. Zhou, Q., Pang, G., Tian, Y., He, S., Chen, J. “AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection.” ICLR 2024. https://arxiv.org/abs/2310.18961
  11. Anomalib on PyPI (version 2.7.0, 6 October 2026) and GitHub. https://pypi.org/project/anomalib/ and https://github.com/open-edge-platform/anomalib

By Riju — about

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *