replicate / dreambooth

Train your own custom Stable Diffusion model using a small set of images

  • Public
  • 295.5K runs
  • A100 (80GB)
  • GitHub
  • Paper
  • License

Run replicate/dreambooth with an API

Input schema

seedinteger

A seed for reproducible training

Default
1337
scale_lrboolean

Scale the learning rate by the number of GPUs, gradient accumulation steps, and batch size.

ckpt_baseuri

A ckpt file with existing training base

adam_beta1number

The beta1 parameter for the Adam optimizer.

Default
0.9
adam_beta2number

The beta2 parameter for the Adam optimizer.

Default
0.999
class_datauri

An optional ZIP file containing the training data of class images. This corresponds to `class_prompt` above, also with the purpose of keeping the model generalizable. By default, the pretrained stable-diffusion model will generate N images (determined by the `num_class_images` you set) based on the `class_prompt` provided. But to save time or to have your preferred specific set of `class_data`, you can also provide them in a ZIP file.

pad_tokensboolean

Flag to pad tokens to length 77.

resolutioninteger

The resolution for input images. All the images in the train/validation dataset will be resized to this resolution.

Default
512
center_cropboolean

Whether to center crop images before resizing to resolution

adam_epsilonnumber

Epsilon value for the Adam optimizer

Default
1e-8
class_promptstring

The prompt or description of the coarse class of your training images, in the format of `a [class noun]`, optionally with some extra description. `class_prompt` is used to alleviate overfitting to your customised images (the trained model should still keep the learnt prior so that it can still generate different dogs when the `[identifier]` is not in the prompt). Corresponding to the examples of the `instant_prompt` above, the `class_prompt` can be `a dog` or `a photo of a dog`.

lr_schedulerstring

The scheduler type to use

Default
"constant"
instance_datauri

A ZIP file containing your training images (JPG, PNG, etc. size not restricted). These images contain your 'subject' that you want the trained model to embed in the output domain for later generating customized scenes beyond the training images. For best results, use images without noise or unrelated objects in the background.

learning_ratenumber

Initial learning rate (after the potential warmup period) to use.

Default
0.000001
max_grad_normnumber

Max gradient norm.

Default
1
n_save_sampleinteger

The number of samples to save.

Default
4
use_8bit_adamboolean

Whether or not to use 8-bit Adam from bitsandbytes.

instance_promptstring

The prompt you use to describe your training images, in the format: `a [identifier] [class noun]`, where the `[identifier]` should be a rare token. Relatively short sequences with 1-3 letters work the best (e.g. `sks`, `xjy`). `[class noun]` is a coarse class descriptor of the subject (e.g. cat, dog, watch, etc.). For example, your `instance_prompt` can be: `a sks dog`, or with some extra description `a photo of a sks dog`. The trained model will learn to bind a unique identifier with your specific subject in the `instance_data`.

lr_warmup_stepsinteger

Number of steps for the warmup in the lr scheduler.

max_train_stepsinteger

Total number of training steps to perform. If provided, overrides num_train_epochs.

Default
2000
num_class_imagesinteger

Minimal class images for prior preservation loss. If not enough images are provided in class_data, additional images will be sampled with class_prompt.

Default
50
num_train_epochsinteger

Default
1
save_infer_stepsinteger

The number of inference steps for save sample.

Default
50
train_batch_sizeinteger

Batch size (per device) for the training dataloader.

Default
1
adam_weight_decaynumber

Weight decay to use

Default
0.01
prior_loss_weightnumber

Weight of prior preservation loss.

Default
1
sample_batch_sizeinteger

Batch size (per device) for sampling images.

Default
4
save_sample_promptstring

The prompt used to generate sample outputs to save.

train_text_encoderboolean

Whether to train the text encoder

Default
true
save_guidance_scalenumber

CFG for save sample.

Default
7.5
gradient_checkpointingboolean

Whether or not to use gradient checkpointing to save memory at the expense of slower backward pass.

with_prior_preservationboolean

Flag to add prior preservation loss.

Default
true
gradient_accumulation_stepsinteger

Number of updates steps to accumulate before performing a backward/update pass.

Default
1
save_sample_negative_promptstring

The negative prompt used to generate sample outputs to save.

Output schema

Type
uri