This repository contains a small learning-oriented diffusion model project built with PyTorch.
The main project is:
mnist3_diffusion_demo/
It trains a DDPM on MNIST digit 3, generates new digit-3 images, filters generated images with a high-accuracy MNIST classifier, supports human good/bad quality labeling, trains a second quality classifier, and includes novelty checks against the training set.
ddpm_2d_demo.py Tiny 2D DDPM toy demo
mnist3_diffusion_demo/ Complete MNIST digit-3 DDPM project
PROJECT_RESULTS.md Result images and metric summary
requirements.txt Minimal root dependencies
Inside mnist3_diffusion_demo/:
train_mnist3_ddpm.py Train/sample the MNIST-3 DDPM
train_mnist_classifier.py Train MNIST 10-class classifier
generate_digit3_with_classifier.py Generate and filter by digit-3 confidence
label_generated_quality.py UI for manual good/bad labeling
train_quality_classifier.py Train the second quality classifier
generate_digit3_with_quality_filter.py
verify_generation_novelty.py Nearest-neighbor novelty check
DDPM_CODE_EXPLANATION.md Detailed code explanation
outputs/ Curated checkpoints, metrics, and images
MNIST raw files are expected at:
data/MNIST/raw/
The dataset is intentionally not committed to the repository.
Install dependencies:
pip install -r requirements.txt
pip install -r mnist3_diffusion_demo/requirements.txtRun the high-config checkpoint to sample images:
cd mnist3_diffusion_demo
python train_mnist3_ddpm.py --mode sample --checkpoint outputs/checkpoints/mnist3_high_10000.pt --sample-count 64Generate images filtered by the digit classifier:
python generate_digit3_with_classifier.py --threshold 0.99 --count 64Run the final two-stage filter, after a quality classifier exists:
python generate_digit3_with_quality_filter.py --count 64 --digit-threshold 0.99 --quality-threshold 0.90See PROJECT_RESULTS.md for result images, metrics, and artifact locations.
For a detailed explanation of the DDPM implementation, see: