Home

Awesome

Diversity-Measurable Anomaly Detection

<div align="center"> <img src="./DMAD.JPG" title="Logo" width="800" /> </div> <div align="center"> <img src="./MNIST1.JPG" width="400" height="290"/><img src="./MNIST2.JPG" width="400" height="290"/> </div>

Requirements

Datasets

If you need to download a dataset, these resources may be helpful:

Then you need to move the downloaded datasets, like ``./dataset/ped2/'' for PDM and specify the corresponding path for PPDM.

Toy Experiment

Download VQ-CVAE-based DMAD-PDM from GoogleDrive or design your custom dataset with code in DMAD-Toy Then chech the arguments parser and run:

cd DMAD-Toy
python main.py

Training & Testing

Pre-Processed Files

The master branch does not contain pre-processing files (>25MB, e.g. background template for ShanghaiTech) and you need to download them at: BaiduPan (Password:dmad) or GoogleDrive

All files are located with the same path, you just need to download them to the Corresponding Folder and Unzip them.

Commands

To train or test PDM version DMAD framework, just run:

cd DMAD-PDM
python [[Train], [Evaluate]]_[[ped2], [avenue], [shanghai]].py
<*optional> python process_avenue.py # to remove static anomalies, e.g. bag and a sitting person on the left side of the screen in dir_1 and dir_2

To train or test PPDM version DMAD framework, just run:

cd DMAD-PPDM
python [[Train], [Evaluate]]_mvtec.py

Pretrained Models

We also provide four model checkpoints to reproduce the performance report in the papar at: BaiduPan (Password:dmad) or GoogleDrive

Limitation & Improvement

We mainly focuses on the diversity modeling and measurement framework, where geometrical diversity is just one of common pattern in anomaly detection. However, as for anomaly with other kind of diversities, e.g. colors, the geometric-specific diversity measurement may not be positively correlated to anomaly severity. Besides, the training of PDM version may be unstable under certain parameters.

Our solution about stable diversity-agnostic modeling approach will be linked to this repo after relevant paper is accepted.

Acknowledgments

The architecture for PPDM version is based on the implementation of RD. VQ-Layer and the architecture for toy experiment on MNIST is based on the implementation of VQ-VAE. We also thank the authors of MNAD for the framework of loading data and models applied to surveillance videos.

Citation

If you find this code useful, please consider citing our paper:

@inproceedings{liu2023dmad,
  title={Diversity-Measurable Anomaly Detection},
  author={Wenrui Liu and Hong Chang and Bingpeng Ma and Shiguang Shan and Xilin Chen},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  month={June},
  year={2023},
  pages={12147-12156}
}