[ICCV2023] Unsupervised Surface Anomaly Detection with Diffusion Probabilistic Model
@inproceedings{zhang2023unsupervised,
title={Unsupervised Surface Anomaly Detection with Diffusion Probabilistic Model},
author={Zhang, Xinyi and Li, Naiqi and Li, Jiawei and Dai, Tao and Jiang, Yong and Xia, Shu-Tao},
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
pages={6782--6791},
year={2023}
}
![image](https://private-user-images.githubusercontent.com/51684540/278666977-789dd35c-17d6-48d5-8c57-612bc71d0d6e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDkxNTgsIm5iZiI6MTcyMzIwODg1OCwicGF0aCI6Ii81MTY4NDU0MC8yNzg2NjY5NzctNzg5ZGQzNWMtMTdkNi00OGQ1LThjNTctNjEyYmM3MWQwZDZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA5VDEzMDczOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ0MGIwOGFmZGVlNGE0MzQ5ODBlZGE5MmI5ZTY0OGNhYTEwYjk5MGI0NDhiNzgxYTIxNzVjZjZkODRlOTRmY2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7ZFusbjJEdYsJAV9luXsEsK5fwqKnQRMrxYcLamAU-4)
conda env create -f environment.yaml
conda activate DiffAD
Following DRAEM, we use the MVTec-AD and DTD dataset. You can run the download_dataset.sh script from the project directory to download the MVTec and the DTD datasets to the datasets folder in the project directory:
./scripts/download_dataset.sh
The reconstrucion sub-network is based on the latent diffusion model.
cd rec_network
CUDA_VISIBLE_DEVICES=<GPU_ID> python main.py --base configs/kl.yaml -t --gpus 0,
CUDA_VISIBLE_DEVICES=<GPU_ID> python main.py --base configs/mvtec.yaml -t --gpus 0 -max_epochs 4000,
cd seg_network
CUDA_VISIBLE_DEVICES=<GPU_ID> python train.py --gpu_id 0 --lr 0.001 --bs 32 --epochs 700 --data_path ./datasets/mvtec/ --anomaly_source_path ./datasets/dtd/images/ --checkpoint_path ./checkpoints/obj_name --log_path ./logs/
After training the reconstruction sub-network, you can test the reconstruction performance with the anomalous inputs:
python scripts/mvtec.py
For some samples with severe deformations, such as missing transistors, you can add some noise to the anomalous conditions to adjust the sampling.
cd seg_network
python test.py --gpu_id 0 --base_model_name "seg_network" --data_path ./datasets/mvtec/ --checkpoint_path ./checkpoints/obj_name/