back to the blog

How to Finetune Dreambooth Model

Written on . Posted in Stable Diffusion API.
How to Finetune Dreambooth Model

How to finetune dreambooth model to generate different types of your images?

Here is a step-by-step guide:

1. Prepare Training Images

Preparing images you want to train is very important, choosing the right images can generate awesome results. Make sure all images are different and not the same.

You will need 5-10 images of yourself or any item you want to finetune on.

1. Remove any kind of extra background;

2. Crop each image in 512x512 resolution;

3. Prepare around 10 images.

2. Choosing Token Name

Prompting with just your token. ie "adhik" instead of "adhik person"

If you trained with adhik under the class person, the model should only know your face as:

adhik person
    

Example Prompts:

? Incorrect (missing person following adhik)

portrait photograph of adhik 35mm film vintage glass
    

✅ This is right (person is included after adhik)

portrait photograph of adhik person 35mm film vintage glass
    

You might sometimes get someone who kinda looks like you with adhik (especially if you trained for too many steps), but that's only because this current iteration of Dreambooth overtrains that token so much that it bleeds into that token.

Right Instance Prompt:: a photo of adhik person

3. Choosing Training Steps

Having too many steps can lead to bad results, and too few can result in bad results as well.
We recommend having 2x steps number of images or keep 2000 steps

4. Prepare API

Visit API docs from this link to see API docs,

You can also open API collection using postman,

Change API like this:

"instance_prompt": "a photo of adhik person",
 
Change "instance_prompt" to how you want to call the model, like
1. a photo of XYZ person
2. a photo of XYZ car
3. a photo of XYZ product
 
Change person, car, product, etc. with item category and XYZ with the item name you are training with.
 
"class_prompt": "a photo of person",
 
Class Prompt is what this training is about before the new prompt
1. a photo of a person
2. a photo of a car
3. a photo of the product etc...
 
"images" :
 
Pass image links in the 'images' array, and make sure all images are accessible, and not protected by any password.
 
  1. All images have to be 512x512
  2. Have a static link, for example, xyz.com/image.png
  3. If the image link has been redirecting, it will not work
  4. All images have to be valid .png images.
  5. Anything above not good will result in failed training.

4. Start Training

Make an API call to start training, if you get an error, make sure you have your subscription activated. it will take 45 minutes to finish the training.