This repository is inspired from the work done in the paper Score-Based Generative Modeling through Stochastic Differential Equations by Song et al, and the especially the repository
@inproceedings{
song2021scorebased,
title={Score-Based Generative Modeling through Stochastic Differential Equations},
author={Yang Song and Jascha Sohl-Dickstein and Diederik P Kingma and Abhishek Kumar and Stefano Ermon and Ben Poole},
booktitle={International Conference on Learning Representations},
year={2021},
url={https://openreview.net/forum?id=PxTIG12RRHS}
}
Clone the repository:
git clone https://github.com/greg2451/score-based-generative-modeling.git
-
Install conda locally following this link. We recommend miniconda, it is more lightweight and will be sufficient for our usage.
-
Create a new conda environment by executing the following command in your terminal:
conda create -n score_generative python=3.8 conda activate score_generative conda install pip
-
Having the conda environnement activated, install the requirements:
pip install -r requirements.txt
After installing the requirements, you can train a model on FashionMNIST by running the following command:
python main.py
Tune the hyperparameters by passing flags to the command line. For example, to train a model with a learning rate of 0.0001, run:
python main.py --learning_rate 0.0001
To see all the available flags, run:
python main.py --help
The training should happen, and the saved models will be located in the runs
folder.
After training a model, you can generate images by running the following command:
python generate.py --model_path <path_to_model>
Again, all hyperparameters can be tuned by passing flags to the command line. To know more about the available flags, run:
python generate.py --help
All generated images will be saved in the generations
folder.
Just run the first cell of the notebook and wait for the training to finish! You can tune the hyperparameters by changing the values of the variables in the first cell. The expected output is the same as the one described in the previous section.
Cells 2,3 and 4 are examples of generation setup using the three different samplers, on our pretrained model. Again, you can tune the hyperparameters by changing the values of the variables in the cells. This time, the images won't be saved, but only displayed in the notebook.
This section should only be necessary if you want to contribute to the project.
Start by installing the dev-requirements:
pip install -r dev-requirements.txt
Run the following command at the root of the repository:
pre-commit install