Stable Diffusion Dreambooth微调API
请求方法
POST
请求地址
https://api.lanrui.co/api/sd/train/dreambooth
CURL 示例
curl --location 'https://api.lanrui.co/api/sd/train/dreambooth' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {填入API Key,删除花括号}' \
--data 'request_dict = {
"pretrained_model_name_or_path": "runwayml/stable-diffusion-v1-5",
"train_batch_size": 1,
"bucket_no_upscale": true,
"bucket_reso_steps": 1.0,
"caption_dropout_every_n_epochs": 0.0,
"caption_dropout_rate": 0.1,
"clip_skip": 1,
"color_aug": false,
"repeats": 10,
"epoch": 2,
"flip_aug": false,
"gradient_accumulation_steps": 1.0,
"keep_tokens": 1,
"learning_rate": "0.0000166666666",
"lr_scheduler": "cosine",
"lr_warmup": 10,
"max_bucket_reso": 1024,
"max_resolution": "512,512",
"max_token_length": 150,
"min_bucket_reso": 256,
"mixed_precision": "bf16",
"optimizer": "Lion",
"random_crop": false,
"save_every_n_epochs": 1,
"save_precision": "fp16",
"shuffle_caption": true,
"train_batch_size": 4
}'
请求 Body 参数(application/json)
参数名 | 参数类型 | 取值范围 | 参数释义 | 是否必填 |
---|---|---|---|---|
pretrained_model_name_or_path | string | 默认值: runwayml/stable-diffusion-v1-5 取值范围: stabilityai/stable-diffusion-xl-base-1.0 runwayml/stable-diffusion-v1-5 | Pretrained model name | 否 |
sdxl | boolean | 默认值: False | sdxl | 否 |
repeats | integer | 默认值: 10 | The number of times an image is reused within an epoch | 否 |
train_batch_size | integer | 默认值: 1 取值范围: [1, inf) | Batch size for training | 否 |
epoch | integer | 默认值: 20 取值范围: [1, inf) | Epoch size for training | 否 |
mixed_precision | string | 默认值: fp16 取值范围: no fp16 bf16 fp8 | Whether or not to use mixed precision training | 否 |
train_data_dir | string | 默认值: 空 | Image folder (containing training images subfolders) | 否 |
max_resolution | string | 默认值: 512,512 | Max resolution (width, height) | 否 |
color_aug | boolean | 默认值: False | Enable weak color augmentation | 否 |
flip_aug | boolean | 默认值: False | Enable horizontal flip augmentation | 否 |
output_dir | string | 默认值: 空 | Output directory for trained model | 否 |
save_every_n_epochs | integer | 默认值: 10 取值范围: [1, inf) | Save every N epochs | 否 |
save_precision | string | 默认值: fp16 取值范围: float fp16 bf16 | Save precision | 否 |
learning_rate | number | 默认值: 1e-06 取值范围: [0.0, inf) | Learning rate (Set to 0 to not train the Unet) | 否 |
learning_rate_te | number | 默认值: 1e-06 取值范围: [0.0, 1.0] | Learning rate TE (Set to 0 to not train the Text Encoder) | 否 |
learning_rate_te1 | number | 默认值: 1e-06 取值范围: [0.0, 1.0] | Learning rate TE1 (Set to 0 to not train the Text Encoder 1) | 否 |
learning_rate_te2 | number | 默认值: 1e-06 取值范围: [0.0, 1.0] | Learning rate TE2 (Set to 0 to not train the Text Encoder 2) | 否 |
lr_scheduler | string | 默认值: constant 取值范围: constant adafactor constant_with_warmup cosine cosine_with_restarts linear polynomial | LR Scheduler | 否 |
lr_warmup | number | 默认值: 0 取值范围: [0.0, inf) | LR warmup (% of total steps) Can't use LR warmup with LR Scheduler constant... setting to 0 and disabling field... | 否 |
lr_scheduler_num_cycles | integer | 默认值: 1 取值范围: [1, inf) | Number of restarts for cosine scheduler with restarts | 否 |
lr_scheduler_power | number | 默认值: 1.0 取值范围: [0.0, inf) | Polynomial power for polynomial scheduler | 否 |
optimizer | string | 默认值: PagedAdamW8bit 取值范围: AdamW AdamW8bit Adafactor DAdaptation DAdaptAdaGrad DAdaptAdam DAdaptAdan DAdaptAdanIP DAdaptAdamPreprint DAdaptLion DAdaptSGD Lion Lion8bit PagedAdamW8bit PagedAdamW32bit PagedLion8bit Prodigy SGDNesterov SGDNesterov8bit | Optimizer | 否 |
min_snr_gamma | integer | 默认值: 0 取值范围: [0, 20] | Recommended value of 5 when used | 否 |
shuffle_caption | boolean | 默认值: False | Shuffle caption | 否 |
keep_tokens | integer | 默认值: 0 取值范围: [0, 32] | Keep n tokens | 否 |
no_token_padding | boolean | 默认值: False | No token padding | 否 |
max_token_length | integer | 默认值: 75 取值范围: 75 150 225 | max token length of text encoder | 否 |
noise_offset_type | string | 默认值: Original 取值范围: Original Multires | Noise offset type | 否 |
noise_offset | number | 默认值: 0 取值范围: [0.0, 1.0] | Recommended values are 0.05 - 0.15 | 否 |
noise_offset_random_strength | boolean | 默认值: False | Use random strength between 0~noise_offset for noise offset | 否 |
adaptive_noise_scale | number | 默认值: 0 取值范围: [-1.0, 1.0] | Add latent mean absolute value * this value to noise_offset | 否 |
multires_noise_iterations | integer | 默认值: 0 取值范围: [0, 64] | Enable multires noise (recommended values are 6-10) | 否 |
multires_noise_discount | number | 默认值: 0.3 取值范围: [0.0, 1.0] | Recommended values are 0.8. For LoRAs with small datasets, 0.1-0.3 | 否 |
sample_every_n_epochs | integer | 默认值: 0 | Sample every n epochs | 否 |
sample_sampler | string | 默认值: euler_a 取值范围: ddim pndm lms euler euler_a heun dpm_2 dpm_2_a dpmsolver dpmsolver++ dpmsingle k_lms k_euler k_euler_a k_dpm_2 k_dpm_2_a | Sample sampler | 否 |
sample_prompts | string | 默认值: 空 | Enter one sample prompt per line to generate multiple samples per cycle. Optional specifiers include: --w (width), --h (height), --d (seed), --l (cfg scale), --s (sampler steps) and --n (negative prompt). eg: masterpiece, best quality, 1girl, in white shirts, upper body, looking at viewer, simple background --n low quality, worst quality, bad anatomy,bad composition, poor, low effort --w 768 --h 768 --d 1 --l 7.5 --s 28 | 否 |
seed | integer | 默认值: 0 取值范围: [0, inf) | Seed (Set to 0 to make random) | 否 |
clip_skip | integer | 默认值: 1 取值范围: [0, 12] | Clip skip | 否 |
stop_text_encoder_training | integer | 默认值: 0 取值范围: [-1, 100] | Stop TE (% of total steps) | 否 |
gradient_accumulation_steps | integer | 默认值: 1 取值范围: [1, 120] | Number of updates steps to accumulate before performing a backward/update pass | 否 |
optimizer_args | string | 默认值: 空 | (Optional) eg: relative_step=True scale_parameter=True warmup_init=True | 否 |
lr_scheduler_args | string | 默认值: 空 | (Optional) eg: milestones=[1,10,30,50] gamma=0.1 | 否 |
enable_bucket | boolean | 默认值: True | Enable buckets | 否 |
random_crop | boolean | 默认值: False | Random crop instead of center crop | 否 |
min_bucket_reso | integer | 默认值: 64 取值范围: [64, 4096] | Minimum size in pixel a bucket can be (>= 64) | 否 |
max_bucket_reso | integer | 默认值: 2048 取值范围: [64, 4096] | Maximum size in pixel a bucket can be (>= 64) | 否 |
bucket_no_upscale | boolean | 默认值: True | Don't upscale bucket resolution | 否 |
bucket_reso_steps | integer | 默认值: 64 取值范围: [1, 128] | Bucket resolution steps | 否 |
caption_dropout_every_n_epochs | integer | 默认值: 0 | Dropout caption every n epochs | 否 |
caption_dropout_rate | number | 默认值: 0 取值范围: [0.0, 1.0] | Rate of caption dropout | 否 |
weighted_captions | boolean | 默认值: False | Enable weighted captions in the standard style (token:1.3). No commas inside parens, or shuffle/dropout may break the decoder. | 否 |
ip_noise_gamma | number | 默认值: 0 取值范围: [0.0, 1.0] | Enable input perturbation noise. used for regularization. recommended value: around 0.1 | 否 |
ip_noise_gamma_random_strength | boolean | 默认值: False | Use random strength between 0~ip_noise_gamma for input perturbation noise | 否 |
min_timestep | integer | 默认值: 0 取值范围: [0, 1000] | Values greater than 0 will make the model more img2img focussed. 0 = image only | 否 |
max_timestep | integer | 默认值: 1000 取值范围: [0, 1000] | Values lower than 1000 will make the model more img2img focussed. 1000 = noise only | 否 |