Python repository by @bmaltais. AI agent rules & system prompts with 13k stars.
# kohya_ss
## Purpose
Gradio-based GUI and CLI front end for [kohya-ss/sd-scripts](https://github.com/kohya-ss/sd-scripts), used to configure and launch Stable Diffusion / SDXL / FLUX training runs (LoRA, DreamBooth, fine-tuning, TI) without hand-writing command lines.
## Ownership
- Maintainer: bmaltais
- `sd-scripts/` is a **git submodule** pointing at upstream kohya-ss/sd-scripts. Never edit files inside it โ GUI-side changes only. If a fix requires a sd-scripts change, describe it as a snippet in the PR body instead of committing to the submodule.
## Local Contracts
- Python 3.10โ3.11 (`pyproject.toml`), dependency management via `uv` (never bare `pip`).
- `kohya_gui.py` is the launcher entry point; it shares a name with the `kohya_gui/` package, so anything loading it dynamically (see `test/test_allowed_paths.py`) must import by file path, not `import kohya_gui`.
- Config precedence: `config.toml` (user, gitignored) vs `config example.toml` (tracked template) โ copy, don't edit the example in place.
- Secrets (API tokens, HF keys) go through env vars / `config.toml`, never hardcoded.
## Work Guidance
- Black formatting on Python changes before commit.
- Keep GUI-only changes decoupled from submodule internals โ call `sd-scripts` via its existing CLI/library surface, don't reach into its internals from `kohya_gui/`.
- Before a refactor touching >300 LOC, strip dead props/exports/debug logging first, as its own commit.
## Verification
- `.github/workflows/typos.yaml` runs `crate-ci/typos` on push/PR โ fix flagged typos before merging.
- `tests/` holds the pytest regression suite; `test/test_allowed_paths.py` is a standalone unittest. Run both before shipping GUI changes (`pytest tests/ test/test_allowed_paths.py`).
- No `tsc`/`eslint` equivalent exists (pure Python project) โ rely on the tests above plus manual GUI smoke-test via `gui.sh` / `gui.bat`.
## Child DOX Index
- `kohya_gui/AGENTS.md` โ Gradio GUI package (tabs, shared widget classes, launcher helpers)
- `tools/AGENTS.md` โ standalone CLI utility scripts (extraction, conversion, captioning)
- `docs/AGENTS.md` โ feature guides and localized documentation
- `tests/AGENTS.md` โ pytest regression suite
- `test/AGENTS.md` โ manual end-to-end scratch fixtures and the allowed-paths unittest
- `sd-scripts/` โ upstream submodule, out of scope for local AGENTS.md (do not create one; see Ownership above)