Julian-Wyatt / AnoDDPM

CVPR Workshop paper - AnoDDPM: Anomaly Detection with Denoising Diffusion Probabilistic Models using Simplex Noise
https://julianwyatt.co.uk/anoddpm
MIT License
154 stars 27 forks source link
anomaly-detection computer-vision cvpr ddpm dl medical segmentation

AnoDDPM: Anomaly Detection with Denoising Diffusion Probabilistic Models using Simplex Noise

This is the github repository for an anomaly detection approach utilising DDPMs with simplex noise implemented in pytorch.

The code was written by Julian Wyatt and is based off the Guided Diffusion Repo and a fork of a python simplex noise library.

The project was accepted at the CVPR Workshop: NTIRE 2022: Project | Paper

Simplex noise examples

gif 1         gif 2

Gaussian noise example

File structure:

For access to checkpoints, please get in touch. For access to datasets, please refer to the paper's citations.

How To...

Train

To train a model, run python3 diffusion_training.py ARG_NUM where ARG_NUM is the number relating to the json arg file. These arguments are stored in ./test_args/ and are called args1.json for example.

Evaluate

To evaluate a model, run python3 detection.py ARG_NUM, and ensure the script runs the correct sub function.

Datasets

To perform the same tests, store the anomalous dataset in ./DATASETS/CancerousDataset/EdinburghDataset/Anomalous-T1/raw and the training dataset in ./DATASETS/Train/. The training dataset contained 100 folders where each contained the raw file and the numpy extracted file. To add a new dataset, edit the dataset.py file and ensure the new dataset is loaded via the script you're running.

Example args:

{ "img_size": [256,256], "Batch_Size": 1, "EPOCHS": 3000, "T": 1000, "base_channels": 128, "beta_schedule": "linear", "channel_mults": "", "loss-type": "l2", "loss_weight": "none", "train_start": true, "lr": 1e-4, "random_slice": true, "sample_distance": 800, "weight_decay": 0.0, "save_imgs":false, "save_vids":true, "dropout":0, "attention_resolutions":"16,8", "num_heads":2, "num_head_channels":-1, "noise_fn":"simplex", "dataset": "mri" }

Citation:

If you use this code for your research, please cite:
AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Julian Wyatt, Adam Leach , Sebastian M. Schmon , Chris G. Willcocks; Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, 2022

@InProceedings{Wyatt_2022_CVPR,
    author    = {Wyatt, Julian and Leach, Adam and Schmon, Sebastian M. and Willcocks, Chris G.},
    title     = {AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
    month     = {June},
    year      = {2022},
    pages     = {650-656}
}