mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-16 08:52:45 +00:00
* Add LECO training script and associated tests
- Implemented `sdxl_train_leco.py` for training with LECO prompts, including argument parsing, model setup, training loop, and weight saving functionality.
- Created unit tests for `load_prompt_settings` in `test_leco_train_util.py` to validate loading of prompt configurations in both original and slider formats.
- Added basic syntax tests for `train_leco.py` and `sdxl_train_leco.py` to ensure modules are importable.
* fix: use getattr for safe attribute access in argument verification
* feat: add CUDA device compatibility validation and corresponding tests
* Revert "feat: add CUDA device compatibility validation and corresponding tests"
This reverts commit 6d3e51431b.
* feat: update predict_noise_xl to use vector embedding from add_time_ids
* feat: implement checkpointing in predict_noise and predict_noise_xl functions
* feat: remove unused submodules and update .gitignore to exclude .codex-tmp
---------
Co-authored-by: Kohya S. <52813779+kohya-ss@users.noreply.github.com>
2.1 KiB
2.1 KiB
LECO Training
This repository now includes dedicated LECO training entry points:
train_leco.pyfor Stable Diffusion 1.x / 2.xsdxl_train_leco.pyfor SDXL
These scripts train a LoRA against the model's own noise predictions, so no image dataset is required.
Current scope
- U-Net LoRA training only
networks.lorais the default network module- Prompt YAML supports both original LECO prompt pairs and ai-toolkit style slider targets
- Full ai-toolkit job YAML is not supported; use a prompt/target YAML file only
Example: SD 1.x / 2.x
accelerate launch train_leco.py ^
--pretrained_model_name_or_path="model.safetensors" ^
--output_dir="output" ^
--output_name="detail_slider" ^
--prompts_file="prompts.yaml" ^
--network_dim=8 ^
--network_alpha=4 ^
--learning_rate=1e-4 ^
--max_train_steps=500 ^
--max_denoising_steps=40 ^
--mixed_precision=bf16
Example: SDXL
accelerate launch sdxl_train_leco.py ^
--pretrained_model_name_or_path="sdxl_model.safetensors" ^
--output_dir="output" ^
--output_name="detail_slider_xl" ^
--prompts_file="slider.yaml" ^
--network_dim=8 ^
--network_alpha=4 ^
--learning_rate=1e-4 ^
--max_train_steps=500 ^
--max_denoising_steps=40 ^
--mixed_precision=bf16
Prompt YAML: original LECO format
- target: "van gogh"
positive: "van gogh"
unconditional: ""
neutral: ""
action: "erase"
guidance_scale: 1.0
resolution: 512
batch_size: 1
multiplier: 1.0
weight: 1.0
Prompt YAML: ai-toolkit style slider target
This expands internally into the bidirectional LECO pairs needed for slider-style behavior.
targets:
- target_class: ""
positive: "high detail, intricate, high quality"
negative: "blurry, low detail, low quality"
multiplier: 1.0
weight: 1.0
guidance_scale: 1.0
resolution: 512
neutral: ""
You can also provide multiple neutral prompts:
targets:
- target_class: "person"
positive: "smiling person"
negative: "expressionless person"
neutrals:
- ""
- "studio photo"
- "cinematic lighting"