  Anomaly detection aims to separate anomalies from normal samples, and the
pretrained network is promising for anomaly detection. However, adapting the
pretrained features would be confronted with the risk of pattern collapse when
finetuning on one-class training data. In this paper, we propose an anomaly
detection framework called constrained adaptive projection with pretrained
features (CAP). Combined with pretrained features, a simple linear projection
head applied on a specific input and its k most similar pretrained normal
representations is designed for feature adaptation, and a reformed
self-attention is leveraged to mine the inner-relationship among one-class
semantic features. A loss function is proposed to avoid potential pattern
collapse. Concretely, it considers the similarity between a specific data and
its corresponding adaptive normal representation, and incorporates a constraint
term slightly aligning pretrained and adaptive spaces. Our method achieves
state-ofthe-art anomaly detection performance on semantic anomaly detection and
sensory anomaly detection benchmarks including 96.5% AUROC on CIFAR- 100
dataset, 97.0% AUROC on CIFAR-10 dataset and 89.9% AUROC on MvTec dataset.
