Industrial anomaly detection (AD) is a critical task for automated quality control, yet it faces a persistent hurdle: the "bias" inherent in general-purpose AI models. Most state-of-the-art methods rely on feature extractors pre-trained on natural images (like ImageNet), which don't always translate well to the subtle, irregular defects found on a factory floor.
In their paper "REB: Reducing Biases in Representation for Industrial Anomaly Detection," researchers from The Hong Kong Polytechnic University introduce a two-pronged framework designed to bridge this gap by tackling both domain and feature-space biases.
TL;DR
REB improves industrial anomaly detection by fine-tuning models with a diverse synthetic defect generator (DefectMaker) and employing a novel Local-Density KNN (LDKNN) retrieval method. This approach allows smaller, faster networks like ResNet18 to achieve state-of-the-art results, reaching 99.5% AUROC on the MVTec AD benchmark.
What Problem Does This Paper Address?
Existing representation-based AD methods typically follow a two-stage pipeline: extract features from normal images and then use a distance measure (like K-Nearest Neighbor) to flag anything that looks "too far" from the norm. However, this approach suffers from two major biases:
- Domain Bias: Pre-trained models are "biased" toward natural scenes (cats, cars, trees). Industrial defects are often tiny, irregular, and structurally different, meaning the model's internal representation isn't optimized to see them.
- Local Density Bias: Standard KNN assumes the feature space is uniform. In reality, some "normal" features are tightly clustered (high density), while others are naturally sparse. A simple distance check might incorrectly flag a normal but sparse feature as an anomaly, or miss a subtle defect hidden in a dense region.
Methods
The REB framework introduces two innovative modules to solve these issues:
1. DefectMaker (Reducing Domain Bias)
To teach the model what an industrial defect looks like without needing real (and rare) anomalous data, the authors developed DefectMaker. Unlike previous methods that used simple rectangles, DefectMaker uses:
- Bézier Curves: To generate realistic, irregular shapes like scratches ("scars") or spots ("clumps").
- Saliency Guidance: An unsupervised saliency model ensures defects are placed on the actual object rather than the background.
- Diverse Fills: Defects are filled with random noise or patches from other images and then fused using pasting or blending techniques.
The model undergoes a self-supervised "proxy task," learning to classify these diverse synthetic defects, which fine-tunes the backbone to be more sensitive to industrial irregularities.
2. LDKNN (Reducing Local Density Bias)
During the inference phase, REB uses Local-Density KNN. Instead of just measuring the Euclidean distance to the nearest normal neighbor, it subtracts a "local density" factor.
- The Logic: If a test feature is near a "sparse" region of the memory bank, the threshold for calling it an anomaly should be higher.
- The Algorithm: During training, the average distance to $K$ neighbors is pre-calculated for every point in the memory bank. During testing, this density value is used to normalize the anomaly score, effectively "leveling the playing field" across the feature space.
Datasets
The authors evaluated REB on three primary industrial benchmarks:
- MVTec AD: The gold standard for industrial AD, containing 15 categories of objects and textures.
- MVTec LOCO AD: A more challenging dataset focusing on "logical" anomalies (e.g., a box missing a component) vs. structural ones.
- BTAD (BeanTech Anomaly Detection): A real-world dataset featuring industrial products like nuts and screws.
Key Insights and Ideas
- Smaller is Better (Sometimes): By reducing bias, REB allows a lightweight ResNet18 to outperform much larger models like WideResNet50. This is a huge win for edge deployment in factories where compute is limited.
- Robustness to Hyperparameters: Standard KNN performance often drops as you increase $K$ (the number of neighbors). LDKNN, however, remains stable or even improves with larger $K$ values because the local density normalization accounts for the global distribution of the data.
- Efficiency: The LDKNN calculation adds less than 0.1 ms to the inference time, making the performance boost essentially "free" in terms of computational cost.
Key Results
REB sets new high-water marks across several benchmarks:
- MVTec AD: Achieved 99.5% Im.AUROC using a ResNet18 backbone, surpassing the previous state-of-the-art (SOTA) for that model size.
- MVTec LOCO AD: Reached 88.8% Im.AUROC (with a WR101 backbone), outperforming other representation-based methods.
- BTAD: Achieved a remarkable 96.0% Im.AUROC.
Limitations and Future Work
The authors note that while DefectMaker is excellent for structural defects (cracks, stains), it struggles with logical anomalies (e.g., the wrong number of items in a package). Because DefectMaker focuses on local patch-level changes, it doesn't "understand" the global logic of an image.
Future work aims to design a version of DefectMaker specifically targeting these high-level logical defects and to more tightly integrate the self-supervised learning phase with the memory bank construction.
Summary updated