This repository contains the implementation of DSR as proposed in the paper DSR -- A dual subspace re-projection network for surface anomaly detection
You can create a conda environment with: conda create --name --file requirements.txt
But the main packages used are:
PyTorch 1.11, opencv-python, sklearn, numpy
Set up the MVTec AD benchmark by downloading it from: https://www.mvtec.com/company/research/datasets/mvtec-ad, and extracting it. For training and evaluation pass the base directory of the extracted files (for example ./data/mvtec/) as the --data_path argument.
Download the pretrained models and extract the zip so that the checkpoints folder will be located in the base directory of this repository.
Download link: https://drive.google.com/file/d/15plhikrUjYCcx23JVxxBKb-HBwKAb8UK/view?usp=sharing
#BASE_PATH -- the base directory of mvtec
#i -- the gpu id used for evaluation
python test_dsr.py $i $BASE_PATH DSR
#BASE_PATH -- the base directory of mvtec
#OUT_PATH -- where the trained models will be saved
#i -- the index of the object class in the obj_batch list in train_dsr.py
python train_dsr.py --gpu_id 0 --obj_id $i --lr 0.0002 --bs 8 --epochs 100 --data_path $BASE_PATH --out_path $OUT_PATH