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

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support