https://github.com/kohya-ss/sd-scripts
Config Start
config: seems like the epoch calculation is wrong, when in doubt just set the number low and set repeats high by renaming folders.
having multiple epochs is similar to having multiple repeats, but ending epochs is slow
$run = $True
$ckpt = "<CHANGE ME>"; # base checkpoint to finetune
$vae = "<CHANGE ME>"
$img_dir = "<CHANGE ME>";
my_concepts_folder
12_A, images in A will repeat 12x
20_B, images in B will repeat 20x
$reg_dir = "<CHANGE ME>"; #optional, just point this to an empty folder if you don't care.
$output = "<CHANGE ME>"; # safetensors output folder
$output_name="<change me>_locon"
$noise_offset=0
$keep_tokens=0
$learning_rate=<change me>
$text_encoder_lr=<change me>
$unet_lr=<change me>
$lr_warmup_ratio = 0.1
$resolution=512
$train_batch_size = 4
$num_epochs = 5
$save_every_n_epochs=1
$scheduler="cosine_with_restarts"
$network_dim=4 # linear layers
$network_alpha=4 # linear layers
$conv_dim=1
$conv_alpha=1 # not used right now cause i'm too dumb to pass in nargs through accelerate call for python
$network_args="conv_dim={0}" -f $conv_dim
Config End
Clear-Host
if (Test-Path -Path $output) {
Write-Output "Output folder {$output} already exists."
} else {
Write-Output "Creating output folder {$output}"
mkdir -p $output
}
Write-Output "Measuring folders:"
$total = 0
$folders = Get-ChildItem -Path $img_dir -Directory
$folders | ForEach-Object {
$parts = $.Name.Split("")
if(($parts | Measure-Object | ForEach-Object{$.Count}) -ne 2)
{
Return
}
$repeats = [int]$parts[0]
$imgs = Get-ChildItem $.FullName -Recurse -File -Include .png, .bmp, .gif, .jpg,.jpeg, .webp | Measure-Object | ForEach-Object{$_.Count}
$img_repeats = ($repeats * $imgs)
Write-Output "`t$($parts[1]): $repeats repeats * $imgs images = $($img_repeats)"
$total += $img_repeats
}
Write-Output "Total images with repeats: $total"
$mts = int
Write-Output "Max training steps $total / $train_batch_size * $num_epochs = $mts"
$lr_warmup_steps = [math]::Round($mts * $lr_warmup_ratio)
Write-Output "Warmup steps: $lr_warmup_steps, Batch size: $train_batch_size, Epochs: $num_epochs"
if ($run) {
.\venv\Scripts\activate
}