YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Conditional Diffusion on Modified MNIST
This project trains a class-conditional diffusion model on a modified MNIST dataset where class 1 includes samples from both MNIST digit 1 and FashionMNIST class 'trouser'.
π¦ Setup
git clone https://github.com/yourusername/conditional-diffusion-mnist.git
cd conditional-diffusion-mnist
pip install -r requirements.txt
π Dataset
Prepare the custom dataset:
python prepare_dataset.py
This generates Dataset/shuffled_mnist_with_trousers.pt, a balanced dataset of MNIST 1s and FashionMNIST trousers labeled as 1.
𧨠Train the Diffusion Model
python train_diffusion.py
This trains a conditional DDPM model and saves checkpoints under the DDPM/ directory, including unet_final.pt.
π¨ Sample from the Model
python sample_images.py
This loads the trained model from DDPM/unet_final.pt and generates class-conditioned samples (by default, class 1).
π Folder Structure
conditional-diffusion-mnist/
βββ DDPM/ # Model checkpoints
β βββ unet_final_ema.pt
β βββ class_embedder.pt
βββ Samples/ # Sample generation
β βββ class {condition_class}/ # Samples from the original model with respective conditioned class
β βββ class {condition_class}-Unlearned with constant lambda/ # Samples from the unlearned (constant lambda) model with respective conditioned class
β βββ class {condition_class}-Unlearned with dynamic lambda/ # Samples from the unlearned (dynamic lambda) model with respective conditioned class
βββ DDPM_Unlearned/ # Model checkpoints after Unlearning with constant lambda
β βββ unet_unlearned_ema.pt
β βββ class_embedder_unlearned_ema.pt
βββ DDPM_Unlearned_dynamic/ # Model checkpoints after Unlearning with dynamic lambda
β βββ unet_unlearned_dynamic_ema.pt
β βββ class_embedder_unlearned_dynamic_ema.pt
βββ Dataset/ # Custom dataset generation and files
β βββ shuffled_augmented_mnist.pt
β βββ original_mnist.pt
β βββ trousers_subset.pt
βββ train_diffusion.py # Training script
βββ preprocess_dataset.py # Dataset creation script
βββ requirements.txt
βββ README.md
π§ͺ Requirements
Install all dependencies using:
pip install -r requirements.txt
π License
MIT License
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support