Home

Awesome

Prototypical Residual Networks for Anomaly Detection and Localization

Unofficial PyTorch implementation for CVPR2023 paper, Prototypical Residual Networks for Anomaly Detection and Localization.

This paper proposes 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.

Framework

Dataset Preparation

Download MVTecAD dataset from there, put it to the directory data/mvtec_anomaly_detection.

Then unzip the foreground masks:

unzip fg_mask.zip

Prototype Features Generation

Run the create_proto_feature_maps.py to generate prototype features.

python create_proto_feature_maps.py

Training and validating

Run the following code for training and validating the MVTecAD dataset.

python train.py

We summarize the validation results on MVTecAD as follows.

CategoryImage/Pixel AUCPaper
Carpet0.999/0.9880.977/0.990
Grid0.818/0.8300.994/0.984
Leather1.000/0.9941.000/0.997
Tile0.992/0.9571.000/0.996
Wood1.000/0.9551.000/0.978
Bottle1.000/0.9841.000/0.994
Cable0.952/0.9490.989/0.988
Capsule0.903/0.9610.980/0.985
Hazelnut1.000/0.9941.000/0.997
Metal Nut0.962/0.9841.000/0.997
Pill0.880/0.9700.993/0.995
Screw0.834/0.9610.959/0.975
Toothbrush0.983/0.9631.000/0.996
Transistor0.931/0.9730.997/0.984
Zipper0.988/0.9600.997/0.988
Mean0.949/0.9620.994/0.990

:hammer: Todo List

The following issues need to be further improved:

Reference

@InProceedings{Zhang_2023_CVPR,
    author    = {Zhang, Hui and Wu, Zuxuan and Wang, Zheng and Chen, Zhineng and Jiang, Yu-Gang},
    title     = {Prototypical Residual Networks for Anomaly Detection and Localization},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2023},
    pages     = {16281-16291}
}

Acknowledgement

The dataset part of this repository is built using the BGAD library and the DRAEM repository.