monbooru

module
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0

README

Monbooru

Your own self-hosted and lightweight booru.
Designed for organizing your local media collection, including AI-generated images (Stable Diffusion, ComfyUI, A1111/Forge). Works fully offline and with no telemetry. Supports ONNX models for local auto-tagging of your collection (WD14, JoyTag...).


Features

  • Tag-based gallery with folder tree, favorites, saved searches, related-image suggestions
  • A watcher that picks up new, moved, and deleted files in the gallery within a few seconds; and support for multi-file browser upload
  • Stable Diffusion metadata extraction from A1111/Forge and ComfyUI (prompts, models, seeds, full workflow)
  • Optional auto-tagging with local ONNX models (WD14, JoyTag, or any compatible model), CPU or GPU (CUDA)
  • Search with wildcards, OR, exclusions, plus filters on folder, date, size, dimensions, category, generation recipe...
  • Batch operations: bulk delete, bulk move, bulk auto-tag, delete-all-search-results, tag-all-search-results / tag-selected (add or remove tags in one go)
  • Create multiple galleries with their own filesystem and switch between them
  • Per-gallery export and import: full backup (.db, .json, .zip with images), or a light format (.json or .zip with images) with only images<->tags map. See docs/MIGRATING.md for migrating from another supported booru-style app.
  • REST API for third-party integrations (e.g. adding images to the gallery from an external app)
  • Daily maintenance schedule: scheduled sync, auto-tag, recompute counts, merge general tags, and vacuum databases...
  • Fully offline, no telemetry

Quick start (Docker)

Edit the volume paths in docker/docker-compose.yml, then docker compose up -d. The app is available at http://localhost:8080.


Search syntax

Tags separated by spaces means AND. Everything else stacks on top:

Syntax Effect
cat dog has both tags
cat OR dog either one
-blonde_hair exclude
blue* / *hair* wildcards
fav:true favorites only
source:a1111 / source:comfyui / source:none by metadata source
folder:2024/january images in this folder or any subfolder
folder:"my set 1" quote paths that contain spaces
folderonly:2024/january only images directly in this folder, no subfolders
width:>=1920 height:<768 dimensions
date:2024-03-15 date:>2024-01-01 date:2024-01..2024-06 dates
cat:character any tag in that category
character:cat tag "cat" in the character category
missing:true files gone from disk
animated:true / animated:false gif/mp4/webm
tagged:true / tagged:false images with or without tags
autotagged:true / autotagged:false images with or without auto-tags
generated:abcd1234abcd same generation recipe (hash shown on the image page)

Autocomplete is combination-aware: the count next to each suggestion is for the full query, and suggestions that would return zero results are hidden.

Sort options: newest, file size, random shuffle. Any query can be saved from the sidebar for one-click access later.


Tags

Five built-in categories (General, Character, Artist, Copyright, Meta), each with its own color. Custom categories with custom colors are also supported.

  • Add tags manually or let the auto-tagger do it
  • The same name can live in multiple categories (character:cat vs artist:cat)
  • Merge tags, rename, move between categories
  • Category-aware autocomplete: typing artist: limits suggestions to artist tags

Auto-tagger

You can use autotaggers to tag your images automatically.
Place a model in the models/ volume. Each tagger lives in its own subfolder with two files:

  • model.onnx, the weights
  • tags.csv in WD14 format (tag_id,name,category_id), or tags.txt with one label per line (all labels are assigned to general)

If neither default filename is present, monbooru picks the lone .onnx plus the lone .csv/.txt found in the folder, so models distributed with nonstandard names (e.g. top_tags.txt) work without extra config.

Restart the container after adding a model, then enable it in Settings → Auto-Tagger. Multiple taggers can run at the same time, and each tag records which tagger produced it. Auto-tags can be removed per tagger or all at once without touching manual tags.

Some models that have been tested :

Example setup (WD14 SwinV2):

MODEL_DIR=/data/monbooru/models
mkdir -p "$MODEL_DIR/wd-swinv2"

wget -O "$MODEL_DIR/wd-swinv2/model.onnx" \
  https://huggingface.co/SmilingWolf/wd-swinv2-tagger-v3/resolve/main/model.onnx

wget -O "$MODEL_DIR/wd-swinv2/tags.csv" \
  https://huggingface.co/SmilingWolf/wd-swinv2-tagger-v3/resolve/main/selected_tags.csv

If no tagger is enabled, auto-tagging is simply disabled. The rest of the app works normally.

GPU (CUDA)

The default image is CPU-only (~210 MB). For GPU inference, switch to the -cuda image (~2.3 GB), pass the GPU into the container the usual way, then enable Settings → Auto-Tagger → Use GPU (CUDA) (or set MONBOORU_TAGGER_USE_CUDA=true).

The current mode (GPU or CPU) is shown as a badge in the Auto-Tagger section. The -cuda image also runs on CPU when the toggle is off, so switching between the two does not require a rebuild. Worker count is configurable in Settings (default 8); increase it on GPU if preprocessing becomes the bottleneck.


Environment variables

All of these override the TOML config. Pattern: MONBOORU_{SECTION}_{KEY}.

Variable Overrides Type
MONBOORU_SERVER_BIND_ADDRESS server.bind_address string
MONBOORU_SERVER_BASE_URL server.base_url string
MONBOORU_PATHS_DATA_PATH paths.data_path string
MONBOORU_PATHS_MODEL_PATH paths.model_path string
MONBOORU_GALLERY_WATCH_ENABLED gallery.watch_enabled bool
MONBOORU_GALLERY_MAX_FILE_SIZE_MB gallery.max_file_size_mb int
MONBOORU_TAGGER_USE_CUDA tagger.use_cuda bool
MONBOORU_AUTH_ENABLE_PASSWORD auth.enable_password bool
MONBOORU_AUTH_PASSWORD_HASH auth.password_hash string
MONBOORU_AUTH_SESSION_LIFETIME_DAYS auth.session_lifetime_days int
MONBOORU_AUTH_API_TOKEN auth.api_token string
MONBOORU_UI_PAGE_SIZE ui.page_size int
MONBOORU_LOG_LEVEL log.level warn / info / debug

Per-tagger settings (enable flags, confidence thresholds, worker count) live in the Settings UI, not in env vars.


Keyboard shortcuts

Key Where Action
s Anywhere Focus search input
t Image detail Focus tag input
f Image detail Toggle favorite
Delete Image detail Delete image (advances to the next in the current search)
Space Image detail Play / pause the video
h / l Gallery Previous / next page
Arrows Gallery Navigate the grid
Enter Gallery Open focused image
/ Image detail Previous / next image
Escape Anywhere Close dialog, blur input, or go back

REST API

Disabled by default. Generate a token in Settings → Authentication to enable it.

  • HTML reference: /api/v1/docs (also linked in the footer)
  • OpenAPI spec: /api/v1/openapi.json

Covers search, tag add/remove, upload, delete.


Building without Docker

# CPU only, no auto-tagger
go build -o monbooru ./cmd/monbooru

# With auto-tagger (requires the ONNX Runtime shared library on the system)
CGO_ENABLED=1 go build -tags tagger -o monbooru ./cmd/monbooru

./monbooru -config /path/to/monbooru.toml

Inotify limit (Docker)

If the watcher reports an inotify limit error (logged as no space left on device from inotify_add_watch), raise fs.inotify.max_user_watches on the host (not inside the container) and restart. If you see too many open files, raise fs.inotify.max_user_instances. Alternatively, disable the watcher in Settings and use the manual Sync button when adding new files.


Warning

Intended for local network use. This project is not designed for direct exposure to the public internet.

Directories

Path Synopsis
cmd
monbooru command
internal
api
Package api implements the /api/v1/ REST handlers for monbooru.
Package api implements the /api/v1/ REST handlers for monbooru.
db
gallery
Monbooru is a Linux-only deployment; path handling assumes forward slashes.
Monbooru is a Linux-only deployment; path handling assumes forward slashes.
logx
Package logx is a thin level gate over the stdlib log package.
Package logx is a thin level gate over the stdlib log package.
search
Package search implements the Monbooru query language parser and SQL executor.
Package search implements the Monbooru query language parser and SQL executor.
web
web/compatibility
Package compatibility translates foreign gallery exports (zipped Hydrus exports, …) into the same in-memory shape the monbooru-native light import consumes.
Package compatibility translates foreign gallery exports (zipped Hydrus exports, …) into the same in-memory shape the monbooru-native light import consumes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL