GuansongPang / ADShift

Official PyTorch implementation of the ICCV'23 paper “Anomaly Detection under Distribution Shift”

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ICCV2023 - Anomaly Detection under Distribution Shift

Official PyTorch implementation of the ICCV'23 paper “Anomaly Detection under Distribution Shift”

Environment

Create suitable conda environment:

conda env create -f environment.yml

Dataset

1. Download dataset:

-MNIST_grey: https://www.kaggle.com/datasets/jidhumohan/mnist-png
-MNIST_M: https://www.kaggle.com/datasets/aquibiqbal/mnistm
-PACS: https://www.kaggle.com/datasets/nickfratto/pacs-dataset
-MVTEC: https://www.mvtec.com/company/research/datasets/mvtec-ad
-CIFAR-10: https://www.kaggle.com/datasets/swaroopkml/cifar10-pngs-in-folders

2. Generate corrupted test set for MVTEC and CIFAR-10

To generate currupted data for MVTEC:

python generate_corrupted_mvtec.py

To generate currupted data for CIFAR-10:

python generate_corrupted_cifar10.py

DINL (for training phase)

To train the model, please run the corresponding file train_namedataset_DINL.py
For example, to train DINL for PACS:

python train_PACS_DINL.py

ATTA (for inference phase)

Note: change the path to the normal image for each dataset if needed.
To run the inference, please run the corresponding file inference_namedataset_ATTA.py
For example, to train ATTA for PACS:

python inference_PACS_ATTA.py

Citation

Please cite this paper if it helps your research:

@article{cao2023anomaly,
  title={Anomaly Detection under Distribution Shift},
  author={Cao, Tri and Zhu, Jiawen and Pang, Guansong},
  journal={arXiv preprint arXiv:2303.13845},
  year={2023}
}

About

Official PyTorch implementation of the ICCV'23 paper “Anomaly Detection under Distribution Shift”


Languages

Language:Python 100.0%