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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
# This is in yaml format. You can use json if you prefer
|
| 3 |
+
# I like both but yaml is easier to write
|
| 4 |
+
# Plus it has comments which is nice for documentation
|
| 5 |
+
# This is the config I use on my sliders, It is solid and tested
|
| 6 |
+
job: train
|
| 7 |
+
config:
|
| 8 |
+
# the name will be used to create a folder in the output folder
|
| 9 |
+
# it will also replace any [name] token in the rest of this config
|
| 10 |
+
name: detail_slider_v1
|
| 11 |
+
# folder will be created with name above in folder below
|
| 12 |
+
# it can be relative to the project root or absolute
|
| 13 |
+
training_folder: "output/LoRA"
|
| 14 |
+
device: cuda:0 # cpu, cuda:0, etc
|
| 15 |
+
# for tensorboard logging, we will make a subfolder for this job
|
| 16 |
+
log_dir: "output/.tensorboard"
|
| 17 |
+
# you can stack processes for other jobs, It is not tested with sliders though
|
| 18 |
+
# just use one for now
|
| 19 |
+
process:
|
| 20 |
+
- type: slider # tells runner to run the slider process
|
| 21 |
+
# network is the LoRA network for a slider, I recommend to leave this be
|
| 22 |
+
network:
|
| 23 |
+
# network type lierla is traditional LoRA that works everywhere, only linear layers
|
| 24 |
+
type: "lierla"
|
| 25 |
+
# rank / dim of the network. Bigger is not always better. Especially for sliders. 8 is good
|
| 26 |
+
linear: 8
|
| 27 |
+
linear_alpha: 4 # Do about half of rank
|
| 28 |
+
# training config
|
| 29 |
+
train:
|
| 30 |
+
# this is also used in sampling. Stick with ddpm unless you know what you are doing
|
| 31 |
+
noise_scheduler: "ddpm" # or "ddpm", "lms", "euler_a"
|
| 32 |
+
# how many steps to train. More is not always better. I rarely go over 1000
|
| 33 |
+
steps: 500
|
| 34 |
+
# I have had good results with 4e-4 to 1e-4 at 500 steps
|
| 35 |
+
lr: 2e-4
|
| 36 |
+
# enables gradient checkpoint, saves vram, leave it on
|
| 37 |
+
gradient_checkpointing: true
|
| 38 |
+
# train the unet. I recommend leaving this true
|
| 39 |
+
train_unet: true
|
| 40 |
+
# train the text encoder. I don't recommend this unless you have a special use case
|
| 41 |
+
# for sliders we are adjusting representation of the concept (unet),
|
| 42 |
+
# not the description of it (text encoder)
|
| 43 |
+
train_text_encoder: false
|
| 44 |
+
# same as from sd-scripts, not fully tested but should speed up training
|
| 45 |
+
min_snr_gamma: 5.0
|
| 46 |
+
# just leave unless you know what you are doing
|
| 47 |
+
# also supports "dadaptation" but set lr to 1 if you use that,
|
| 48 |
+
# but it learns too fast and I don't recommend it
|
| 49 |
+
optimizer: "adamw"
|
| 50 |
+
# only constant for now
|
| 51 |
+
lr_scheduler: "constant"
|
| 52 |
+
# we randomly denoise random num of steps form 1 to this number
|
| 53 |
+
# while training. Just leave it
|
| 54 |
+
max_denoising_steps: 40
|
| 55 |
+
# works great at 1. I do 1 even with my 4090.
|
| 56 |
+
# higher may not work right with newer single batch stacking code anyway
|
| 57 |
+
batch_size: 1
|
| 58 |
+
# bf16 works best if your GPU supports it (modern)
|
| 59 |
+
dtype: bf16 # fp32, bf16, fp16
|
| 60 |
+
# if you have it, use it. It is faster and better
|
| 61 |
+
# torch 2.0 doesnt need xformers anymore, only use if you have lower version
|
| 62 |
+
# xformers: true
|
| 63 |
+
# I don't recommend using unless you are trying to make a darker lora. Then do 0.1 MAX
|
| 64 |
+
# although, the way we train sliders is comparative, so it probably won't work anyway
|
| 65 |
+
noise_offset: 0.0
|
| 66 |
+
# noise_offset: 0.0357 # SDXL was trained with offset of 0.0357. So use that when training on SDXL
|
| 67 |
+
|
| 68 |
+
# the model to train the LoRA network on
|
| 69 |
+
model:
|
| 70 |
+
# huggingface name, relative prom project path, or absolute path to .safetensors or .ckpt
|
| 71 |
+
name_or_path: "runwayml/stable-diffusion-v1-5"
|
| 72 |
+
is_v2: false # for v2 models
|
| 73 |
+
is_v_pred: false # for v-prediction models (most v2 models)
|
| 74 |
+
# has some issues with the dual text encoder and the way we train sliders
|
| 75 |
+
# it works bit weights need to probably be higher to see it.
|
| 76 |
+
is_xl: false # for SDXL models
|
| 77 |
+
|
| 78 |
+
# saving config
|
| 79 |
+
save:
|
| 80 |
+
dtype: float16 # precision to save. I recommend float16
|
| 81 |
+
save_every: 50 # save every this many steps
|
| 82 |
+
# this will remove step counts more than this number
|
| 83 |
+
# allows you to save more often in case of a crash without filling up your drive
|
| 84 |
+
max_step_saves_to_keep: 2
|
| 85 |
+
|
| 86 |
+
# sampling config
|
| 87 |
+
sample:
|
| 88 |
+
# must match train.noise_scheduler, this is not used here
|
| 89 |
+
# but may be in future and in other processes
|
| 90 |
+
sampler: "ddpm"
|
| 91 |
+
# sample every this many steps
|
| 92 |
+
sample_every: 20
|
| 93 |
+
# image size
|
| 94 |
+
width: 512
|
| 95 |
+
height: 512
|
| 96 |
+
# prompts to use for sampling. Do as many as you want, but it slows down training
|
| 97 |
+
# pick ones that will best represent the concept you are trying to adjust
|
| 98 |
+
# allows some flags after the prompt
|
| 99 |
+
# --m [number] # network multiplier. LoRA weight. -3 for the negative slide, 3 for the positive
|
| 100 |
+
# slide are good tests. will inherit sample.network_multiplier if not set
|
| 101 |
+
# --n [string] # negative prompt, will inherit sample.neg if not set
|
| 102 |
+
# Only 75 tokens allowed currently
|
| 103 |
+
# I like to do a wide positive and negative spread so I can see a good range and stop
|
| 104 |
+
# early if the network is braking down
|
| 105 |
+
prompts:
|
| 106 |
+
- "a woman in a coffee shop, black hat, blonde hair, blue jacket --m -5"
|
| 107 |
+
- "a woman in a coffee shop, black hat, blonde hair, blue jacket --m -3"
|
| 108 |
+
- "a woman in a coffee shop, black hat, blonde hair, blue jacket --m 3"
|
| 109 |
+
- "a woman in a coffee shop, black hat, blonde hair, blue jacket --m 5"
|
| 110 |
+
- "a golden retriever sitting on a leather couch, --m -5"
|
| 111 |
+
- "a golden retriever sitting on a leather couch --m -3"
|
| 112 |
+
- "a golden retriever sitting on a leather couch --m 3"
|
| 113 |
+
- "a golden retriever sitting on a leather couch --m 5"
|
| 114 |
+
- "a man with a beard and red flannel shirt, wearing vr goggles, walking into traffic --m -5"
|
| 115 |
+
- "a man with a beard and red flannel shirt, wearing vr goggles, walking into traffic --m -3"
|
| 116 |
+
- "a man with a beard and red flannel shirt, wearing vr goggles, walking into traffic --m 3"
|
| 117 |
+
- "a man with a beard and red flannel shirt, wearing vr goggles, walking into traffic --m 5"
|
| 118 |
+
# negative prompt used on all prompts above as default if they don't have one
|
| 119 |
+
neg: "cartoon, fake, drawing, illustration, cgi, animated, anime, monochrome"
|
| 120 |
+
# seed for sampling. 42 is the answer for everything
|
| 121 |
+
seed: 42
|
| 122 |
+
# walks the seed so s1 is 42, s2 is 43, s3 is 44, etc
|
| 123 |
+
# will start over on next sample_every so s1 is always seed
|
| 124 |
+
# works well if you use same prompt but want different results
|
| 125 |
+
walk_seed: false
|
| 126 |
+
# cfg scale (4 to 10 is good)
|
| 127 |
+
guidance_scale: 7
|
| 128 |
+
# sampler steps (20 to 30 is good)
|
| 129 |
+
sample_steps: 20
|
| 130 |
+
# default network multiplier for all prompts
|
| 131 |
+
# since we are training a slider, I recommend overriding this with --m [number]
|
| 132 |
+
# in the prompts above to get both sides of the slider
|
| 133 |
+
network_multiplier: 1.0
|
| 134 |
+
|
| 135 |
+
# logging information
|
| 136 |
+
logging:
|
| 137 |
+
log_every: 10 # log every this many steps
|
| 138 |
+
use_wandb: false # not supported yet
|
| 139 |
+
verbose: false # probably done need unless you are debugging
|
| 140 |
+
|
| 141 |
+
# slider training config, best for last
|
| 142 |
+
slider:
|
| 143 |
+
# resolutions to train on. [ width, height ]. This is less important for sliders
|
| 144 |
+
# as we are not teaching the model anything it doesn't already know
|
| 145 |
+
# but must be a size it understands [ 512, 512 ] for sd_v1.5 and [ 768, 768 ] for sd_v2.1
|
| 146 |
+
# and [ 1024, 1024 ] for sd_xl
|
| 147 |
+
# you can do as many as you want here
|
| 148 |
+
resolutions:
|
| 149 |
+
- [ 512, 512 ]
|
| 150 |
+
# - [ 512, 768 ]
|
| 151 |
+
# - [ 768, 768 ]
|
| 152 |
+
# slider training uses 4 combined steps for a single round. This will do it in one gradient
|
| 153 |
+
# step. It is highly optimized and shouldn't take anymore vram than doing without it,
|
| 154 |
+
# since we break down batches for gradient accumulation now. so just leave it on.
|
| 155 |
+
batch_full_slide: true
|
| 156 |
+
# These are the concepts to train on. You can do as many as you want here,
|
| 157 |
+
# but they can conflict outweigh each other. Other than experimenting, I recommend
|
| 158 |
+
# just doing one for good results
|
| 159 |
+
targets:
|
| 160 |
+
# target_class is the base concept we are adjusting the representation of
|
| 161 |
+
# for example, if we are adjusting the representation of a person, we would use "person"
|
| 162 |
+
# if we are adjusting the representation of a cat, we would use "cat" It is not
|
| 163 |
+
# a keyword necessarily but what the model understands the concept to represent.
|
| 164 |
+
# "person" will affect men, women, children, etc but will not affect cats, dogs, etc
|
| 165 |
+
# it is the models base general understanding of the concept and everything it represents
|
| 166 |
+
# you can leave it blank to affect everything. In this example, we are adjusting
|
| 167 |
+
# detail, so we will leave it blank to affect everything
|
| 168 |
+
- target_class: ""
|
| 169 |
+
# positive is the prompt for the positive side of the slider.
|
| 170 |
+
# It is the concept that will be excited and amplified in the model when we slide the slider
|
| 171 |
+
# to the positive side and forgotten / inverted when we slide
|
| 172 |
+
# the slider to the negative side. It is generally best to include the target_class in
|
| 173 |
+
# the prompt. You want it to be the extreme of what you want to train on. For example,
|
| 174 |
+
# if you want to train on fat people, you would use "an extremely fat, morbidly obese person"
|
| 175 |
+
# as the prompt. Not just "fat person"
|
| 176 |
+
# max 75 tokens for now
|
| 177 |
+
positive: "high detail, 8k, intricate, detailed, high resolution, high res, high quality"
|
| 178 |
+
# negative is the prompt for the negative side of the slider and works the same as positive
|
| 179 |
+
# it does not necessarily work the same as a negative prompt when generating images
|
| 180 |
+
# these need to be polar opposites.
|
| 181 |
+
# max 76 tokens for now
|
| 182 |
+
negative: "blurry, boring, fuzzy, low detail, low resolution, low res, low quality"
|
| 183 |
+
# the loss for this target is multiplied by this number.
|
| 184 |
+
# if you are doing more than one target it may be good to set less important ones
|
| 185 |
+
# to a lower number like 0.1 so they don't outweigh the primary target
|
| 186 |
+
weight: 1.0
|
| 187 |
+
# shuffle the prompts split by the comma. We will run every combination randomly
|
| 188 |
+
# this will make the LoRA more robust. You probably want this on unless prompt order
|
| 189 |
+
# is important for some reason
|
| 190 |
+
shuffle: true
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
# anchors are prompts that we will try to hold on to while training the slider
|
| 194 |
+
# these are NOT necessary and can prevent the slider from converging if not done right
|
| 195 |
+
# leave them off if you are having issues, but they can help lock the network
|
| 196 |
+
# on certain concepts to help prevent catastrophic forgetting
|
| 197 |
+
# you want these to generate an image that is not your target_class, but close to it
|
| 198 |
+
# is fine as long as it does not directly overlap it.
|
| 199 |
+
# For example, if you are training on a person smiling,
|
| 200 |
+
# you could use "a person with a face mask" as an anchor. It is a person, the image is the same
|
| 201 |
+
# regardless if they are smiling or not, however, the closer the concept is to the target_class
|
| 202 |
+
# the less the multiplier needs to be. Keep multipliers less than 1.0 for anchors usually
|
| 203 |
+
# for close concepts, you want to be closer to 0.1 or 0.2
|
| 204 |
+
# these will slow down training. I am leaving them off for the demo
|
| 205 |
+
|
| 206 |
+
# anchors:
|
| 207 |
+
# - prompt: "a woman"
|
| 208 |
+
# neg_prompt: "animal"
|
| 209 |
+
# # the multiplier applied to the LoRA when this is run.
|
| 210 |
+
# # higher will give it more weight but also help keep the lora from collapsing
|
| 211 |
+
# multiplier: 1.0
|
| 212 |
+
# - prompt: "a man"
|
| 213 |
+
# neg_prompt: "animal"
|
| 214 |
+
# multiplier: 1.0
|
| 215 |
+
# - prompt: "a person"
|
| 216 |
+
# neg_prompt: "animal"
|
| 217 |
+
# multiplier: 1.0
|
| 218 |
+
|
| 219 |
+
# You can put any information you want here, and it will be saved in the model.
|
| 220 |
+
# The below is an example, but you can put your grocery list in it if you want.
|
| 221 |
+
# It is saved in the model so be aware of that. The software will include this
|
| 222 |
+
# plus some other information for you automatically
|
| 223 |
+
meta:
|
| 224 |
+
# [name] gets replaced with the name above
|
| 225 |
+
name: "[name]"
|
| 226 |
+
# version: '1.0'
|
| 227 |
+
# creator:
|
| 228 |
+
# name: Your Name
|
| 229 |
+
# email: your@gmail.com
|
| 230 |
+
# website: https://your.website
|