  Anomaly detection and localization are widely used in industrial
manufacturing for its efficiency and effectiveness. Anomalies are rare and hard
to collect and supervised models easily over-fit to these seen anomalies with a
handful of abnormal samples, producing unsatisfactory performance. On the other
hand, anomalies are typically subtle, hard to discern, and of various
appearance, making it difficult to detect anomalies and let alone locate
anomalous regions. To address these issues, we propose a framework called
Prototypical Residual Network (PRN), which learns feature residuals of varying
scales and sizes between anomalous and normal patterns to accurately
reconstruct the segmentation maps of anomalous regions. PRN mainly consists of
two parts: multi-scale prototypes that explicitly represent the residual
features of anomalies to normal patterns; a multisize self-attention mechanism
that enables variable-sized anomalous feature learning. Besides, we present a
variety of anomaly generation strategies that consider both seen and unseen
appearance variance to enlarge and diversify anomalies. Extensive experiments
on the challenging and widely used MVTec AD benchmark show that PRN outperforms
current state-of-the-art unsupervised and supervised methods. We further report
SOTA results on three additional datasets to demonstrate the effectiveness and
generalizability of PRN.
