Recommendation service for Danbooru
  • Python 91.8%
  • Dockerfile 8.2%
Find a file
2026-10-20 06:33:02 -05:00
.github/workflows Rebranding 2026-10-20 06:23:28 -05:00
data move empty to root 2025-11-08 16:57:46 -06:00
recommender Rebranding 2026-10-20 06:23:28 -05:00
scripts Add systemd-run scripts. 2019-12-01 01:26:38 -06:00
.gitignore move empty to root 2025-11-08 16:57:46 -06:00
Dockerfile Use Debian archive for bullseye packages 2026-10-20 06:33:02 -05:00
empty.pickle move empty to root 2025-11-08 16:57:46 -06:00
env.sample Add metrics 2026-07-12 08:10:27 -05:00
gunicorn.conf.py Add metrics 2026-07-12 08:10:27 -05:00
LICENSE Initial commit 2018-07-12 17:21:25 -07:00
poetry.lock Add metrics 2026-07-12 08:10:27 -05:00
pyproject.toml Add metrics 2026-07-12 08:10:27 -05:00
README.md Rebranding 2026-10-20 06:23:28 -05:00
train Remove systemd scripts. 2021-10-20 04:00:33 -05:00
wsgi.py Switch to poetry for managing dependencies. 2019-11-30 22:16:01 -06:00

Recommender

Post recommendation service for Fennec.

Quickstart

# Install pyenv (https://github.com/pyenv/pyenv)
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

# Install python dependencies
sudo apt install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev libffi-dev

# Install python
pyenv install 3.7.5

# Install dependency manager (https://poetry.eustace.io)
python -m pip install --user poetry

# Install dependencies
python -m poetry install

# Edit config file
cp env.sample .env
vim .env

# Train model
python -m poetry run python bin/train

# Run webserver (development)
python -m poetry run flask run
python -m poetry run gunicorn wsgi

# Get recommendations for user #1
curl http://localhost:5000/recommend/1

# Get recommendations for post #1
curl http://localhost:5000/similar/1

# Get model info (user/post counts, training time, etc.) as JSON
curl http://localhost:5000/info

# Get Prometheus metrics
curl http://localhost:5000/metrics

System requirements

Training on the full dataset of ~80 million favorites takes ~17 minutes (on an E5-1650v4) and requires ~4GB of RAM. The trained model requires ~2GB of RAM.