8000 GitHub - aisk/loracraft: LoRA training workbench with dataset, run and result management · GitHub
[go: up one dir, main page]

Skip to content
aiskPublic

About

LoRA training workbench with dataset, run and result management

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

LoraCraft

A LoRA training workbench: manage datasets, captions, training runs and results in one place. SDXL first.

What it does

  • Dataset: import images with their captions, browse and filter by tag, edit tags one image at a time or in bulk, spot missing captions and undersized images.
  • Auto-captioning: a vision LLM (any OpenAI-compatible endpoint, local or hosted) writes captions according to what the LoRA is for: a character, a style or a concept. Results are suggestions you accept or discard; with a tag dictionary installed, invented tags are flagged or corrected.
  • Training: a self-contained SDXL LoRA trainer with plain-language setup, a queue, live progress and preview images after every round.
  • Results: preview images of every round side by side, pick the best round, export it.

Layout

src/loracraft/
  server/        FastAPI backend: projects, dataset, auto-captioning, run queue
  trainer/       SDXL LoRA trainer, runs as its own process
  vendor/kohya/  code adapted from kohya-ss/sd-scripts (Apache-2.0)
web/             Svelte frontend
tests/

Install

Requires Python 3.12. Training needs a GPU that PyTorch drives through CUDA or ROCm; the dataset and captioning tools work without one.

Apple Silicon (MPS) is wired up but has never been run on a Mac: expect it to need fixes. It trains in full precision only, so it wants a lot of memory. On a Mac, plain pip install loracraft is enough, since the PyTorch build on PyPI includes MPS.

Install PyTorch first, from the index that matches your GPU, then LoraCraft. Which index that is (CUDA version, ROCm, …) is listed at pytorch.org:

python -m venv .venv                 # then activate it
pip install torch --index-url <index for your GPU>
pip install loracraft

The order matters. LoraCraft accepts any PyTorch build, so the one you installed is kept; without one, pip install loracraft brings the default build from PyPI, which on Windows cannot use the GPU. If that happened, repeat the pip install torch … line with --force-reinstall. The training page tells you when the installed PyTorch cannot train.

Run

loracraft                            # http://127.0.0.1:8600
python -m loracraft --port 8700      # the same, on another port

To use it as an app in a window of its own rather than in a browser tab, install the app extra:

pip install "loracraft[app]"
loracraft --window

The window uses the system's web view: WebView2 on Windows (part of Windows 11), WKWebView on macOS; on Linux it needs GTK or Qt WebKit from the system packages, see the pywebview documentation. Closing the window does not stop a training run in progress: it carries on, and LoraCraft picks it up when started again.

User data (database, images, runs) lives in the per-user data directory, printed at startup: %LOCALAPPDATA%\loracraft on Windows, ~/Library/Application Support/loracraft on macOS, ~/.local/share/loracraft on Linux. Set LORACRAFT_HOME to keep it elsewhere.

Development

Requires uv and Node.js.

uv sync                              # Python environment, including PyTorch
cd web && npm install && npm run build
uv run loracraft

uv sync installs the torch-rocm dependency group, which pins PyTorch to the AMD ROCm build for Windows and RDNA2 cards (device-gfx1030). For another AMD card, change the device-gfx… names; for another vendor, replace the group.

npm run build writes the web UI into src/loracraft/web_dist/, from where the server serves it. For frontend work, run npm run dev in web/ alongside the server and open http://localhost:5600.

To build the distributions (the web UI must be built first):

uv build

To release, set the new version in pyproject.toml, commit, then tag that commit and push the tag. The release workflow builds the distributions, uploads them to PyPI and creates the GitHub release:

uv version 0.2.0                     # also updates uv.lock
git commit -am "🔖 Release 0.2.0"
git tag v0.2.0 && git push origin main v0.2.0

Training worker

A run is a directory containing config.json (see trainer/config.py):

python -m loracraft.trainer <run_dir>

It writes events.jsonl, checkpoints/ and samples/ into the same directory. Create a file named stop there to stop gracefully. Checkpoints use kohya's key names and metadata, so they load in ComfyUI and WebUI.

Tag dictionary

To validate Danbooru tags written by the vision model, put a tag list such as danbooru.csv (first column: tag name) into <workspace>/dictionaries/. Without one, validation is skipped.

Tests

uv run pytest

Third-party code

src/loracraft/vendor/kohya/ contains modified code from kohya-ss/sd-scripts, licensed under Apache-2.0. See the README in that directory for the source commit and the list of changes.

About

LoRA training workbench with dataset, run and result management

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0