Git Product home page Git Product logo

explore-diffusion-cs726's Introduction

explore-diffusion

[CS726-2023] Programming assignment exploring diffusion models

Getting started

Steps to get started with the code:

  1. Install Anaconda on your system, download from -- https://www.anaconda.com.
  2. Clone the github repo -- git clone https://github.com/ashutoshbsathe/explore-diffusion.git, into some convenient folder of your choice.
  3. cd explore-diffusion.
  4. Run the command -- conda env create --file environment.yaml. This will setup all the required dependencies.
  5. Activate the environment using source activate cs726-env or conda activate cs726-env. You are done with the setup.

Training your model

Once you code up your model in the model.py file, you can use the provided trainer in the train.py file to train your model, as -- python train.py.

You can use various command line arguments to tweak the number of epochs, batch size, etc. Please check the train.py file for details. You can get the full list of available hyperparameters by doing python train.py -h

After completion of training you can find the checkpoint and hyperparams under the runs directory. A demo directory structure is shown as follows:

image

Of interest are the last.ckpt and hparams.yaml files, which will be used while evaluating the trained model.

Evaluating your trained model

Once the trained model is available, you can use the eval.py file to generate the metrics and visualizations. Refer the command line arguments to understand further. A demo run is as follows:

 python eval.py --ckpt_path runs/n_dim=3,n_steps=50,lbeta=1.000e-05,ubeta=1.280e-02,batch_size=1024,n_epochs=500/last.ckpt \
                --hparams_path runs/n_dim=3,n_steps=50,lbeta=1.000e-05,ubeta=1.280e-02,batch_size=1024,n_epochs=500/lightning_logs/version_0/hparams.yaml \
                --eval_nll --vis_diffusion --vis_overlay

This evaluates the trained model on samples generated from $3$ runs, using only the negative log likelihood (--eval_nll). It also generates neat visualization of the diffusion process as gif animations.

Example plot generated with --vis_overlay.

image

Here, yellow-magenta points represent the original distribution and the blue-purple points indicate samples generated from a trained DDPM

Example animation produced with --vis_diffusion.

00 diffusionvis track_max=False track_min=False smoothed_end=True

Here, yellow-magenta points represent the original distribution and the blue-purple points indicate samples generated from a trained DDPM. Notice how the blue-purple points slowly become closer and closer to the original distribution as the reverse process progresses.

Acknowledgements

Special thanks to Kanad Pardeshi for generating the 3d_sin_5_5 and helix distributions and helping with the implementation of several evaluation metrics

explore-diffusion-cs726's People

Contributors

jimut123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.