Introduction
Anomaly Detection (AD) has traditionally been divided into two distinct domains: Semantic AD, which focuses on identifying novel object categories (e.g., a cat in a dataset of dogs), and Industrial AD, which targets subtle defects in otherwise normal objects (e.g., a hairline crack in a component). Historically, models specialized for one domain perform poorly in the other. GeneralAD addresses this "chasm" by introducing a unified framework capable of cross-domain proficiency with minimal task-specific tuning.
Methodology: Bridging the Domain Gap
GeneralAD utilizes a pretrained Vision Transformer (ViT) backbone, specifically DINOv2, to leverage its rich spatial feature representations. The framework operates through a two-stage pipeline designed to handle both global semantic shifts and local industrial defects.
Self-supervised Anomaly Generation (SAG)
Since training data typically consists only of "normal" samples, GeneralAD creates synthetic anomalies in the feature space using three strategies:
- Noise All Patches: Adds Gaussian noise to the entire feature map, simulating semantic shifts.
- Noise Random Patches: Targets a subset of patches to mimic local industrial defects.
- Attention Shuffle: Uses attention maps to identify and relocate critical patches, effectively simulating "logical anomalies" where components are present but incorrectly positioned.
Cross-Patch Attention Discriminator
Unlike traditional methods that analyze patches in isolation, GeneralAD employs a transformer-based discriminator. By using Multi-Head Attention (MHA), the model allows patches to interact globally. This context-aware approach is essential for detecting logical inconsistencies that local scanners might overlook. During inference, the model generates patch-level scores, which are aggregated using a Top-K average to produce a final image-level anomaly score.
Experimental Results
The authors evaluated GeneralAD across ten diverse datasets, spanning semantic (e.g., CIFAR-10, Fashion-MNIST), near-distribution (e.g., Aircraft-FGVC), and industrial (e.g., MVTec-AD, VisA) categories.
State-of-the-Art Performance
GeneralAD achieved state-of-the-art (SOTA) results on six of the ten datasets and remained competitive on the others. Notably, on the MVTec-LOCO benchmark—which focuses on complex logical anomalies—GeneralAD outperformed previous leaders like SimpleNet and Recontrast by approximately 7% and 3% in image-level AUROC, respectively.
Efficiency and Interpretability
The model demonstrates high sample efficiency, significantly outperforming established methods like PatchCore in few-shot scenarios (1 to 8 training images). Furthermore, GeneralAD provides high-quality localization heatmaps, accurately pinpointing anomalous regions at the pixel level across both industrial and semantic tasks.
Discussion and Future Work
A key insight from this research is the importance of global context provided by the attention-based discriminator. The primary hyperparameter, $K$ (the number of patches averaged for the final score), serves as a bridge between domains: higher $K$ values suit semantic tasks covering the whole image, while lower values (e.g., $K=10$) are optimal for localized industrial defects.
While GeneralAD is a powerful generalist, its performance is tied to the quality of the pretrained backbone. Future research may explore automated methods for determining the optimal $K$ value or more advanced distortion techniques to further enhance its "all-rounder" capabilities without manual intervention.
Summary updated