Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sd-scripts

> 编程语言
Open source

sd-scripts English / 日本語 Table of Contents <details <summaryClick to expand</summary - Introduction - Supported Models - Features - Sponsor…

7.2K stars0 likes2 views
WebsiteGitHub

About

sd-scripts English / 日本語 Table of Contents <details <summaryClick to expand</summary - Introduction - Supported Models - Features - Sponsor…

sd-scripts

English / 日本語

Table of Contents

Click to expand
  • Introduction
    • Supported Models
    • Features
    • Sponsors
    • Support the Project
  • Documentation
    • Training Documentation (English and Japanese)
    • Other Documentation (English and Japanese)
  • For Developers Using AI Coding Agents
  • Windows Installation
    • Windows Required Dependencies
    • Installation Steps
    • About requirements.txt and PyTorch
    • xformers installation (optional)
  • Linux/WSL2 Installation
    • DeepSpeed installation (experimental, Linux or WSL2 only)
  • Upgrade
    • Upgrade PyTorch
  • Credits
  • License

Introduction

This repository contains training, generation and utility scripts for Stable Diffusion and other image generation models.

Sponsors

We are grateful to the following companies for their generous sponsorship:

Support the Project

If you find this project helpful, please consider supporting its development via GitHub Sponsors. Your support is greatly appreciated!

Change History

  • Changes planned for the next release: The following are the main changes planned for the next release. Please note that these changes may be subject to change without notice before the release.

    • Added OFTv2 and BOFT network modules (networks.oft_v2, networks.boft) for SD1.x / SD2.x / SDXL training. PR #2357
      • Orthogonal fine-tuning adapters following the PEFT implementation. Weights in PEFT format can also be loaded. Thanks to umisetokikaze.
      • Note that --network_dim means the block size for these modules. For details, please refer to the documentation.
    • Added per-subset timestep sampling offset (custom_attributes.timestep_sampling.offset) for FLUX.1 and Anima LoRA training. PR #2401 Thanks to okdsf.
      • Shifts the timestep sampling distribution of each dataset subset toward lower- or higher-noise timesteps. For details, please refer to the documentation.
    • Added --show_timesteps_offset to preview the timestep distribution with the offset applied when using --show_timesteps. PR #2410
      • The documentation also describes how the offset behaves with shift / flux_shift timestep sampling.
  • Version 0.11.1 (2026-06-16):

    • Added support for torch.compile in Anima LoRA/LLLite training. PR #2379
      • It seems to speed up training by about 20%. It requires Triton and MSVC compiler. For details, please refer to the documentation.
    • Added 2D-only Qwen-Image VAE. PR #2382
      • Based on the suggestion by woct0rdho in issue #2369. Thanks to woct0rdho.
      • Enabled by specifying --qwen_image_vae_2d. The weights are the same as the standard (3D) version.
      • Expected to speed up latent pre-caching (training itself remains unchanged). For details, please refer to the documentation.
    • Added support for LLLite inpainting model training. PR #2378
      • For details, please refer to the documentation.
    • Added logging of timestep sampling settings and visualization of timesteps distribution. PR #2384
      • Visualization makes it easier to understand how training is conducted at different timesteps.
      • For details, please refer to the documentation.
  • Version 0.11.0 (2026-06-12):

    • A major internal refactoring of the codebase has been performed to improve code quality and maintainability. PR #2372
      • We have made efforts to minimize direct impact on users. For details and bug reports, please refer to this discussion.
  • Version 0.10.6 (2026-06-12):

    • Stable version before refactoring merge.
  • Version 0.10.5 (2026-05-08):

    • Support for transformers version 5 and later has been added. Thanks to marcus165090-spec for PR #2315 (followed by PR #2316).
      • The transformers version in requirements.txt remains 4.x, but it also works with 5.x. If you use 5.x for any reason, please also update diffusers to the latest version.
    • Support for ControlNet-LLLite training for Anima has been added. Thanks to PR #2317.
      • For details, please refer to the documentation.
  • Version 0.10.4 (2026-05-07):

    • Improved compatibility with Intel GPUs. Thanks to WhitePr for PR #2307.
    • Support for training inpainting models for SD 1.5/SDXL has been added. Thanks to allanoepping for PR #2309 (followed by PR #2318).
      • For details, please refer to the documentation.

Supported Models

  • Stable Diffusion 1.x/2.x
  • SDXL
  • SD3/SD3.5
  • FLUX.1
  • LUMINA
  • HunyuanImage-2.1
  • Anima

Features

  • LoRA training
  • Fine-tuning (native training, DreamBooth): except for HunyuanImage-2.1
  • Textual Inversion training: SD/SDXL
  • Inpainting model training: SD1.5 and SDXL
  • Image generation
  • Other utilities such as model conversion, image tagging, LoRA merging, etc.

Documentation

Training Documentation (English and Japanese)

  • LoRA Training Overview
  • Dataset config / Japanese version
  • Advanced Training
  • OFTv2 / BOFT Training
  • SDXL Training
  • SD3 Training
  • FLUX.1 Training
  • LUMINA Training
  • HunyuanImage-2.1 Training
  • Fine-tuning
  • Textual Inversion Training
  • ControlNet-LLLite Training / Japanese version
  • Anima ControlNet-LLLite Training Guide
  • Validation
  • Masked Loss Training / Japanese version
  • Inpainting Training

Other Documentation (English and Japanese)

  • Image generation / Japanese version
  • Tagging images with WD14 Tagger / Japanese version

For Developers Using AI Coding Agents

This repository provides recommended instructions to help AI agents like Claude and Gemini understand our project context and coding standards.

To use them, you need to opt-in by creating your own configuration file in the project root.

Quick Setup:

  1. Create a CLAUDE.md and/or GEMINI.md file in the project root.

  2. Add the following line to your CLAUDE.md to import the repository's recommended prompt:

    markdown
    @./.ai/claude.prompt.md

    or for Gemini:

    markdown
    @./.ai/gemini.prompt.md
  3. You can now add your own personal instructions below the import line (e.g., Always respond in Japanese.).

This approach ensures that you have full control over the instructions given to your agent while benefiting from the shared project context. Your CLAUDE.md and GEMINI.md are already listed in .gitignore, so they won't be committed to the repository.

Windows Installation

Windows Required Dependencies

Python 3.10.x and Git:

  • Python 3.10.x: Download Windows installer (64-bit) from https://www.python.org/downloads/windows/
  • git: Download latest installer from https://git-scm.com/download/win

Python 3.11.x, and 3.12.x will work but not tested.

Give unrestricted script access to powershell so venv can work:

  • Open an administrator powershell window
  • Type Set-ExecutionPolicy Unrestricted and answer A
  • Close admin powershell window

Installation Steps

Open a regular Powershell terminal and type the following inside:

powershell
git clone https://github.com/kohya-ss/sd-scripts.git
cd sd-scripts

python -m venv venv
.\venv\Scripts\activate

pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
pip install --upgrade -r requirements.txt

accelerate config

If python -m venv shows only python, change python to py.

Note: bitsandbytes, prodigyopt and lion-pytorch are included in the requirements.txt. If you'd like to use another version, please install it manually.

This installation is for CUDA 12.4. If you use a different version of CUDA, please install the appropriate version of PyTorch. For example, if you use CUDA 12.1, please install pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu121.

Answers to accelerate config:

txt
- This machine
- No distributed training
- NO
- NO
- NO
- all
- fp16

If you'd like to use bf16, please answer bf16 to the last question.

Note: Some user reports ValueError: fp16 mixed precision requires a GPU is occurred in training. In this case, answer 0 for the 6th question: What GPU(s) (by id) should be used for training on this machine as a comma-separated list? [all]:

(Single GPU with id 0 will be used.)

About requirements.txt and PyTorch

The file does not contain requirements for PyTorch. Because the version of PyTorch depends on the environment, it is not included in the file. Please install PyTorch first according to the environment. See installation instructions below.

The scripts are tested with PyTorch 2.6.0. PyTorch 2.6.0 or later is required.

For RTX 50 series GPUs, PyTorch 2.8.0 with CUDA 12.8/12.9 should be used. requirements.txt will work with this version.

xformers installation (optional)

To install xformers, run the following command in your activated virtual environment:

bash
pip install xformers --index-url https://download.pytorch.org/whl/cu124

Please change the CUDA version in the URL according to your environment if necessary. xformers may not be available for some GPU architectures.

Linux/WSL2 Installation

Linux or WSL2 installation steps are almost the same as Windows. Just change venv\Scripts\activate to source venv/bin/activate.

Note: Please make sure that NVIDIA driver and CUDA toolkit are installed in

Issues· 909 open

View all issuesOpen on GitHub
  • #1795

    Crashed randomly in the middle of cooking

    Updated Sep 14, 2026
  • #2420

    `torch.cuda.amp` in `__main__` self-test blocks and the IPEX hijack — deprecated since torch 2.3/2.4, unguarded on the main install path

    Updated Aug 22, 2026
  • #2417

    [Feature Request] Add option to disable cuDNN/MIOpen backend (workaround for AMD RDNA 4 GPU crashes)

    Updated Aug 16, 2026
  • #2414

    WeightsUnpickler error: Unsupported operand 56

    Updated Aug 8, 2026
  • #2405

    --tag_replacement doesn't actually replace anything (variable shadowing bug)

    Updated Jul 25, 2026
  • #2407

    [bug] --skip_until_initial_step 使用時、--gradient_accumulation_steps > 1 で再開位置を過剰にスキップして学習が終了する

    Updated Jul 21, 2026
  • #2403

    Silent `adaln` drop while anima lora training

    Updated Jul 16, 2026
  • #2402

    LECO: verify_training_args() crashes on missing sample_every_n_epochs/sample_every_n_steps

    Updated Jul 8, 2026
  • #2394

    Adding Anima ControlNet support

    Updated Jun 20, 2026
  • #2392

    "Missing keys in state dict" solved when training lora on some anima ft checkpoints

    Updated Jun 18, 2026

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 22, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言