https://explainextended.com/2024/12/31/happy-new-year-16/
This repository contains the code for the article Happy New Year: Diffusion Model image generator in about 700 lines of pure SQL.
The SQL code described in the article runs on PostgreSQL 17.2.
To populate the tables, you need to run the script populate.py. This script will download the model files from HuggingFace, create database tables, and populate them with the model weights and biases.
- Docker
- Python 3.11 or later
-
Build and run the database image:
cd docker docker compose up -d -
Install Python dependencies:
pip install -r requirements.txt -
Populate the tables:
python populate.py --connection_string="postgresql://explainextended2025:MySecretPassword@localhost:5432/explainextended2025"Consider changing the password if your machine is exposed to the Internet.
-
The scripts mentioned in the article are located in the scripts directory.
The Jupyter notebook contains an implementation of Denoising Diffusion Probabilistic Model in about 130 lines of PyTorch code. It was used to verify the correctness of the SQL code.
Enjoy!