Welcome to the official codebase for the Sensorial System's Stable Diffusion projects. For now, this only hosts the codebase for our Stable Diffusion XL LoRA Trainer, designed to make it easier to automate all the steps of finetuning Stable Diffusion models.
- Rust Library: For programmability, a Rust library is made available for developers.
- Command Line Interface (CLI): For ease of use, the trainer can be accessed via a CLI, making it accessible for various use cases.
- kohya_ss: Follow the installation guidelines here https://github.com/bmaltais/kohya_ss.
We have a dataset with photos of Bacana, a Coton de Tuléar, conceptualized as bacana white dog
to not mix with the existing Coton de Tuléar
concept in the Stable Diffusion XL
model.
It's organized as follows:
Rust Library
The training code example looks like this:
use stable_diffusion_trainer::*;
fn main() {
let kohya_ss = std::env::var("KOHYA_SS_PATH").expect("KOHYA_SS_PATH not set");
let environment = Environment::new().with_kohya_ss(kohya_ss);
let prompt = Prompt::new("bacana", "white dog");
let image_data_set = ImageDataSet::from_dir("examples/training/lora/bacana/images");
let data_set = TrainingDataSet::new(image_data_set);
let output = Output::new("{prompt.instance}({prompt.class})d{network.dimension}a{network.alpha}", "examples/training/lora/bacana/output");
let parameters = Parameters::new(prompt, data_set, output);
Trainer::new()
.with_environment(environment)
.start(¶meters);
}
Stable Diffusion CLI
Install the CLI tool:
cargo install stable-diffusion-cli
Setup the environment:
stable-diffusion-cli setup
Train the example with:
stable-diffusion-cli train --config examples/training/lora/bacana/parameters.json
The training parameters looks like this:
{
"prompt": {
"instance": "bacana",
"class": "white dog"
},
"dataset": {
"training": "images"
},
"network": {
"dimension": 8,
"alpha": 1.0
},
"output": {
"name": "{prompt.instance}({prompt.class})d{network.dimension}a{network.alpha}",
"directory": "./output"
},
"training": {
"optimizer": "Adafactor",
"learning_rate": {
"scheduler": "Constant"
}
}
}