# kohya-ss/sd-scripts

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/kohya-ss-sd-scripts).**

7,133 stars · 1,199 forks · Python · Apache-2.0

## Links

- GitHub: https://github.com/kohya-ss/sd-scripts
- awesome-repositories: https://awesome-repositories.com/repository/kohya-ss-sd-scripts.md

## Description

sd-scripts is a suite of utilities designed for fine-tuning generative models, preprocessing datasets, and converting model weights. It provides a collection of scripts for executing Stable Diffusion training through methods such as DreamBooth, textual inversion, and full fine-tuning, alongside a framework for creating and managing Low-Rank Adaptation weights.

The project features specialized capabilities for model weight conversion between different architectures and precision formats. It includes tools for merging adaptation weights into base models, extracting weights from trained models, and integrating multiple adaptation modules to blend styles or concepts.

The toolkit covers a broad range of generative AI operations, including image dataset preparation with automated tagging and aspect ratio bucketing, and various inference methods such as text-to-image, image-to-image, and inpainting. It also incorporates memory and performance optimizations, including VRAM management, latent caching, and just-in-time training acceleration.

The software provides integration for synchronizing training states and model checkpoints with the Hugging Face Hub.

## Tags

### Artificial Intelligence & ML

- [Generative Model Fine-Tuning](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-model-fine-tuning.md) — Adjusts weights of pre-trained generative models using custom datasets to learn specific subjects, styles, or concepts.
- [Custom Stable Diffusion Training](https://awesome-repositories.com/f/artificial-intelligence-ml/custom-stable-diffusion-training.md) — Ships a comprehensive collection of scripts for fine-tuning Stable Diffusion models using various methods and optimizations.
- [Diffusion Models](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-models/diffusion-models.md) — Enables generating images from text or image prompts using trained checkpoints, LoRA weights, and structural guidance.
- [Text-to-Image Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-image-generators.md) — Provides a pipeline for generating high-resolution images from natural language text prompts. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/gen_img_README-ja.md))
- [Image Inpainting](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-image-generators/image-inpainting.md) — Provides tools for generative filling of specific image regions using masks and text prompts. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/gen_img_README.md))
- [Image-to-Image Translation](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/diffusion-visual-models/generative-ai-pipelines/text-to-image-generators/image-inpainting/image-to-image-translation.md) — Enables the creation of new images using an existing image as a base with strength control. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/gen_img_README.md))
- [Generative Image Dataset Preparation](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-image-dataset-preparation.md) — Analyzes images to generate descriptive tags and manages resolution buckets and captions for supervised training.
- [Image Dataset Preprocessors](https://awesome-repositories.com/f/artificial-intelligence-ml/image-dataset-preprocessors.md) — Provides utilities for tagging images, generating captions and managing aspect ratio bucketing for model training.
- [LoRA Training](https://awesome-repositories.com/f/artificial-intelligence-ml/lora-training.md) — Provides a framework for creating and merging low-rank adaptation weights to modify model behavior.
- [Model Loading](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/data-and-checkpointing/model-loading.md) — Loads pre-trained models from remote IDs or local files with precision and VAE options. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_network_advanced.md))
- [Layer-Wise Learning Rates](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/model-fine-tuning-adaptation/learning-rate-schedulers/layer-wise-learning-rates.md) — Allows freezing specific blocks and assigning individual learning rates to balance training stability. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/fine_tune.md))
- [Memory Optimization](https://awesome-repositories.com/f/artificial-intelligence-ml/memory-optimization.md) — Reduces VRAM requirements during training and inference through block swapping, mixed precision, and latent caching.
- [Layer-Specific Training](https://awesome-repositories.com/f/artificial-intelligence-ml/model-training/layer-specific-training.md) — Allows selecting specific model blocks or layers for updates to focus training on particular network segments. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/sd3_train_network.md))
- [Model Exporting](https://awesome-repositories.com/f/artificial-intelligence-ml/model-training/model-exporting.md) — Exports models and optimizer states with precision settings and automatic checkpoint rotation. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_network_advanced.md))
- [LoRA-Weighted Image Generations](https://awesome-repositories.com/f/artificial-intelligence-ml/model-weight-management/lora-adapter-loaders/lora-weighted-image-generations.md) — Generates images using trained LoRA weights with adjustable guidance scales. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/hunyuan_image_train_network.md))
- [Weight Merging](https://awesome-repositories.com/f/artificial-intelligence-ml/weight-merging.md) — Integrates trained weights directly into a base model to create a single standalone file. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/flux_train_network.md))
- [Adapter Module Training](https://awesome-repositories.com/f/artificial-intelligence-ml/adapter-module-training.md) — Provides capabilities for training LLLite adapter modules for lightweight conditional image control. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_train_control_net_lllite.md))
- [ControlNet Guidance](https://awesome-repositories.com/f/artificial-intelligence-ml/controlnet-guidance.md) — Provides capabilities to constrain image structure using hint images and pre-processors. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/gen_img_README-ja.md))
- [Dataset Subset Organization](https://awesome-repositories.com/f/artificial-intelligence-ml/dataset-subset-extractions/dataset-subset-organization.md) — Organizes images into hierarchical subsets to apply specific repeat counts or caption prefixes. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/config_README-ja.md))
- [Automated Image Tagging](https://awesome-repositories.com/f/artificial-intelligence-ml/image-classification/image-level-tagging/automated-image-tagging.md) — Implements automated image analysis to create descriptive labels in text files for training sets. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/wd14_tagger_README-en.md))
- [Latent Representation Caching](https://awesome-repositories.com/f/artificial-intelligence-ml/in-memory-model-caching/latent-representation-caching.md) — Speeds up training by storing pre-computed latent representations to disk or memory to avoid redundant calculations. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/flux_train.py))
- [Dataset Configurations](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/dataset-management/dataset-configurations.md) — Uses configuration files to define training data, high-resolution image settings, and aspect ratio bucketing. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_network_advanced.md))
- [JIT Kernel Fusion Accelerators](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/machine-learning-training/distributed-and-accelerated-compute/training-acceleration-tools/training-acceleration-engines/jit-kernel-fusion-accelerators.md) — Reduces training step duration by applying just-in-time compilation and kernel fusion on a per-block basis. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_torch_compile.md))
- [Local Inference](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/local-ai-deployment-platforms/deployment-platforms/local-inference.md) — Allows running model inference for image generation directly on local hardware using checkpoints. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/sdxl_minimal_inference.py))
- [Model Inference](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/model-integration-pipelines/model-inference.md) — Executes a denoising loop on Flux models to generate images from text prompts. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/flux_minimal_inference.py))
- [Weight Approximation Extraction](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-fine-tuning/low-rank-adaptation/weight-approximation-extraction.md) — Implements the extraction of LoRA weights by calculating the difference between a trained model and its base. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/flux_train_network.md))
- [Text Encoder Adaptation](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/fine-tuning-and-customization/model-fine-tuning/multimodal-fine-tuning/text-encoder-adaptation.md) — Allows fine-tuning the text encoder alongside the diffusion model to improve adherence to complex prompts. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_train_network.md))
- [Model Weight Converters](https://awesome-repositories.com/f/artificial-intelligence-ml/model-weight-converters.md) — Transforms diffusion model weights between different architectures and precision formats for compatibility.
- [LoRA Adapter Loaders](https://awesome-repositories.com/f/artificial-intelligence-ml/model-weight-management/lora-adapter-loaders.md) — Supports applying and merging multiple LoRA weights to modify the style or content of generated images. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/gen_img_README.md))
- [Model Merging](https://awesome-repositories.com/f/artificial-intelligence-ml/pre-trained-model-application/model-merging.md) — Provides tools to combine pre-trained weights into a base model to facilitate differential learning. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_network_advanced.md))
- [Training Caption Processing](https://awesome-repositories.com/f/artificial-intelligence-ml/training-caption-processing.md) — Provides tools to add prefixes, suffixes, and shuffle tags to control how the model learns descriptions. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/config_README-en.md))
- [Image Augmentations](https://awesome-repositories.com/f/artificial-intelligence-ml/training-data-transformations/image-augmentations.md) — Performs random flips, color adjustments, and face cropping on image subsets to increase training variety. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/config_README-en.md))
- [In-Training Sample Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/training-progress-monitors/in-training-sample-generation.md) — Generates preview images at specified intervals during training to visually monitor the quality of the model's convergence. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/inpainting_training.md))
- [Training Stability Techniques](https://awesome-repositories.com/f/artificial-intelligence-ml/training-stability-techniques.md) — Implements noise offsets and input perturbations to ensure consistent convergence and stability during the fine-tuning process. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_network_advanced.md))

### Part of an Awesome List

- [Adapter Merging](https://awesome-repositories.com/f/awesome-lists/ai/model-adaptation-and-merging/adapter-merging.md) — Combines multiple Low-Rank Adaptation modules into a single model to blend concepts. ([source](https://github.com/kohya-ss/sd-scripts#readme))
- [High Resolution Training](https://awesome-repositories.com/f/awesome-lists/ai/model-training-and-fine-tuning/high-resolution-training.md) — Supports training on datasets with multiple image resolutions and adaptive batch sizes for improved flexibility. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/flux_train_network.md))
- [Model Fine-Tuning](https://awesome-repositories.com/f/awesome-lists/ai/model-training-and-fine-tuning/model-fine-tuning.md) — A specialized tool for adjusting weights of pre-trained image models through DreamBooth, textual inversion and full fine-tuning.
- [Subject-Specific Fine-Tuning](https://awesome-repositories.com/f/awesome-lists/ai/model-training-and-fine-tuning/model-fine-tuning/subject-specific-fine-tuning.md) — Implements DreamBooth training to specialize generative models on unique subjects using small image sets. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/train_db.py))
- [Textual Inversion Embeddings](https://awesome-repositories.com/f/awesome-lists/media/image-loading/latent-inversion/textual-inversion-embeddings.md) — Provides tools for optimizing small embedding files to teach new concepts without altering the base model weights. ([source](https://github.com/kohya-ss/sd-scripts#readme))
- [Inpainting Training](https://awesome-repositories.com/f/awesome-lists/ai/image-inpainting-models/inpainting-training.md) — Provides scripts to train models specifically for filling or replacing regions of images using masks. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/inpainting_training.md))
- [ControlNet Training](https://awesome-repositories.com/f/awesome-lists/ai/model-training-and-fine-tuning/model-fine-tuning/controlnet-training.md) — Includes specialized training scripts for Flux ControlNet with memory optimizations like CPU offloading. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/flux_train_control_net.py))

### Data & Databases

- [Aspect Ratio Bucketing](https://awesome-repositories.com/f/data-databases/in-memory-caches/image-caches/aspect-ratio-bucketing.md) — Optimizes training efficiency by grouping images by resolution and filtering out low-quality small files. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/config_README-en.md))
- [Model Weight Conversions](https://awesome-repositories.com/f/data-databases/vector-data-formats/format-conversion-utilities/model-weight-conversions.md) — Transforms model weights between different architectures and precision formats for compatibility. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_train_network.md))

### Hardware & IoT

- [Training Throughput Optimizations](https://awesome-repositories.com/f/hardware-iot/integration-performance/gpu-performance/training-throughput-optimizations.md) — Utilizes specialized precision modes and deep learning primitives to maximize GPU throughput during model training. ([source](https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_torch_compile.md))
