Annotsim: Self-Supervised Anomaly Segmentation via Diffusion Models with Dynamic Transformer UNet (WACV 2024) 🚀
This research paper introduces a novel self-supervised anomaly detection method for image segmentation. It employs a diffusion model utilising a newly developed four-dimensional simplex noise function (Tsimplex) for improved efficiency and sample quality, especially in higher-dimensional and coloured images. The core of the model is a Dynamic Transformer UNet (DTUNet), a modified Vision Transformer architecture designed to handle time and noise image patches as tokens. Extensive experiments across three datasets demonstrate significant performance improvements over existing generative-based anomaly detection methods, particularly in medical imaging. The source code is publicly available.
- Custom Diffusion Models: An extended UNet with selective denoising capabilities.
- Dynamic Transformer Blocks: Enhancements for dynamic anomaly segmentation.
- Simplex Noise Integration: Supports 3D/4D noise generation for improved feature diversity.
- Comprehensive Evaluation Metrics: Tools to calculate precision, recall, Dice score, and more.
- Visualization Tools: Generates diffusion videos and detection outputs for interpretability.
| Distribution Visualization | Histogram Plot |
|---|---|
![]() |
![]() |
| Qualitative Result 1 | Qualitative Result 2 |
|---|---|
![]() |
![]() |
Annotsim/
├── src/
│ ├── models/ # Model architectures (UNet, transformer blocks, etc.)
│ ├── utils/ # Helper functions (dataset loading, noise generation, etc.)
│ ├── scripts/ # Training and evaluation scripts
├── requirements.txt # Python dependencies
├── setup.py # Installation script
├── README.md # Project documentation
└── .gitignore # Ignored files and directories
- Python 3.8 or later
- CUDA-enabled GPU (optional but recommended for training)
-
Clone the repository:
git clone https://github.com/MAXNORM8650/Annotsim.git cd Annotsim -
Install dependencies:
pip install -r requirements.txt
-
Install the repository as a package:
pip install -e .
To train a diffusion model:
python src/scripts/diffusion_training_UVW.py --argNReplace argN with your desired configuration file from "test_args" file.
To evaluate a model:
python src/scripts/detection.py --argNThis project uses two publicly available datasets:
- BRATS2021: A dataset for brain tumor segmentation.
- Pneumonia X-Ray: A dataset for chest X-ray anomaly detection.
For more details, refer to the datasets' official documentation.
Generated videos during training and evaluation are saved in:
outputs/diffusion-videos/
Detection results are saved in:
outputs/detection-images/
- Komal Kumar: GitHub Profile
The project imported from:
@InProceedings{Kumar_2025_WACV,
author = {Kumar, Komal and Chakraborty, Snehashis and Mahapatra, Dwarikanath and Bozorgtabar, Behzad and Roy, Sudipta},
title = {Self-Supervised Anomaly Segmentation via Diffusion Models with Dynamic Transformer UNet},
booktitle = {Proceedings of the Winter Conference on Applications of Computer Vision (WACV)},
month = {February},
year = {2025},
pages = {7917-7927}
}






