This is a standalone inference engine of diffusion models written in C. You can train the diffusion model in pytorch, then run the model with diffusion.c.
This is an experimental project, trying to rewrite diffusion model purely by basic operations in C without any "black boxes". The meat of this project was writing the C inference engine in diffusion.c.
For fast experiment, I used a very tiny model. you can train the model in minutes just by running
pip install -r requirement.txt
python train.py
After training, you will get a binary model file ckpt.bin
in the weights
folder.
compile diffusion.c with:
gcc -O3 -o diffusion diffusion.c -lm
deploy the inference code, simply run
./diffusion
The training code is adapted from minDiffusion and the deeplearning course
If you have any questions, feel free to reach out to me.