santa hat
deerdeer nosedeer glow
Sign In

How to automate your picture selection for LoRa training

How to automate your picture selection for LoRa training

requriments:

  1. Kohya_SS https://github.com/bmaltais/kohya_ss

  2. instaloader https://github.com/instaloader/instaloader

  3. Booru https://github.com/starik222/BooruDatasetTagManager

Beforehand: You can checkout the model resulting from this guide here (including the used training data and .txt tag files): https://civitai.com/models/231658?modelVersionId=261486

i make use of downloading a whole instagram profile and tagging ALL images in WD14 Captioning beforehand to sort out the pictures to train, by deleting the pictures with undesired tags, instead of going through the pictures 1 by 1 and deciding by hand. if you want to filter out pictures faster for your lora training. keep on reading this guide :)

Download the instagram profile of your favourite person you want to create a lora of.

i will use https://www.instagram.com/bambiskii/ for this tutorial.

to make use of instaloader, open up cmd in the same path as the instaloader.exe and run the command according to her instagram tag. e.g. we need bambiskii

the command to download only her pictures, without the metadata, text or videos looks like this:

instaloader profile bambiskii --no-videos --no-captions --no-metadata-json --no-compress-json

hit enter and wait for the download to finish:

the pictures will be in a folder with the same name as the insta tag so "bambiskii".

now we need 3 new folders which you should create inside the bambiskii folder named

  • img

  • mod

  • log

so your folder structure should look like this:

bambiskii/img

bambiskii/mod

bambiskii/log

Put all the downloaded pictures into the "img" folder

we now need to tag all those images with WD14 captioning which can be found inside of the Kohya_SS Tool, the then tagged images help us sort out the unwanted stuff instead of going through all pics 1 by 1.

Open up Kohya SS and go to "Utilities" -> "Captioning" -> "WD14 Captioning"

To get better person/facial recognition increase the "character threshold" to 0.7

Choose the folder "img" in the "image folder to caption" section at the top

click on "caption images" and wait for it to finish
(there will be a message in the cmd window)

13:40:41-111336 INFO     ...captioning done

Open up Booru Dataset Manager

and open up the folder we just tagged with WD14

the important stuff is on the right, which is a list of all the tags inside of this folder.

now choose (with CTRL pressed) all tags that you DONT want

e.g. "1boy, 2girls, multiple people" etc.

anything besides "1girl" basicly

for me it looked smth like this

now click on the filter icon to only get pictures you want to delete

mark all the pictures on the left side with CTRL+A and press DEL to delete all the unwanted pictures from your dataset.

now click on "1girl" on the right and on the filter option button until it says "NOT"

now you have every picture that does not contain the tag "1girl"

and mark all the pictures on the left again with CTRL+A like before and delete them.

as a last step in Booru you can now add your trigger word to your dataset.

click on the green plus sign on the right. enter your trigger word. for me its bambiskii, choose "TOP" so its the first tag on all pictures , go to "save changes" on the top left and thats it, you are done in booru

now just go to kohya_ss and train your lora with your favourite settings.

there are already a million guides on kohya_ss lora training and i dont think i can add anything special to it.

i uploaded my preset settings for kohysa in the attachments (for NVIDIA GPUs) if you want to check it out.

87

Comments