  Anomaly detection with only prior knowledge from normal samples attracts more
attention because of the lack of anomaly samples. Existing CNN-based pixel
reconstruction approaches suffer from two concerns. First, the reconstruction
source and target are raw pixel values that contain indistinguishable semantic
information. Second, CNN tends to reconstruct both normal samples and anomalies
well, making them still hard to distinguish. In this paper, we propose Anomaly
Detection TRansformer (ADTR) to apply a transformer to reconstruct pre-trained
features. The pre-trained features contain distinguishable semantic
information. Also, the adoption of transformer limits to reconstruct anomalies
well such that anomalies could be detected easily once the reconstruction
fails. Moreover, we propose novel loss functions to make our approach
compatible with the normal-sample-only case and the anomaly-available case with
both image-level and pixel-level labeled anomalies. The performance could be
further improved by adding simple synthetic or external irrelevant anomalies.
Extensive experiments are conducted on anomaly detection datasets including
MVTec-AD and CIFAR-10. Our method achieves superior performance compared with
all baselines.
