Generating LoRAs
LoRAs are like specialized mini-models that can be used when
generating images with Stable
Diffusion. They’re often used for adding characters or specific
concepts not known by the base model. This page contains documentation
on how I generate LoRAs.
Setting up the environment
I am unable to run kohya_ss on my own
machine, so I will be renting one from RunPod instead.
- Create an account on RunPod
- Provision a server with the SDiffusion
Dreambooth ControlNet Deforum Kohya template with at least 15 GB
container storage and 30 GB persistent storage (personally I use 25 GB
and 100 GB)
- Click Connect
- Connect to HTTP Service [Port 8888] to open Jupyter Lab and upload
your training data with the following folder structure
- /workspace/<lora
name>/image/<number_of_repeats>_<lora name>
- image1.jpg
- image1.txt (caption)
- /workspace/<lora name>/log
- /workspace/<lora name>/model
- Use the machine to download the base model
- In Jupyter, open a Terminal
- Run a command like
nohup wget -qc "https://civitai.com/api/download/models/28562?type=Model&format=SafeTensor&size=pruned&fp=fp16" -O /workspace/stable-diffusion-webui/models/Stable-diffusion/anyloraCheckpoint_novaeFp16Pruned.safetensors &
(this downloads the AnyLORA
noVae fp16 model in the background)
Training the LoRA
- Back in RunPod, click Connect to HTTP Service [Port 3010] to open
kohya_ss GUI (wait until it’s ready)
- Click the Dreambooth LoRA tab
- In Model Quick Pick, select Custom
- In Pretrained model name or path, type the path to your base model
(e.g.
/workspace/stable-diffusion-webui/models/Stable-diffusion/anyloraCheckpoint_novaeFp16Pruned.safetensors
)
- Click the Folders tab
- Enter the Image folder
(e.g.
/workspace/<lora name>/image
)
- Enter the Output folder
(e.g.
/workspace/<lora name>/model
)
- Enter the Log folder
(e.g.
/workspace/<lora name>/log
)
- Enter the Model output name
- Click the Training parameters tab
- Enter the training parameters according to the type of LoRA you are
making
- Enter a sample prompt
(e.g.
(masterpiece, best quality:1.2), character name, 1girl, solo, cowboy shot, looking at viewer --n (worse quality, lower quality:2) --w 512 --h 768
)
- In the Jupyter Terminal, run
tail -f /workspace/logs/kohya_ss.log
to check the logs for
kohya_ss
- Click Train Model