I train the embeddings in Automatic1111 under the Train tab, so my comments refer to that.

Basically embeddings are trained on the standard model. I use sd-v1-5-pruned.ckpt for that. This does not work on merged models. Therefore make sure that the right model is selected.

If I want to train the appearance of a person (face/hair) then take best 2-5 vectors. Many say that 2 vectors are enough, but I prefer to have stronger embeddings, so I mostly use Vector 5. For styles this can vary, but there I mostly use Vector 10. The larger the vectors, the stronger the embedding and can not be easily adjusted with the prompts.

Create embedding

Name: embeddingName
Initialization text: *

Number of vectors per token: 2-10

From my experience you get the best result with 10-20 images in 512x512 px format. The more images, the more variance. For quick and easy batch cropping you can use the site https://www.birme.net/?target_width=512&target_height=512, download the edited images and save them into a separate folder. Image formats PNG, JPG and WEBP can be used.

If the images are in the correct size, the images still have to be described, for this I use the option Use BLIP for caption under the "Preprocess images" Tab. With this option all images will be described.
After that you should check the text files if they match the images or if there are wrong or duplicate descriptions.

Then you can start training.

My default settings are:

Embedding: embeddingName
Embedding Learning rate: 0.01:100, 0.007:1000, 0.005:2500, 0.0001:5000

Gradient clipping: disabled

Batch size: 1
Gradient accumulation steps: 1
(these can be adjusted depending on the GPU to learn faster, but sometimes give broken results, so I leave it like this)

Dataset directory: Path to directory with input images

Log directory: textual_inversion

Prompt template: subject_basic_woman.txt
(is only used to output the preview images during the learning process and contains for me e.g.: a photo of a woman as [name] or for styles [filewords], by [name] and can be found in the folder textual_inversion_templates)

width: 512
height: 512

Do not resize images: checked

Max steps: 5000
(Depends also on the number of images, i use 5000 for my learning rate)

Save an image to log directory every N steps, 0 to disable: 250
(means that a preview is created every 250 steps)
Save a copy of embedding to log directory every N steps, 0 to disable: 250
(means that every 250 steps the embedding will be saved - in the directory Log directory -> Date -> EmbeddingName)

...

Choose latent sampling method: deterministic

That's it.

At the end you can test the result, if the embedding is too strong, you can copy the saved embeddings with the intermediate steps into the embeddings folder of Automatic1111 and test it. As an example use a prompt and the embedding name "EmbeddingName-1500" or you train again with more or less vectors.

Edit

Pub: 23 Mar 2023 22:21 UTC

Edit: 23 Mar 2023 22:23 UTC

Views: 456