hollowstrawberry / kohya-colab

Accessible Google Colab notebooks for Stable Diffusion Lora training, based on the work of kohya-ss and Linaqruf
GNU General Public License v3.0
564 stars 79 forks source link

Tips on regularization #137

Closed Karbadel closed 2 months ago

Karbadel commented 2 months ago

Hi, thanks for your hard work =)

Can anyone give me tips how to make work the regularization images in the subfolder dataset?

First, I configured a main image folder (37 images) and a secondary regularization images folder (550 images) like this:

custom_dataset = """ [[datasets]]

[[datasets.subsets]] image_dir = "/content/drive/MyDrive/Loras/lana/dataset" num_repeats = 15

[[datasets.subsets]] image_dir = "/content/drive/MyDrive/Loras/lana/regularization" is_reg = true

"""

And then executed the main training cell, but I get the following error:

Checking dataset...

KeyError Traceback (most recent call last) in <cell line: 518>() 516 "### There will be several files, you should try the latest version (the file with the largest number next to it)")) 517 --> 518 main()

2 frames in (.0) 251 return 252 reg = [d.get("image_dir") for d in datasets if d.get("is_reg", False)] --> 253 datasets_dict = {d["image_dir"]: d["num_repeats"] for d in datasets} 254 folders = datasets_dict.keys() 255 files = [f for folder in folders for f in os.listdir(folder)]

KeyError: 'num_repeats'

This is my first time trying regularization, so I guess that maybe is a rookie error. Can anyone give me some tips? What I am doing wrong?

Thanks! =)

hollowstrawberry commented 2 months ago

You need to add num_repeats = 1 to the regularisation folder

Karbadel commented 2 months ago

Wow, thanks! It worked like a charm!

Thanks a lot, have a good day ^^