Patch SVDD for Image anomaly detection. Paper: https://arxiv.org/abs/2006.16067 (published in ACCV 2020).
An input image and a generated anomaly map for 'wood' class.
The code runs on python 3.7, pytorch 1.3.1, and torchvision 0.4.2.
Set the DATASET_PATH to the root path of the downloaded MVTec AD dataset.
python main_train.py --obj=bottle --lr=1e-4 --lambda_value=1e-3 --D=64
obj
denotes the name of the class out of 15 MVTec AD classes.lr
denotes the learning rate of Adam optimizer.lambda_value
denotes the value of 'lambda' in Eq. 6 of the paper.D
denotes the number of embedding dimension (default to 64). python main_evaluate.py --obj=bottle
obj
denotes the name of the class.The script loads the trained encoder saved in ckpts/ directory. Note that the same evaluation procedure is performed at every training epoch in Step 2.
For a quick evaluation, trained encoders for cable and wood classes are included. Training (Step 2) can be skipped for those classes.
python main_visualize.py --obj=bottle
obj
denotes the name of the class.The script generates and saves anomaly maps for all the test images in the obj
class.
The genereated maps are saved in anomaly_maps/obj directory.