How to automate factory defect inspection with Anomalib
ML6 detailed how to use the open-source library Anomalib for automated visual inspection in manufacturing. Using a student-teacher setup, the model trains strictly on defect-free nominal images to pinpoint anomalies at the pixel level. Exporting to Intel's OpenVINO increased CPU inference speed by nearly 4x to 30.2 fps.

Anomalib is an open-source deep learning library built specifically for industrial anomaly detection, letting teams build automated visual quality control pipelines with minimal labeling overhead.
In manufacturing inspection, collecting defective samples is always a major bottleneck. Defect varieties are endless, while actual faulty parts are rare. Anomalib tackles this using a one-class learning approach that trains exclusively on defect-free nominal images.
Spotting flaws with nominals only
The setup relies on a student-teacher pyramid architecture. The teacher model is a ResNet18 pre-trained on ImageNet, while the student model is another ResNet18 initialized randomly.
During inference, the framework evaluates the difference between features produced by the student and the teacher. This difference scores the probability of an anomaly at the pixel level, pinpointing both the exact location and scale of any flaw on the product.
Benchmarks and the OpenVINO speedup
ML6 tested the implementation across 7 categories of the MVTec anomaly detection benchmark. Images were set to a 244x244 resolution with default hyperparameters.
The test ran on modest hardware: an AWS EC2 t3.xlarge instance equipped with 4 Intel Xeon Platinum 8175M vCPUs @ 2.50GHz and 8GB of RAM, without any dedicated GPU.
The model delivered standout detection scores, reaching a perfect score in the leather category. For inference speed, running plain PyTorch on a CPU can be sluggish. By exporting the bottle model to Intel's OpenVINO framework, throughput jumped to roughly 30.2 fps, marking a nearly 4x speedup over the standard PyTorch implementation.
Developers can grab Anomalib directly on GitHub, where it ships with algorithms, benchmarking utilities, and export tools ready out of the box.
Why it matters
This workflow hits the sweet spot for factory floors and edge developers. You bypass the painful process of collecting and labeling rare defects, and OpenVINO allows real-time 30 fps speeds on ordinary enterprise CPUs without costly GPUs.
Keep in mind that one-class architectures are sensitive to domain drift. If nominal training data gets contaminated with subtle flaws or factory lighting fluctuates, false alarm rates can creep up. Thorough threshold tuning on real production lines is still essential before going live.
Sources (2)
- medium.com(opens in a new tab)Originalmedium.com
- @ml6team(opens in a new tab)Discussionx.com