This project implements a conditional denoising diffusion probabilistic model (DDPM) using a UNet architecture for generating high-quality images.
train.py: Main training script.utils.py: Utility functions for data loading, image saving, and logging.ddpm.py: Implements the Gaussian diffusion process.unet.py: Contains the UNet architecture with self-attention and other modules.ema.py: Implements an exponential moving average (EMA) for model parameter smoothing.
- Update the dataset path and training parameters in
train.py:args.dataset_pathargs.run_nameargs.epochargs.batch_sizeargs.img_sizeargs.lr
- Run the training script:
python train.py - Check the logs, generated images, and saved models in the respective
runs/,results/, andmodels/directories.
- The training script loads the data, builds the UNet model, and applies the Gaussian diffusion process.
- Loss is computed using mean squared error (MSE), optimized with AdamW.
- EMA is used to maintain a stable version of the model.
- Conditional generation is supported via optional label inputs.
- The implementation contain the Classifier free guidance(
CFG) and Exponential Moving Average(EMA)