A context-free DDPM (Denoising Diffusion Probabilistic Model) training pipeline for wind-speed imagery using pre-generated NASA Global Precipitation Measurement (GPM) satellite data, combined with NASA Geostationary Operational Environmental Satellite (GOES) imagery RI data to identify intense convective bursts noise for fully deterministic and reproducible experiments.
This is the Physics-Informed Diffusion Model SERWED (Synthetic Extreme Rare Weather Events Data) generator provides a complete training pipeline for diffusion models with a focus on reproducibility. Unlike traditional implementations that generate noise on-the-fly, this system uses pre-generated deterministic noise stored on disk, enabling:
- Fully reproducible training runs
- Simplified debugging and experimentation
- Separation of data preparation, noise generation, and training phases
- Deterministic Training: Pre-generated noise ensures identical results across runs
- Unconditional Generation: Simplified model without label conditioning
- Modular Pipeline: Clear separation between data prep, noise generation, and training
- Configuration-Driven: YAML config files for easy experiment management
- WandB Integration: Optional experiment tracking and logging
- Python 3.8 or higher
- CUDA-capable GPU (recommended)
- Sufficient disk space for pre-generated noise (~200+ GB for full datasets)
the library dependencies are listed in requirements.txt. they are about 5 gb in size due to torch and torchvision.
- Clone the repository:
git clone https://github.com/MarawanYakout/SERWED.git- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtNote
For detailed usage and advanced configurations, refer to the inline documentation within each script.
export PYTHONPATH=$PYTHONPATH:.python scripts/prepare_data.py --folder_path raw_data --sample_fraction 0.25 --image_size 16 --output_images /training_data/wind_3D16X16.npyImportant
Adjust --sample_fraction for quick tests or full dataset.
python scripts/pregenerate_noise.py --images_np training_data/wind_3D16X16.npy --timesteps 500 --height 16 --channels 3 --save_dir pregenerated_noise/ --images_per_file 1000
python scripts/train_cli.py --data_np training_data/wind_3D16X16.npy --pregenerated_noise_dir pregenerated_noise/ --timesteps 500 --epochs 250 --batch_size 32 --lr 0.0001 --save_dir weights/ --save_every 4Note
The training is mainly in scripts/train_cli.py which uses src/trainer.py for the training loop.
python tests/test_vis_ddpm.py --checkpoint weights/model_99.pth --output_dir tests/vis_out --num_samples 32 --save_rate 20python main_train.pyConvert raw wind-speed images into a consolidated NumPy array:
python scripts/prepare_data.py \
--folder_path ./Data/training_data \
--sample_fraction 1.0 \
--image_size 16 \
--output_images wind_3D16X16.npyParameters:
folder_path: Directory containing raw training imagessample_fraction: Fraction of dataset to use (e.g., 0.25 for quick tests)image_size: Target image dimensions (e.g., 16 for 16×16 patches)output_images: Path for output.npyfile
Create deterministic noise tensors for all images and timesteps:
python scripts/pregenerate_noise.py \
--images_np wind_3D16X16.npy \
--timesteps 500 \
--height 16 \
--channels 3 \
--save_dir ./pregenerated_noise \
--images_per_file 1000Parameters:
images_np: Path to prepared datasettimesteps: Number of diffusion steps (typically 500)height: Image height (must match dataset)channels: Number of channels (3 for RGB)save_dir: Output directory for noise chunksimages_per_file: Images per chunk file (for memory management)
Note: This step can take several hours and requires significant disk space.
Start training using either a config file or CLI arguments:
python scripts/train_cli.py \
--config ./config/train.yaml \
--pregenerated_noise_dir ./pregenerated_noisepython scripts/train_cli.py \
--data_np wind_3D16X16.npy \
--pregenerated_noise_dir ./pregenerated_noise \
--timesteps 500 \
--epochs 250 \
--batch_size 32 \
--lr 0.0001 \
--save_dir ./weights \
--save_every 4Use a YAML config file in config/:
- There are ones for 25% training testing
- Full 100% testing for major computers
dataset:
npy_images: wind_3D16X16.npy
model:
height: 16
n_feat: 64
diffusion:
timesteps: 500
beta1: 0.0001
beta2: 0.02
train:
epochs: 250
batch_size: 32
lr: 0.0001
save_dir: weights/
save_every: 4
wandb:
enabled: true
project: DDPM-Wind
group: unconditional
name: run-v1# Prepare subset
python scripts/prepare_data.py \
--folder_path ./Data/training_data \
--sample_fraction 0.25 \
--image_size 16 \
--output_images wind_3D16X16_25pct.npy
# Generate noise
python scripts/pregenerate_noise.py \
--images_np wind_3D16X16_25pct.npy \
--timesteps 500 \
--height 16 \
--channels 3 \
--save_dir ./noise_25pct
# Train
python scripts/train_cli.py \
--data_np wind_3D16X16_25pct.npy \
--pregenerated_noise_dir ./noise_25pct \
--epochs 50 \
--batch_size 32-
scripts/prepare_data.py- Dataset preparation and preprocessing -
scripts/pregenerate_noise.py- Pre-generate deterministic noise tensors -
scripts/compute_norm_stats.py- Normalisaion statistics computation -
scripts/train_cli.py- Main training entry point
src/datasets.py- Custom dataset loader for images and pre-generated noisesrc/trainer.py- DDPM training loop implementationsrc/context_unet.py- U-Net model architecturesrc/diffusion.py- Diffusion schedule utilities
Contributions are welcome! If you'd like to contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Make your changes
- Commit with clear messages (
git commit -m 'Add new feature') - Push to your branch (
git push origin feature/your-feature) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate documentation.
This work is licensed under the Creative Commons Attribution 4.0 International License. - see the LICENSE file for details.
- arXiv: https://arxiv.org/abs/2603.06782
- arXiv Paper PDF: https://arxiv.org/pdf/2603.06782
- Paper Puplishing is Processing ..
- Authors: Marawan Yakout | Tannistha Maiti
- GitHub: @MarawanYakout
- Email: mmyay1@student.london.ac.uk | yakout@marawan.net
- LinkedIn: linkedin.com/in/marawanyakout