{"owner":"bmaltais","repo":"kohya_ss","hasSkills":true,"totalSkillsCount":6,"totalTokensCount":2963,"categories":["root-instruction"],"hasMcp":false,"mcpConfig":null,"found":["docs/AGENTS.md","tests/AGENTS.md","tools/AGENTS.md","AGENTS.md","test/AGENTS.md","kohya_gui/AGENTS.md"],"skills":{"docs/AGENTS.md":"# docs/\n\n## Purpose\n\nReference documentation supplementing the root `README.md`: per-feature guides, installation instructions, and localized (`-ja`/`-zh`) copies of training READMEs.\n\n## Ownership\n\nContent-only; no code. Owned jointly by whoever maintains the referenced feature.\n\n## Local Contracts\n\n- `Installation/` — per-platform/package-manager install guides (`pip_linux.md`, `pip_windows.md`, `uv_linux.md`, `uv_windows.md`).\n- `LoRA/`, `Finetuning/` — feature-specific guides, each with a `top_level.md` overview.\n- Root-level `*_README.md` / `*_README-ja.md` / `*_README-zh.md` pairs are translated copies — when updating an English doc that has translated siblings, note in the PR that translations are now stale (translations are community-maintained, not auto-synced).\n- `image_folder_structure.md`, `troubleshooting_tesla_v100.md`, `installation_docker.md`, `installation_runpod.md`, `installation_novita.md` are standalone single-topic guides, not part of a series.\n\n## Work Guidance\n\n- New feature guides should follow the existing `<Feature>/top_level.md` pattern rather than a single flat file, if the feature is expected to grow multiple sub-topics (options, troubleshooting, etc.) — otherwise a flat root-level `.md` is fine.\n- Don't duplicate installation steps already covered in the root `README.md`'s Installation Options section; link to it instead.\n\n## Verification\n\n- `.github/workflows/typos.yaml` lints spelling across the repo, docs included.\n\n## Child DOX Index\n\nNone — sub-folders here are content collections, not durable code boundaries.\n","tests/AGENTS.md":"# tests/\n\n## Purpose\n\nPytest/unittest regression suite for `kohya_gui/` behavior that's cheap to isolate (no GPU, no model weights).\n\n## Ownership\n\nMirrors `kohya_gui/` — tests here target that package's pure-Python logic (e.g. `class_tensorboard.py`'s AVX/tensorboard-availability detection).\n\n## Local Contracts\n\n- One `test_<module_under_test>.py` per targeted `kohya_gui/` module; use `importlib.reload` on the target module inside each test when the module has import-time side effects that need re-triggering under different mocked conditions (see `test_tensorboard_visibility.py`).\n- Mock external/environment dependencies (`shutil.which`, `cpuinfo.get_cpu_info`, hardware/OS checks) — this suite must run without a GPU or real tensorboard/cpuinfo state.\n- Distinct from `test/` (singular) at the repo root, which holds manual end-to-end scratch fixtures and outputs, not unit tests — see `test/AGENTS.md`.\n\n## Work Guidance\n\n- New pure-logic additions to `kohya_gui/` (config parsing, capability detection, validation helpers) should get a unit test here rather than only being smoke-tested through the GUI.\n\n## Verification\n\n- Run with `pytest tests/`.\n\n## Child DOX Index\n\nNone.\n","tools/AGENTS.md":"# tools/\n\n## Purpose\n\nStandalone CLI scripts for dataset prep, model/LoRA conversion, and one-off maintenance tasks. Independent of the Gradio app — each script is runnable directly with `python tools/<script>.py`.\n\n## Ownership\n\nUtility layer; not wired into the `kohya_gui/` tabs unless a `*_gui.py` file explicitly shells out to one (e.g. LoRA extraction/merge tools back the corresponding `extract_*_gui.py` / `merge_*_gui.py` tabs).\n\n## Local Contracts\n\n- Each script is self-contained with its own argparse CLI — no shared entry point or package `__init__.py`.\n- `lycoris_utils.py` is a shared helper module imported by the `lycoris_locon_extract.py` / `merge_lycoris.py` scripts — keep LyCORIS-specific logic there rather than duplicating it per script.\n- Image dataset scripts (`crop_images_to_n_buckets.py`, `group_images.py`, `group_images_recommended_size.py`, `create_txt_from_images.py`, `rename_depth_mask.py`) operate in place on a target folder passed via CLI arg — they mutate/rename files, so treat them as destructive unless run with a `--dry-run`-style flag where supported.\n- Model/LoRA conversion and merge scripts (`extract_locon.py`, `extract_loha_from_model.py`, `extract_lora_from_models-new.py`, `extract_model_difference.py`, `merge_lycoris.py`, `resize_lora.py`, `prune.py`, `lcm_convert.py`) read/write `.safetensors` files and should not modify inputs in place — always write to a new output path.\n\n## Work Guidance\n\n- New one-off maintenance scripts belong here, not in `kohya_gui/`, unless they need a GUI tab.\n- Prefer extending `lycoris_utils.py` for LyCORIS format changes rather than editing extraction logic per-script.\n\n## Verification\n\nNone currently — no automated tests cover this folder; verify manually against a sample model/dataset before relying on a script's output.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n","AGENTS.md":"# kohya_ss\n\n## Purpose\n\nGradio-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.\n\n## Ownership\n\n- Maintainer: bmaltais\n- `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.\n\n## Local Contracts\n\n- Python 3.10–3.11 (`pyproject.toml`), dependency management via `uv` (never bare `pip`).\n- `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`.\n- Config precedence: `config.toml` (user, gitignored) vs `config example.toml` (tracked template) — copy, don't edit the example in place.\n- Secrets (API tokens, HF keys) go through env vars / `config.toml`, never hardcoded.\n\n## Work Guidance\n\n- Black formatting on Python changes before commit.\n- 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/`.\n- Before a refactor touching >300 LOC, strip dead props/exports/debug logging first, as its own commit.\n\n## Verification\n\n- `.github/workflows/typos.yaml` runs `crate-ci/typos` on push/PR — fix flagged typos before merging.\n- `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`).\n- No `tsc`/`eslint` equivalent exists (pure Python project) — rely on the tests above plus manual GUI smoke-test via `gui.sh` / `gui.bat`.\n\n## Child DOX Index\n\n- `kohya_gui/AGENTS.md` — Gradio GUI package (tabs, shared widget classes, launcher helpers)\n- `tools/AGENTS.md` — standalone CLI utility scripts (extraction, conversion, captioning)\n- `docs/AGENTS.md` — feature guides and localized documentation\n- `tests/AGENTS.md` — pytest regression suite\n- `test/AGENTS.md` — manual end-to-end scratch fixtures and the allowed-paths unittest\n- `sd-scripts/` — upstream submodule, out of scope for local AGENTS.md (do not create one; see Ownership above)\n","test/AGENTS.md":"# test/\n\n## Purpose\n\nManual end-to-end scratch space for exercising real training runs through the GUI/CLI, plus one standalone unittest for launcher behavior. Distinct from `tests/` (plural) at the repo root, which is the automated pytest suite — see `tests/AGENTS.md`.\n\n## Ownership\n\nMixed: `test_allowed_paths.py` is a real regression test; everything else (`config/`, `ft/`, `log/`, `logs/`, `masked_loss/`, `output/`, `img*/`) is generated/scratch data from manual runs, not curated fixtures.\n\n## Local Contracts\n\n- `test_allowed_paths.py` loads the root `kohya_gui.py` launcher by file path (via `importlib.util.spec_from_file_location`), not `import kohya_gui`, because the launcher script and the `kohya_gui/` package share a name — follow the same pattern for any new launcher-level test.\n- `config/` holds sample training preset JSON/TOML files (dreambooth, LoRA, LoCon, LoHa, LoKR, DyLoRA, TI, SDXL variants) used as real inputs when manually exercising a tab end-to-end.\n- `masked_loss/` holds a small fixed sample image set used to manually verify masked-loss training.\n- `logs/`, `log/`, `ft/`, `output/` are run artifacts (tensorboard logs, checkpoints, generated configs) from prior manual test runs — timestamped, disposable, safe to prune; not meant to be committed as fixtures going forward.\n- `img with spaces/` exists specifically to catch path-quoting bugs in generated CLI commands — keep the space in the folder name.\n\n## Work Guidance\n\n- New launcher/CLI-argument-forwarding tests belong here as standalone unittests, following `test_allowed_paths.py`'s import pattern.\n- New pure-logic unit tests for `kohya_gui/` modules belong in `tests/` instead.\n- Don't commit new large run artifacts under `logs/`/`output/`/`ft/` — clean up scratch runs rather than checking them in.\n\n## Verification\n\n- Run with `pytest test/test_allowed_paths.py` (or `python -m unittest test.test_allowed_paths`).\n\n## Child DOX Index\n\nNone.\n","kohya_gui/AGENTS.md":"# kohya_gui/\n\n## Purpose\n\nGradio UI package that builds every tab in the kohya_ss app and translates form inputs into `sd-scripts` CLI invocations. Owned by the root `AGENTS.md`; see it for submodule and dependency rules.\n\n## Ownership\n\nPart of the GUI front end. No files here belong to `sd-scripts` — this package only calls it (via `class_command_executor.py` / subprocess), never imports its internals directly.\n\n## Local Contracts\n\n- `<feature>_gui.py` files (e.g. `lora_gui.py`, `dreambooth_gui.py`, `finetune_gui.py`) each build one Gradio tab and are self-contained entry points.\n- `class_*.py` files are shared, stateful widget groups reused across multiple tabs (e.g. `class_basic_training.py`, `class_advanced_training.py`, `class_source_model.py`, `class_folders.py`, `class_accelerate_launch.py`) — extend these instead of duplicating widget layout in a feature file.\n- `common_gui.py` holds shared helpers (path pickers, config load/save, validation) used across both `class_*` and `*_gui.py` files — put new cross-tab utilities here, not in a feature file.\n- `class_command_executor.py` is the only place that shells out to `sd-scripts` training scripts; new training features should route through it rather than spawning subprocesses ad hoc.\n- `class_gui_config.py` / `class_configuration_file.py` own reading and writing the JSON/TOML preset files under `presets/` and `config_files/` — don't hand-roll config serialization elsewhere.\n- `localization.py` / `localization_ext.py` own i18n string loading from `localizations/`.\n\n## Work Guidance\n\n- When adding a new training method tab, follow the existing `*_gui.py` + shared `class_*` composition pattern rather than inlining a monolithic tab.\n- Keep widget classes decoupled from each other; compose them inside the feature file instead of having one `class_*` reach into another.\n\n## Verification\n\n- No dedicated unit tests for this package yet beyond `test/test_allowed_paths.py` (launcher-level) — smoke-test new/changed tabs by launching the GUI (`gui.sh` / `gui.bat`) and exercising the tab manually.\n- **Launching as an agent (non-interactive/background shell):** use the same invocation as the `gui-uv.*` launcher scripts, not a bare `uv run python kohya_gui.py`:\n  - Cross-platform baseline (matches `gui-uv.sh`): `uv run kohya_gui.py --noverify`\n  - Windows (matches `gui-uv.bat`): add `--link-mode=copy --index-strategy unsafe-best-match` before the script name, i.e. `uv run --link-mode=copy --index-strategy unsafe-best-match kohya_gui.py --noverify`\n  Without `--noverify`, kohya_gui.py re-validates/reinstalls requirements every launch (slow, and reinstalls the editable `sd-scripts` package unnecessarily).\n  When stdout is piped to a background-process log file (not a TTY), Python buffers it — the `* Running on local URL: ...` line may not appear in the log for a long time even though the server is already up. Don't treat a quiet log as a hang: poll the HTTP endpoint instead (`curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7860/`, expect `200`) rather than grepping the log for the ready banner.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n"},"files":{"docs/AGENTS.md":"# docs/\n\n## Purpose\n\nReference documentation supplementing the root `README.md`: per-feature guides, installation instructions, and localized (`-ja`/`-zh`) copies of training READMEs.\n\n## Ownership\n\nContent-only; no code. Owned jointly by whoever maintains the referenced feature.\n\n## Local Contracts\n\n- `Installation/` — per-platform/package-manager install guides (`pip_linux.md`, `pip_windows.md`, `uv_linux.md`, `uv_windows.md`).\n- `LoRA/`, `Finetuning/` — feature-specific guides, each with a `top_level.md` overview.\n- Root-level `*_README.md` / `*_README-ja.md` / `*_README-zh.md` pairs are translated copies — when updating an English doc that has translated siblings, note in the PR that translations are now stale (translations are community-maintained, not auto-synced).\n- `image_folder_structure.md`, `troubleshooting_tesla_v100.md`, `installation_docker.md`, `installation_runpod.md`, `installation_novita.md` are standalone single-topic guides, not part of a series.\n\n## Work Guidance\n\n- New feature guides should follow the existing `<Feature>/top_level.md` pattern rather than a single flat file, if the feature is expected to grow multiple sub-topics (options, troubleshooting, etc.) — otherwise a flat root-level `.md` is fine.\n- Don't duplicate installation steps already covered in the root `README.md`'s Installation Options section; link to it instead.\n\n## Verification\n\n- `.github/workflows/typos.yaml` lints spelling across the repo, docs included.\n\n## Child DOX Index\n\nNone — sub-folders here are content collections, not durable code boundaries.\n","tests/AGENTS.md":"# tests/\n\n## Purpose\n\nPytest/unittest regression suite for `kohya_gui/` behavior that's cheap to isolate (no GPU, no model weights).\n\n## Ownership\n\nMirrors `kohya_gui/` — tests here target that package's pure-Python logic (e.g. `class_tensorboard.py`'s AVX/tensorboard-availability detection).\n\n## Local Contracts\n\n- One `test_<module_under_test>.py` per targeted `kohya_gui/` module; use `importlib.reload` on the target module inside each test when the module has import-time side effects that need re-triggering under different mocked conditions (see `test_tensorboard_visibility.py`).\n- Mock external/environment dependencies (`shutil.which`, `cpuinfo.get_cpu_info`, hardware/OS checks) — this suite must run without a GPU or real tensorboard/cpuinfo state.\n- Distinct from `test/` (singular) at the repo root, which holds manual end-to-end scratch fixtures and outputs, not unit tests — see `test/AGENTS.md`.\n\n## Work Guidance\n\n- New pure-logic additions to `kohya_gui/` (config parsing, capability detection, validation helpers) should get a unit test here rather than only being smoke-tested through the GUI.\n\n## Verification\n\n- Run with `pytest tests/`.\n\n## Child DOX Index\n\nNone.\n","tools/AGENTS.md":"# tools/\n\n## Purpose\n\nStandalone CLI scripts for dataset prep, model/LoRA conversion, and one-off maintenance tasks. Independent of the Gradio app — each script is runnable directly with `python tools/<script>.py`.\n\n## Ownership\n\nUtility layer; not wired into the `kohya_gui/` tabs unless a `*_gui.py` file explicitly shells out to one (e.g. LoRA extraction/merge tools back the corresponding `extract_*_gui.py` / `merge_*_gui.py` tabs).\n\n## Local Contracts\n\n- Each script is self-contained with its own argparse CLI — no shared entry point or package `__init__.py`.\n- `lycoris_utils.py` is a shared helper module imported by the `lycoris_locon_extract.py` / `merge_lycoris.py` scripts — keep LyCORIS-specific logic there rather than duplicating it per script.\n- Image dataset scripts (`crop_images_to_n_buckets.py`, `group_images.py`, `group_images_recommended_size.py`, `create_txt_from_images.py`, `rename_depth_mask.py`) operate in place on a target folder passed via CLI arg — they mutate/rename files, so treat them as destructive unless run with a `--dry-run`-style flag where supported.\n- Model/LoRA conversion and merge scripts (`extract_locon.py`, `extract_loha_from_model.py`, `extract_lora_from_models-new.py`, `extract_model_difference.py`, `merge_lycoris.py`, `resize_lora.py`, `prune.py`, `lcm_convert.py`) read/write `.safetensors` files and should not modify inputs in place — always write to a new output path.\n\n## Work Guidance\n\n- New one-off maintenance scripts belong here, not in `kohya_gui/`, unless they need a GUI tab.\n- Prefer extending `lycoris_utils.py` for LyCORIS format changes rather than editing extraction logic per-script.\n\n## Verification\n\nNone currently — no automated tests cover this folder; verify manually against a sample model/dataset before relying on a script's output.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n","AGENTS.md":"# kohya_ss\n\n## Purpose\n\nGradio-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.\n\n## Ownership\n\n- Maintainer: bmaltais\n- `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.\n\n## Local Contracts\n\n- Python 3.10–3.11 (`pyproject.toml`), dependency management via `uv` (never bare `pip`).\n- `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`.\n- Config precedence: `config.toml` (user, gitignored) vs `config example.toml` (tracked template) — copy, don't edit the example in place.\n- Secrets (API tokens, HF keys) go through env vars / `config.toml`, never hardcoded.\n\n## Work Guidance\n\n- Black formatting on Python changes before commit.\n- 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/`.\n- Before a refactor touching >300 LOC, strip dead props/exports/debug logging first, as its own commit.\n\n## Verification\n\n- `.github/workflows/typos.yaml` runs `crate-ci/typos` on push/PR — fix flagged typos before merging.\n- `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`).\n- No `tsc`/`eslint` equivalent exists (pure Python project) — rely on the tests above plus manual GUI smoke-test via `gui.sh` / `gui.bat`.\n\n## Child DOX Index\n\n- `kohya_gui/AGENTS.md` — Gradio GUI package (tabs, shared widget classes, launcher helpers)\n- `tools/AGENTS.md` — standalone CLI utility scripts (extraction, conversion, captioning)\n- `docs/AGENTS.md` — feature guides and localized documentation\n- `tests/AGENTS.md` — pytest regression suite\n- `test/AGENTS.md` — manual end-to-end scratch fixtures and the allowed-paths unittest\n- `sd-scripts/` — upstream submodule, out of scope for local AGENTS.md (do not create one; see Ownership above)\n","test/AGENTS.md":"# test/\n\n## Purpose\n\nManual end-to-end scratch space for exercising real training runs through the GUI/CLI, plus one standalone unittest for launcher behavior. Distinct from `tests/` (plural) at the repo root, which is the automated pytest suite — see `tests/AGENTS.md`.\n\n## Ownership\n\nMixed: `test_allowed_paths.py` is a real regression test; everything else (`config/`, `ft/`, `log/`, `logs/`, `masked_loss/`, `output/`, `img*/`) is generated/scratch data from manual runs, not curated fixtures.\n\n## Local Contracts\n\n- `test_allowed_paths.py` loads the root `kohya_gui.py` launcher by file path (via `importlib.util.spec_from_file_location`), not `import kohya_gui`, because the launcher script and the `kohya_gui/` package share a name — follow the same pattern for any new launcher-level test.\n- `config/` holds sample training preset JSON/TOML files (dreambooth, LoRA, LoCon, LoHa, LoKR, DyLoRA, TI, SDXL variants) used as real inputs when manually exercising a tab end-to-end.\n- `masked_loss/` holds a small fixed sample image set used to manually verify masked-loss training.\n- `logs/`, `log/`, `ft/`, `output/` are run artifacts (tensorboard logs, checkpoints, generated configs) from prior manual test runs — timestamped, disposable, safe to prune; not meant to be committed as fixtures going forward.\n- `img with spaces/` exists specifically to catch path-quoting bugs in generated CLI commands — keep the space in the folder name.\n\n## Work Guidance\n\n- New launcher/CLI-argument-forwarding tests belong here as standalone unittests, following `test_allowed_paths.py`'s import pattern.\n- New pure-logic unit tests for `kohya_gui/` modules belong in `tests/` instead.\n- Don't commit new large run artifacts under `logs/`/`output/`/`ft/` — clean up scratch runs rather than checking them in.\n\n## Verification\n\n- Run with `pytest test/test_allowed_paths.py` (or `python -m unittest test.test_allowed_paths`).\n\n## Child DOX Index\n\nNone.\n","kohya_gui/AGENTS.md":"# kohya_gui/\n\n## Purpose\n\nGradio UI package that builds every tab in the kohya_ss app and translates form inputs into `sd-scripts` CLI invocations. Owned by the root `AGENTS.md`; see it for submodule and dependency rules.\n\n## Ownership\n\nPart of the GUI front end. No files here belong to `sd-scripts` — this package only calls it (via `class_command_executor.py` / subprocess), never imports its internals directly.\n\n## Local Contracts\n\n- `<feature>_gui.py` files (e.g. `lora_gui.py`, `dreambooth_gui.py`, `finetune_gui.py`) each build one Gradio tab and are self-contained entry points.\n- `class_*.py` files are shared, stateful widget groups reused across multiple tabs (e.g. `class_basic_training.py`, `class_advanced_training.py`, `class_source_model.py`, `class_folders.py`, `class_accelerate_launch.py`) — extend these instead of duplicating widget layout in a feature file.\n- `common_gui.py` holds shared helpers (path pickers, config load/save, validation) used across both `class_*` and `*_gui.py` files — put new cross-tab utilities here, not in a feature file.\n- `class_command_executor.py` is the only place that shells out to `sd-scripts` training scripts; new training features should route through it rather than spawning subprocesses ad hoc.\n- `class_gui_config.py` / `class_configuration_file.py` own reading and writing the JSON/TOML preset files under `presets/` and `config_files/` — don't hand-roll config serialization elsewhere.\n- `localization.py` / `localization_ext.py` own i18n string loading from `localizations/`.\n\n## Work Guidance\n\n- When adding a new training method tab, follow the existing `*_gui.py` + shared `class_*` composition pattern rather than inlining a monolithic tab.\n- Keep widget classes decoupled from each other; compose them inside the feature file instead of having one `class_*` reach into another.\n\n## Verification\n\n- No dedicated unit tests for this package yet beyond `test/test_allowed_paths.py` (launcher-level) — smoke-test new/changed tabs by launching the GUI (`gui.sh` / `gui.bat`) and exercising the tab manually.\n- **Launching as an agent (non-interactive/background shell):** use the same invocation as the `gui-uv.*` launcher scripts, not a bare `uv run python kohya_gui.py`:\n  - Cross-platform baseline (matches `gui-uv.sh`): `uv run kohya_gui.py --noverify`\n  - Windows (matches `gui-uv.bat`): add `--link-mode=copy --index-strategy unsafe-best-match` before the script name, i.e. `uv run --link-mode=copy --index-strategy unsafe-best-match kohya_gui.py --noverify`\n  Without `--noverify`, kohya_gui.py re-validates/reinstalls requirements every launch (slow, and reinstalls the editable `sd-scripts` package unnecessarily).\n  When stdout is piped to a background-process log file (not a TTY), Python buffers it — the `* Running on local URL: ...` line may not appear in the log for a long time even though the server is already up. Don't treat a quiet log as a hang: poll the HTTP endpoint instead (`curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7860/`, expect `200`) rather than grepping the log for the ready banner.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n"},"items":[{"name":"AGENTS.md","path":"AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/AGENTS.md","title":"AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# kohya_ss\n\n## Purpose\n\nGradio-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.\n\n## Ownership\n\n- Maintainer: bmaltais\n- `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.\n\n## Local Contracts\n\n- Python 3.10–3.11 (`pyproject.toml`), dependency management via `uv` (never bare `pip`).\n- `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`.\n- Config precedence: `config.toml` (user, gitignored) vs `config example.toml` (tracked template) — copy, don't edit the example in place.\n- Secrets (API tokens, HF keys) go through env vars / `config.toml`, never hardcoded.\n\n## Work Guidance\n\n- Black formatting on Python changes before commit.\n- 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/`.\n- Before a refactor touching >300 LOC, strip dead props/exports/debug logging first, as its own commit.\n\n## Verification\n\n- `.github/workflows/typos.yaml` runs `crate-ci/typos` on push/PR — fix flagged typos before merging.\n- `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`).\n- No `tsc`/`eslint` equivalent exists (pure Python project) — rely on the tests above plus manual GUI smoke-test via `gui.sh` / `gui.bat`.\n\n## Child DOX Index\n\n- `kohya_gui/AGENTS.md` — Gradio GUI package (tabs, shared widget classes, launcher helpers)\n- `tools/AGENTS.md` — standalone CLI utility scripts (extraction, conversion, captioning)\n- `docs/AGENTS.md` — feature guides and localized documentation\n- `tests/AGENTS.md` — pytest regression suite\n- `test/AGENTS.md` — manual end-to-end scratch fixtures and the allowed-paths unittest\n- `sd-scripts/` — upstream submodule, out of scope for local AGENTS.md (do not create one; see Ownership above)\n","isInternal":false,"tokens":616,"sizeBytes":2434},{"name":"AGENTS.md","path":"docs/AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/docs/AGENTS.md","title":"docs - AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# docs/\n\n## Purpose\n\nReference documentation supplementing the root `README.md`: per-feature guides, installation instructions, and localized (`-ja`/`-zh`) copies of training READMEs.\n\n## Ownership\n\nContent-only; no code. Owned jointly by whoever maintains the referenced feature.\n\n## Local Contracts\n\n- `Installation/` — per-platform/package-manager install guides (`pip_linux.md`, `pip_windows.md`, `uv_linux.md`, `uv_windows.md`).\n- `LoRA/`, `Finetuning/` — feature-specific guides, each with a `top_level.md` overview.\n- Root-level `*_README.md` / `*_README-ja.md` / `*_README-zh.md` pairs are translated copies — when updating an English doc that has translated siblings, note in the PR that translations are now stale (translations are community-maintained, not auto-synced).\n- `image_folder_structure.md`, `troubleshooting_tesla_v100.md`, `installation_docker.md`, `installation_runpod.md`, `installation_novita.md` are standalone single-topic guides, not part of a series.\n\n## Work Guidance\n\n- New feature guides should follow the existing `<Feature>/top_level.md` pattern rather than a single flat file, if the feature is expected to grow multiple sub-topics (options, troubleshooting, etc.) — otherwise a flat root-level `.md` is fine.\n- Don't duplicate installation steps already covered in the root `README.md`'s Installation Options section; link to it instead.\n\n## Verification\n\n- `.github/workflows/typos.yaml` lints spelling across the repo, docs included.\n\n## Child DOX Index\n\nNone — sub-folders here are content collections, not durable code boundaries.\n","isInternal":false,"tokens":359,"sizeBytes":1582},{"name":"AGENTS.md","path":"kohya_gui/AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/kohya_gui/AGENTS.md","title":"kohya_gui - AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# kohya_gui/\n\n## Purpose\n\nGradio UI package that builds every tab in the kohya_ss app and translates form inputs into `sd-scripts` CLI invocations. Owned by the root `AGENTS.md`; see it for submodule and dependency rules.\n\n## Ownership\n\nPart of the GUI front end. No files here belong to `sd-scripts` — this package only calls it (via `class_command_executor.py` / subprocess), never imports its internals directly.\n\n## Local Contracts\n\n- `<feature>_gui.py` files (e.g. `lora_gui.py`, `dreambooth_gui.py`, `finetune_gui.py`) each build one Gradio tab and are self-contained entry points.\n- `class_*.py` files are shared, stateful widget groups reused across multiple tabs (e.g. `class_basic_training.py`, `class_advanced_training.py`, `class_source_model.py`, `class_folders.py`, `class_accelerate_launch.py`) — extend these instead of duplicating widget layout in a feature file.\n- `common_gui.py` holds shared helpers (path pickers, config load/save, validation) used across both `class_*` and `*_gui.py` files — put new cross-tab utilities here, not in a feature file.\n- `class_command_executor.py` is the only place that shells out to `sd-scripts` training scripts; new training features should route through it rather than spawning subprocesses ad hoc.\n- `class_gui_config.py` / `class_configuration_file.py` own reading and writing the JSON/TOML preset files under `presets/` and `config_files/` — don't hand-roll config serialization elsewhere.\n- `localization.py` / `localization_ext.py` own i18n string loading from `localizations/`.\n\n## Work Guidance\n\n- When adding a new training method tab, follow the existing `*_gui.py` + shared `class_*` composition pattern rather than inlining a monolithic tab.\n- Keep widget classes decoupled from each other; compose them inside the feature file instead of having one `class_*` reach into another.\n\n## Verification\n\n- No dedicated unit tests for this package yet beyond `test/test_allowed_paths.py` (launcher-level) — smoke-test new/changed tabs by launching the GUI (`gui.sh` / `gui.bat`) and exercising the tab manually.\n- **Launching as an agent (non-interactive/background shell):** use the same invocation as the `gui-uv.*` launcher scripts, not a bare `uv run python kohya_gui.py`:\n  - Cross-platform baseline (matches `gui-uv.sh`): `uv run kohya_gui.py --noverify`\n  - Windows (matches `gui-uv.bat`): add `--link-mode=copy --index-strategy unsafe-best-match` before the script name, i.e. `uv run --link-mode=copy --index-strategy unsafe-best-match kohya_gui.py --noverify`\n  Without `--noverify`, kohya_gui.py re-validates/reinstalls requirements every launch (slow, and reinstalls the editable `sd-scripts` package unnecessarily).\n  When stdout is piped to a background-process log file (not a TTY), Python buffers it — the `* Running on local URL: ...` line may not appear in the log for a long time even though the server is already up. Don't treat a quiet log as a hang: poll the HTTP endpoint instead (`curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7860/`, expect `200`) rather than grepping the log for the ready banner.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n","isInternal":false,"tokens":778,"sizeBytes":3180},{"name":"AGENTS.md","path":"test/AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/test/AGENTS.md","title":"test - AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# test/\n\n## Purpose\n\nManual end-to-end scratch space for exercising real training runs through the GUI/CLI, plus one standalone unittest for launcher behavior. Distinct from `tests/` (plural) at the repo root, which is the automated pytest suite — see `tests/AGENTS.md`.\n\n## Ownership\n\nMixed: `test_allowed_paths.py` is a real regression test; everything else (`config/`, `ft/`, `log/`, `logs/`, `masked_loss/`, `output/`, `img*/`) is generated/scratch data from manual runs, not curated fixtures.\n\n## Local Contracts\n\n- `test_allowed_paths.py` loads the root `kohya_gui.py` launcher by file path (via `importlib.util.spec_from_file_location`), not `import kohya_gui`, because the launcher script and the `kohya_gui/` package share a name — follow the same pattern for any new launcher-level test.\n- `config/` holds sample training preset JSON/TOML files (dreambooth, LoRA, LoCon, LoHa, LoKR, DyLoRA, TI, SDXL variants) used as real inputs when manually exercising a tab end-to-end.\n- `masked_loss/` holds a small fixed sample image set used to manually verify masked-loss training.\n- `logs/`, `log/`, `ft/`, `output/` are run artifacts (tensorboard logs, checkpoints, generated configs) from prior manual test runs — timestamped, disposable, safe to prune; not meant to be committed as fixtures going forward.\n- `img with spaces/` exists specifically to catch path-quoting bugs in generated CLI commands — keep the space in the folder name.\n\n## Work Guidance\n\n- New launcher/CLI-argument-forwarding tests belong here as standalone unittests, following `test_allowed_paths.py`'s import pattern.\n- New pure-logic unit tests for `kohya_gui/` modules belong in `tests/` instead.\n- Don't commit new large run artifacts under `logs/`/`output/`/`ft/` — clean up scratch runs rather than checking them in.\n\n## Verification\n\n- Run with `pytest test/test_allowed_paths.py` (or `python -m unittest test.test_allowed_paths`).\n\n## Child DOX Index\n\nNone.\n","isInternal":false,"tokens":480,"sizeBytes":1952},{"name":"AGENTS.md","path":"tests/AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/tests/AGENTS.md","title":"tests - AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# tests/\n\n## Purpose\n\nPytest/unittest regression suite for `kohya_gui/` behavior that's cheap to isolate (no GPU, no model weights).\n\n## Ownership\n\nMirrors `kohya_gui/` — tests here target that package's pure-Python logic (e.g. `class_tensorboard.py`'s AVX/tensorboard-availability detection).\n\n## Local Contracts\n\n- One `test_<module_under_test>.py` per targeted `kohya_gui/` module; use `importlib.reload` on the target module inside each test when the module has import-time side effects that need re-triggering under different mocked conditions (see `test_tensorboard_visibility.py`).\n- Mock external/environment dependencies (`shutil.which`, `cpuinfo.get_cpu_info`, hardware/OS checks) — this suite must run without a GPU or real tensorboard/cpuinfo state.\n- Distinct from `test/` (singular) at the repo root, which holds manual end-to-end scratch fixtures and outputs, not unit tests — see `test/AGENTS.md`.\n\n## Work Guidance\n\n- New pure-logic additions to `kohya_gui/` (config parsing, capability detection, validation helpers) should get a unit test here rather than only being smoke-tested through the GUI.\n\n## Verification\n\n- Run with `pytest tests/`.\n\n## Child DOX Index\n\nNone.\n","isInternal":false,"tokens":284,"sizeBytes":1195},{"name":"AGENTS.md","path":"tools/AGENTS.md","rawUrl":"https://raw.githubusercontent.com/bmaltais/kohya_ss/HEAD/tools/AGENTS.md","title":"tools - AI Agent Protocol & Instructions","category":"root-instruction","format":"markdown","content":"# tools/\n\n## Purpose\n\nStandalone CLI scripts for dataset prep, model/LoRA conversion, and one-off maintenance tasks. Independent of the Gradio app — each script is runnable directly with `python tools/<script>.py`.\n\n## Ownership\n\nUtility layer; not wired into the `kohya_gui/` tabs unless a `*_gui.py` file explicitly shells out to one (e.g. LoRA extraction/merge tools back the corresponding `extract_*_gui.py` / `merge_*_gui.py` tabs).\n\n## Local Contracts\n\n- Each script is self-contained with its own argparse CLI — no shared entry point or package `__init__.py`.\n- `lycoris_utils.py` is a shared helper module imported by the `lycoris_locon_extract.py` / `merge_lycoris.py` scripts — keep LyCORIS-specific logic there rather than duplicating it per script.\n- Image dataset scripts (`crop_images_to_n_buckets.py`, `group_images.py`, `group_images_recommended_size.py`, `create_txt_from_images.py`, `rename_depth_mask.py`) operate in place on a target folder passed via CLI arg — they mutate/rename files, so treat them as destructive unless run with a `--dry-run`-style flag where supported.\n- Model/LoRA conversion and merge scripts (`extract_locon.py`, `extract_loha_from_model.py`, `extract_lora_from_models-new.py`, `extract_model_difference.py`, `merge_lycoris.py`, `resize_lora.py`, `prune.py`, `lcm_convert.py`) read/write `.safetensors` files and should not modify inputs in place — always write to a new output path.\n\n## Work Guidance\n\n- New one-off maintenance scripts belong here, not in `kohya_gui/`, unless they need a GUI tab.\n- Prefer extending `lycoris_utils.py` for LyCORIS format changes rather than editing extraction logic per-script.\n\n## Verification\n\nNone currently — no automated tests cover this folder; verify manually against a sample model/dataset before relying on a script's output.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n","isInternal":false,"tokens":446,"sizeBytes":1899}],"systemPromptSnippet":"<yakaai_skills repo=\"bmaltais/kohya_ss\">\n<!-- File: AGENTS.md (Tokens: ~616 | Category: root-instruction) -->\n# kohya_ss\n\n## Purpose\n\nGradio-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.\n\n## Ownership\n\n- Maintainer: bmaltais\n- `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.\n\n## Local Contracts\n\n- Python 3.10–3.11 (`pyproject.toml`), dependency management via `uv` (never bare `pip`).\n- `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`.\n- Config precedence: `config.toml` (user, gitignored) vs `config example.toml` (tracked template) — copy, don't edit the example in place.\n- Secrets (API tokens, HF keys) go through env vars / `config.toml`, never hardcoded.\n\n## Work Guidance\n\n- Black formatting on Python changes before commit.\n- 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/`.\n- Before a refactor touching >300 LOC, strip dead props/exports/debug logging first, as its own commit.\n\n## Verification\n\n- `.github/workflows/typos.yaml` runs `crate-ci/typos` on push/PR — fix flagged typos before merging.\n- `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`).\n- No `tsc`/`eslint` equivalent exists (pure Python project) — rely on the tests above plus manual GUI smoke-test via `gui.sh` / `gui.bat`.\n\n## Child DOX Index\n\n- `kohya_gui/AGENTS.md` — Gradio GUI package (tabs, shared widget classes, launcher helpers)\n- `tools/AGENTS.md` — standalone CLI utility scripts (extraction, conversion, captioning)\n- `docs/AGENTS.md` — feature guides and localized documentation\n- `tests/AGENTS.md` — pytest regression suite\n- `test/AGENTS.md` — manual end-to-end scratch fixtures and the allowed-paths unittest\n- `sd-scripts/` — upstream submodule, out of scope for local AGENTS.md (do not create one; see Ownership above)\n\n<!-- File: docs/AGENTS.md (Tokens: ~359 | Category: root-instruction) -->\n# docs/\n\n## Purpose\n\nReference documentation supplementing the root `README.md`: per-feature guides, installation instructions, and localized (`-ja`/`-zh`) copies of training READMEs.\n\n## Ownership\n\nContent-only; no code. Owned jointly by whoever maintains the referenced feature.\n\n## Local Contracts\n\n- `Installation/` — per-platform/package-manager install guides (`pip_linux.md`, `pip_windows.md`, `uv_linux.md`, `uv_windows.md`).\n- `LoRA/`, `Finetuning/` — feature-specific guides, each with a `top_level.md` overview.\n- Root-level `*_README.md` / `*_README-ja.md` / `*_README-zh.md` pairs are translated copies — when updating an English doc that has translated siblings, note in the PR that translations are now stale (translations are community-maintained, not auto-synced).\n- `image_folder_structure.md`, `troubleshooting_tesla_v100.md`, `installation_docker.md`, `installation_runpod.md`, `installation_novita.md` are standalone single-topic guides, not part of a series.\n\n## Work Guidance\n\n- New feature guides should follow the existing `<Feature>/top_level.md` pattern rather than a single flat file, if the feature is expected to grow multiple sub-topics (options, troubleshooting, etc.) — otherwise a flat root-level `.md` is fine.\n- Don't duplicate installation steps already covered in the root `README.md`'s Installation Options section; link to it instead.\n\n## Verification\n\n- `.github/workflows/typos.yaml` lints spelling across the repo, docs included.\n\n## Child DOX Index\n\nNone — sub-folders here are content collections, not durable code boundaries.\n\n<!-- File: kohya_gui/AGENTS.md (Tokens: ~778 | Category: root-instruction) -->\n# kohya_gui/\n\n## Purpose\n\nGradio UI package that builds every tab in the kohya_ss app and translates form inputs into `sd-scripts` CLI invocations. Owned by the root `AGENTS.md`; see it for submodule and dependency rules.\n\n## Ownership\n\nPart of the GUI front end. No files here belong to `sd-scripts` — this package only calls it (via `class_command_executor.py` / subprocess), never imports its internals directly.\n\n## Local Contracts\n\n- `<feature>_gui.py` files (e.g. `lora_gui.py`, `dreambooth_gui.py`, `finetune_gui.py`) each build one Gradio tab and are self-contained entry points.\n- `class_*.py` files are shared, stateful widget groups reused across multiple tabs (e.g. `class_basic_training.py`, `class_advanced_training.py`, `class_source_model.py`, `class_folders.py`, `class_accelerate_launch.py`) — extend these instead of duplicating widget layout in a feature file.\n- `common_gui.py` holds shared helpers (path pickers, config load/save, validation) used across both `class_*` and `*_gui.py` files — put new cross-tab utilities here, not in a feature file.\n- `class_command_executor.py` is the only place that shells out to `sd-scripts` training scripts; new training features should route through it rather than spawning subprocesses ad hoc.\n- `class_gui_config.py` / `class_configuration_file.py` own reading and writing the JSON/TOML preset files under `presets/` and `config_files/` — don't hand-roll config serialization elsewhere.\n- `localization.py` / `localization_ext.py` own i18n string loading from `localizations/`.\n\n## Work Guidance\n\n- When adding a new training method tab, follow the existing `*_gui.py` + shared `class_*` composition pattern rather than inlining a monolithic tab.\n- Keep widget classes decoupled from each other; compose them inside the feature file instead of having one `class_*` reach into another.\n\n## Verification\n\n- No dedicated unit tests for this package yet beyond `test/test_allowed_paths.py` (launcher-level) — smoke-test new/changed tabs by launching the GUI (`gui.sh` / `gui.bat`) and exercising the tab manually.\n- **Launching as an agent (non-interactive/background shell):** use the same invocation as the `gui-uv.*` launcher scripts, not a bare `uv run python kohya_gui.py`:\n  - Cross-platform baseline (matches `gui-uv.sh`): `uv run kohya_gui.py --noverify`\n  - Windows (matches `gui-uv.bat`): add `--link-mode=copy --index-strategy unsafe-best-match` before the script name, i.e. `uv run --link-mode=copy --index-strategy unsafe-best-match kohya_gui.py --noverify`\n  Without `--noverify`, kohya_gui.py re-validates/reinstalls requirements every launch (slow, and reinstalls the editable `sd-scripts` package unnecessarily).\n  When stdout is piped to a background-process log file (not a TTY), Python buffers it — the `* Running on local URL: ...` line may not appear in the log for a long time even though the server is already up. Don't treat a quiet log as a hang: poll the HTTP endpoint instead (`curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:7860/`, expect `200`) rather than grepping the log for the ready banner.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n\n<!-- File: test/AGENTS.md (Tokens: ~480 | Category: root-instruction) -->\n# test/\n\n## Purpose\n\nManual end-to-end scratch space for exercising real training runs through the GUI/CLI, plus one standalone unittest for launcher behavior. Distinct from `tests/` (plural) at the repo root, which is the automated pytest suite — see `tests/AGENTS.md`.\n\n## Ownership\n\nMixed: `test_allowed_paths.py` is a real regression test; everything else (`config/`, `ft/`, `log/`, `logs/`, `masked_loss/`, `output/`, `img*/`) is generated/scratch data from manual runs, not curated fixtures.\n\n## Local Contracts\n\n- `test_allowed_paths.py` loads the root `kohya_gui.py` launcher by file path (via `importlib.util.spec_from_file_location`), not `import kohya_gui`, because the launcher script and the `kohya_gui/` package share a name — follow the same pattern for any new launcher-level test.\n- `config/` holds sample training preset JSON/TOML files (dreambooth, LoRA, LoCon, LoHa, LoKR, DyLoRA, TI, SDXL variants) used as real inputs when manually exercising a tab end-to-end.\n- `masked_loss/` holds a small fixed sample image set used to manually verify masked-loss training.\n- `logs/`, `log/`, `ft/`, `output/` are run artifacts (tensorboard logs, checkpoints, generated configs) from prior manual test runs — timestamped, disposable, safe to prune; not meant to be committed as fixtures going forward.\n- `img with spaces/` exists specifically to catch path-quoting bugs in generated CLI commands — keep the space in the folder name.\n\n## Work Guidance\n\n- New launcher/CLI-argument-forwarding tests belong here as standalone unittests, following `test_allowed_paths.py`'s import pattern.\n- New pure-logic unit tests for `kohya_gui/` modules belong in `tests/` instead.\n- Don't commit new large run artifacts under `logs/`/`output/`/`ft/` — clean up scratch runs rather than checking them in.\n\n## Verification\n\n- Run with `pytest test/test_allowed_paths.py` (or `python -m unittest test.test_allowed_paths`).\n\n## Child DOX Index\n\nNone.\n\n<!-- File: tests/AGENTS.md (Tokens: ~284 | Category: root-instruction) -->\n# tests/\n\n## Purpose\n\nPytest/unittest regression suite for `kohya_gui/` behavior that's cheap to isolate (no GPU, no model weights).\n\n## Ownership\n\nMirrors `kohya_gui/` — tests here target that package's pure-Python logic (e.g. `class_tensorboard.py`'s AVX/tensorboard-availability detection).\n\n## Local Contracts\n\n- One `test_<module_under_test>.py` per targeted `kohya_gui/` module; use `importlib.reload` on the target module inside each test when the module has import-time side effects that need re-triggering under different mocked conditions (see `test_tensorboard_visibility.py`).\n- Mock external/environment dependencies (`shutil.which`, `cpuinfo.get_cpu_info`, hardware/OS checks) — this suite must run without a GPU or real tensorboard/cpuinfo state.\n- Distinct from `test/` (singular) at the repo root, which holds manual end-to-end scratch fixtures and outputs, not unit tests — see `test/AGENTS.md`.\n\n## Work Guidance\n\n- New pure-logic additions to `kohya_gui/` (config parsing, capability detection, validation helpers) should get a unit test here rather than only being smoke-tested through the GUI.\n\n## Verification\n\n- Run with `pytest tests/`.\n\n## Child DOX Index\n\nNone.\n\n<!-- File: tools/AGENTS.md (Tokens: ~446 | Category: root-instruction) -->\n# tools/\n\n## Purpose\n\nStandalone CLI scripts for dataset prep, model/LoRA conversion, and one-off maintenance tasks. Independent of the Gradio app — each script is runnable directly with `python tools/<script>.py`.\n\n## Ownership\n\nUtility layer; not wired into the `kohya_gui/` tabs unless a `*_gui.py` file explicitly shells out to one (e.g. LoRA extraction/merge tools back the corresponding `extract_*_gui.py` / `merge_*_gui.py` tabs).\n\n## Local Contracts\n\n- Each script is self-contained with its own argparse CLI — no shared entry point or package `__init__.py`.\n- `lycoris_utils.py` is a shared helper module imported by the `lycoris_locon_extract.py` / `merge_lycoris.py` scripts — keep LyCORIS-specific logic there rather than duplicating it per script.\n- Image dataset scripts (`crop_images_to_n_buckets.py`, `group_images.py`, `group_images_recommended_size.py`, `create_txt_from_images.py`, `rename_depth_mask.py`) operate in place on a target folder passed via CLI arg — they mutate/rename files, so treat them as destructive unless run with a `--dry-run`-style flag where supported.\n- Model/LoRA conversion and merge scripts (`extract_locon.py`, `extract_loha_from_model.py`, `extract_lora_from_models-new.py`, `extract_model_difference.py`, `merge_lycoris.py`, `resize_lora.py`, `prune.py`, `lcm_convert.py`) read/write `.safetensors` files and should not modify inputs in place — always write to a new output path.\n\n## Work Guidance\n\n- New one-off maintenance scripts belong here, not in `kohya_gui/`, unless they need a GUI tab.\n- Prefer extending `lycoris_utils.py` for LyCORIS format changes rather than editing extraction logic per-script.\n\n## Verification\n\nNone currently — no automated tests cover this folder; verify manually against a sample model/dataset before relying on a script's output.\n\n## Child DOX Index\n\nNone — no subdirectories with independent scope.\n</yakaai_skills>"}