REB: Reducing Biases in Representation for Industrial Anomaly Detection

Shuai Lyu, Dongmei Mo, Waikeung Wong

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:

  1. 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.
  2. 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.

Figure 3: DefectMaker Pipline.

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.
Figure 2: Overview of the framework of REB. The training process contains three steps. Step 1: DefectMaker generates defective images, and a classification model is trained to classify between the normal and defect and then used for domain adaptation. Step 2: the pre-trained model extracts patch-level features from a group of normal images and collects them into a memory bank. Step 3: measure the local density in the memory bank. During the inference phase, CNN features of the test image are first extracted, then the nearest neighbor features for each feature are retrieved from the memory bank, and a local density-normalized distance is calculated as the anomaly score.

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.
Figure 1: REB detection results on the MVTec AD (left) and MVTec LOCO AD (right) datasets. Anomalies are bounded by segmentation contours.

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

Abstract

Existing representation-based methods usually conduct industrial anomaly detection in two stages: obtain feature representations with a pre-trained model and perform distance measures for anomaly detection. Among them, K-nearest neighbor (KNN) retrieval-based anomaly detection methods show promising results. However, the features are not fully exploited as these methods ignore domain bias of pre-trained models and the difference of local density in feature space, which limits the detection performance. In this paper, we propose Reducing Biases (REB) in representation by considering the domain bias and building a self-supervised learning task for better domain adaption with a defect generation strategy (DefectMaker) that ensures a strong diversity in the synthetic defects. Additionally, we propose a local-density KNN (LDKNN) to reduce the local density bias in the feature space and obtain effective anomaly detection. The proposed REB method achieves a promising result of 99.5\% Im.AUROC on the widely used MVTec AD, with smaller backbone networks such as Vgg11 and Resnet18. The method also achieves an impressive 88.8\% Im.AUROC on the MVTec LOCO AD dataset and a remarkable 96.0\% on the BTAD dataset, outperforming other representation-based approaches. These results indicate the effectiveness and efficiency of REB for practical industrial applications. Code:https://github.com/ShuaiLYU/REB.
BibTeX
@article{lyu2024reb,
  author = {Shuai Lyu and Dongmei Mo and Waikeung Wong},
  title = {{REB: Reducing Biases in Representation for Industrial Anomaly Detection}},
  journal = {Knowledge-Based Systems},
  year = {2024},
  doi = {10.1016/j.knosys.2024.111563},
}
Figure