Skip to content

DavePower-cloud/Diffusion_X-ray_Generator

Repository files navigation

🧠 Diffusion X-Ray Generator

Diffusion-based generative model for synthesising chest X-ray images using a 3D U-Net-style architecture and sinusoidal noise embeddings.

Python
TensorFlow
License
Status
Domain
Model
DOI

📌 Overview

This repository implements a denoising diffusion probabilistic model (DDPM) adapted for medical imaging, specifically chest X-ray generation.

The project demonstrates how diffusion models originally developed for natural images can be extended to a healthcare domain.

The pipeline includes:

  • dataset loading and preprocessing
  • diffusion noise scheduling
  • sinusoidal timestep embeddings
  • U-Net denoising network
  • exponential moving average (EMA) stabilisation
  • image generation and visualisation

🖼️ Sample Outputs

Output following 1 epoch: Generated X-rays1

Output following 25 epochs: Generated X-rays25

Output following 50 epochs: Generated X-rays50

Output following 100 epochs: Generated X-rays100


🧱 Repository Structure

src/
config.py
data.py
diffusion.py
model.py
train.py
generate.py
utils.py

notebooks/
demo_generation.ipynb


🚀 Quick Start

Install dependencies:

  • pip install -r requirements.txt

Train the model:

  • python src/train.py

Generate X-ray images from a trained model:

  • python src/generate.py

📊 Features

Diffusion-based generative modelling (DDPM-style) Sinusoidal timestep embeddings U-Net denoising architecture EMA stabilisation of weights Config-driven training pipeline Reproducible training and generation scripts


⚠️ Dataset

The dataset is not included in this repository, but is publicly available on Kaggle under an MIT license:

👉 https://www.kaggle.com/datasets/divyam6969/chest-xray-pneumonia-dataset

Expected structure:

data/
└── chest_xray/
└── train/
└──bacterial_pneumonia
└──viral_pneumonia
└──fungal_pneumonia

After downloading, place the dataset in the data/ directory as shown above.


📖 Acknowledgements

Parts of this implementation are adapted from diffusion model examples presented in Foster Generative AI by David Foster, originally applied to natural image datasets (e.g., flowers).

This repository extends and modifies those approaches for medical imaging applications, including changes to dataset handling, model configuration, and training workflow.


📚 Reference

Foster, D. Generative Deep Learning. 2nd Ed. O’Reilly Media.


🧠 Key Contribution

Demonstrates application of diffusion models to medical image generation Translates generative AI methods from natural images to healthcare Provides a clean, modular implementation for experimentation and extension


👤 Author

David Power
Healthcare Simulation Specialist | MSc Artificial Intelligence

About

Diffusion-based generative model for synthesising chest X-ray images using a 3D U-Net-style architecture and sinusoidal noise embeddings.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors