Home

Awesome

STFPM

Official pytorch implementation for the paper entitled "Student-Teacher Feature Pyramid Matching for Anomaly Detection" (BMVC 2021) https://arxiv.org/abs/2103.04257v3

plot

Dataset

Download dataset from MvTec website.

Training

Train a model:

python main.py train --mvtec-ad mvtec_anomaly_detection --category carpet --epochs 200

After running this command, a directory snapshots/carpet should be created.

Testing

Evaluate a model:

python main.py test --mvtec-ad mvtec_anomaly_detection --category carpet --checkpoint snapshots/carpet/best.pth.tar

This command will evaluate the model specified by --checkpoint argument. You may download the pre-trained models here.

For per-region-overlap (PRO) calculation, you may refer to here. Note that it might take a long time for PRO calculation.

Results

You are expected to obtain the same numbers given the pre-trained models.

CategoryAUC-ROC(pixel)AUC-ROC (image)PRO
carpet0.9902920.9642860.966061
grid0.9896220.9824560.963767
leather0.9907070.9507470.956661
tile0.9690670.9823230.896640
wood0.9645880.9964910.900518
bottle0.9878941.0000000.959157
cable0.9575040.9355320.894954
capsule0.9857300.8934980.895790
hazelnut0.9847151.0000000.952182
meta_nut0.9717890.9833820.948197
pill0.9755050.9511730.965973
screw0.9884810.8946510.948661
toothbrush0.9895510.8972220.926844
transistor0.8194040.9391670.880923
zipper0.9877560.9613970.868873
<b>average</b><b>0.970174</b><b>0.955488</b><b>0.9283467</b>

Citation

If you find the work useful in your research, please cite our papar.

@inproceedings{wang2021student_teacher,
    title={Student-Teacher Feature Pyramid Matching for Anomaly Detection},
    author={Wang, Guodong and Han, Shumin and Ding, Errui and Huang, Di},
    booktitle={The British Machine Vision Conference (BMVC)},
    year={2021}
}