This is a toy example to do anomaly segmentation using a quite simple teacher-student framework. I wrote this project for learning deeplearning and pytorch.
My code is heavily borrowed from this SPADE-pytorch project. https://github.com/byungjae89/SPADE-pytorch
The main difference is that here a pretrained vgg16 is used as a teacher, guiding a student network with the same structure to extract features. The student's regression errors with respect to the teacher in different receptive fields are combined to yield dense anomaly scores.
PyTorch 1.5+
MVTec AD datasets https://www.mvtec.com/company/research/datasets/mvtec-ad/
Set the DATASET_PATH to the root path of the downloaded MVTec AD dataset.
python main.py
- evaluation metric
roc_auc_score is not suitable because of the extreme imbalance between possitive pixels and negative pixels.
per-region-overlap(PRO) should be a better evaluation metric in this scenario.