{"id":13410467,"url":"https://github.com/Julian-Wyatt/AnoDDPM","last_synced_at":"2025-03-14T16:32:12.989Z","repository":{"id":49816424,"uuid":"431905606","full_name":"Julian-Wyatt/AnoDDPM","owner":"Julian-Wyatt","description":"CVPR Workshop paper -  AnoDDPM: Anomaly Detection with Denoising Diffusion Probabilistic Models using Simplex Noise","archived":false,"fork":false,"pushed_at":"2022-09-04T17:21:01.000Z","size":699,"stargazers_count":154,"open_issues_count":7,"forks_count":27,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-31T20:42:42.319Z","etag":null,"topics":["anomaly-detection","computer-vision","cvpr","ddpm","dl","medical","segmentation"],"latest_commit_sha":null,"homepage":"https://julianwyatt.co.uk/anoddpm","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Julian-Wyatt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-25T16:11:06.000Z","updated_at":"2024-07-22T07:27:44.000Z","dependencies_parsed_at":"2023-01-17T19:40:32.308Z","dependency_job_id":null,"html_url":"https://github.com/Julian-Wyatt/AnoDDPM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Wyatt%2FAnoDDPM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Wyatt%2FAnoDDPM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Wyatt%2FAnoDDPM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Wyatt%2FAnoDDPM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Julian-Wyatt","download_url":"https://codeload.github.com/Julian-Wyatt/AnoDDPM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243610211,"owners_count":20318921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","computer-vision","cvpr","ddpm","dl","medical","segmentation"],"created_at":"2024-07-30T20:01:07.136Z","updated_at":"2025-03-14T16:32:12.678Z","avatar_url":"https://github.com/Julian-Wyatt.png","language":"Python","funding_links":[],"categories":["Papers"],"sub_categories":["Reconstruction based"],"readme":"# AnoDDPM: Anomaly Detection with Denoising Diffusion Probabilistic Models using Simplex Noise\n\nThis is the github repository for an anomaly detection approach utilising DDPMs with simplex noise implemented in\npytorch.\n\nThe code was written by [Julian Wyatt](https://github.com/Julian-Wyatt) and is based off\nthe [Guided Diffusion Repo](https://github.com/openai/guided-diffusion) and a fork of\na [python simplex noise library](https://github.com/lmas/opensimplex).\n\nThe project was accepted at the CVPR Workshop: NTIRE 2022: [Project](https://julianwyatt.co.uk/anoddpm)\n| [Paper](https://openaccess.thecvf.com/content/CVPR2022W/NTIRE/html/Wyatt_AnoDDPM_Anomaly_Detection_With_Denoising_Diffusion_Probabilistic_Models_Using_Simplex_CVPRW_2022_paper.html)\n\n## Simplex noise examples\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"gif 1\" src=\"https://github.com/Julian-Wyatt/JulianWyatt.github.io/blob/db50a67bec8aece87e185260572ece35d74b74df/assets/img/portfolio/anoddpm2-compressed.gif\" width=\"45%\"\u003e\n\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\n  \u003cimg alt=\"gif 2\" src=\"https://github.com/Julian-Wyatt/JulianWyatt.github.io/blob/db50a67bec8aece87e185260572ece35d74b74df/assets/img/portfolio/anoddpm3-compressed.gif\" width=\"45%\"\u003e\n\u003c/p\u003e\n\n## Gaussian noise example\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src='https://github.com/Julian-Wyatt/JulianWyatt.github.io/blob/db50a67bec8aece87e185260572ece35d74b74df/assets/img/portfolio/anoddpmGauss.gif' width=45%\u003e\n\u003c/p\u003e\n\n## File structure:\n\n- dataset.py - custom dataset loader\n- detection.py - code for generating measures \u0026 initial testing and experimentation.\n- diffusion_training.py - training procedure\n- evaluation.py - functions for measures and metrics\n- GaussianDiffusion.py - Gaussian architecture with custom detection, forked from https://github.\n  com/openai/guided-diffusion\n- generate_images.py - generates images for Figs in paper\n- graphs.py - reduce graph quality, load and visualise graphs\n- helpers.py - helper functions for use in several places ie checkpoint loading\n- perlin.py - Generating Fig 2 and testing octaves\n- simplex.py - Simplex class - forked from https://github.com/lmas/opensimplex with added multi-scale code.\n- UNet.py - UNet architecture, forked from https://github.com/openai/guided-diffusion\n- test_args/args{i}.json - primary example seen below\n- model/diff-params-ARGS={i}/params-final.pt - checkpoint for i'th arg\n- Examples/ - demonstration of early testing\n- diffusion-videos/ARGS={i}/ - video outputs of varying args across training, testing and detection\n- diffusion-training-images/ARGS={i}/ - detection images\n- metrics/ - storage of varying metrics\n- final-outputs/ - outputs from generate_images.py\n\nFor access to checkpoints, please get in touch. For access to datasets, please refer to the paper's citations.\n\n## How To...\n\n### Train\n\nTo train a model, run `python3 diffusion_training.py ARG_NUM` where `ARG_NUM` is the number relating to the json arg\nfile. These arguments are stored in ./test_args/ and are called args1.json for example.\n\n### Evaluate\n\nTo evaluate a model, run `python3 detection.py ARG_NUM`, and ensure the script runs the correct sub function.\n\n### Datasets\n\nTo perform the same tests, store the anomalous dataset\nin `./DATASETS/CancerousDataset/EdinburghDataset/Anomalous-T1/raw` and the training dataset in\n`./DATASETS/Train/`. The training dataset contained 100 folders where each contained the raw file and the numpy\nextracted file. To add a new dataset, edit the `dataset.py` file and ensure the new dataset is loaded via the script\nyou're running.\n\n## Example args:\n\n{\n\"img_size\": [256,256],\n\"Batch_Size\": 1,\n\"EPOCHS\": 3000,\n\"T\": 1000,\n\"base_channels\": 128,\n\"beta_schedule\": \"linear\",\n\"channel_mults\": \"\",\n\"loss-type\": \"l2\",\n\"loss_weight\": \"none\",\n\"train_start\": true,\n\"lr\": 1e-4,\n\"random_slice\": true,\n\"sample_distance\": 800,\n\"weight_decay\": 0.0,\n\"save_imgs\":false,\n\"save_vids\":true,\n\"dropout\":0,\n\"attention_resolutions\":\"16,8\",\n\"num_heads\":2,\n\"num_head_channels\":-1,\n\"noise_fn\":\"simplex\",\n\"dataset\": \"mri\"\n}\n\n## Citation:\n\nIf you use this code for your research, please cite:\u003cbr\u003e\nAnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise\u003cbr\u003e\n[Julian Wyatt](https://github.com/Julian-Wyatt), [Adam Leach](https://github.com/qazwsxal)\n, [Sebastian M. Schmon](https://scholar.google.com/citations?user=hs2WrYYAAAAJ\u0026hl=en\u0026oi=ao)\n, [Chris G. Willcocks](https://github.com/cwkx); Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern\nRecognition (CVPR) Workshops, 2022\n\n```\n@InProceedings{Wyatt_2022_CVPR,\n    author    = {Wyatt, Julian and Leach, Adam and Schmon, Sebastian M. and Willcocks, Chris G.},\n    title     = {AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise},\n    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},\n    month     = {June},\n    year      = {2022},\n    pages     = {650-656}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJulian-Wyatt%2FAnoDDPM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJulian-Wyatt%2FAnoDDPM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJulian-Wyatt%2FAnoDDPM/lists"}