跳到主要内容

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_pathstring默认值: runwayml/stable-diffusion-v1-5
取值范围:
stabilityai/stable-diffusion-xl-base-1.0
runwayml/stable-diffusion-v1-5
Pretrained model name
sdxlboolean默认值: False
sdxl
repeatsinteger默认值: 10
The number of times an image is reused within an epoch
train_batch_sizeinteger默认值: 1
取值范围: [1, inf)
Batch size for training
epochinteger默认值: 20
取值范围: [1, inf)
Epoch size for training
mixed_precisionstring默认值: fp16
取值范围:
no
fp16
bf16
fp8
Whether or not to use mixed precision training
train_data_dirstring默认值:
Image folder (containing training images subfolders)
max_resolutionstring默认值: 512,512
Max resolution (width, height)
color_augboolean默认值: False
Enable weak color augmentation
flip_augboolean默认值: False
Enable horizontal flip augmentation
output_dirstring默认值:
Output directory for trained model
save_every_n_epochsinteger默认值: 10
取值范围: [1, inf)
Save every N epochs
save_precisionstring默认值: fp16
取值范围:
float
fp16
bf16
Save precision
learning_ratenumber默认值: 1e-06
取值范围: [0.0, inf)
Learning rate (Set to 0 to not train the Unet)
learning_rate_tenumber默认值: 1e-06
取值范围: [0.0, 1.0]
Learning rate TE (Set to 0 to not train the Text Encoder)
learning_rate_te1number默认值: 1e-06
取值范围: [0.0, 1.0]
Learning rate TE1 (Set to 0 to not train the Text Encoder 1)
learning_rate_te2number默认值: 1e-06
取值范围: [0.0, 1.0]
Learning rate TE2 (Set to 0 to not train the Text Encoder 2)
lr_schedulerstring默认值: constant
取值范围:
constant
adafactor
constant_with_warmup
cosine
cosine_with_restarts
linear
polynomial
LR Scheduler
lr_warmupnumber默认值: 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_cyclesinteger默认值: 1
取值范围: [1, inf)
Number of restarts for cosine scheduler with restarts
lr_scheduler_powernumber默认值: 1.0
取值范围: [0.0, inf)
Polynomial power for polynomial scheduler
optimizerstring默认值: PagedAdamW8bit
取值范围:
AdamW
AdamW8bit
Adafactor
DAdaptation
DAdaptAdaGrad
DAdaptAdam
DAdaptAdan
DAdaptAdanIP
DAdaptAdamPreprint
DAdaptLion
DAdaptSGD
Lion
Lion8bit
PagedAdamW8bit
PagedAdamW32bit
PagedLion8bit
Prodigy
SGDNesterov
SGDNesterov8bit
Optimizer
min_snr_gammainteger默认值: 0
取值范围: [0, 20]
Recommended value of 5 when used
shuffle_captionboolean默认值: False
Shuffle caption
keep_tokensinteger默认值: 0
取值范围: [0, 32]
Keep n tokens
no_token_paddingboolean默认值: False
No token padding
max_token_lengthinteger默认值: 75
取值范围:
75
150
225
max token length of text encoder
noise_offset_typestring默认值: Original
取值范围:
Original
Multires
Noise offset type
noise_offsetnumber默认值: 0
取值范围: [0.0, 1.0]
Recommended values are 0.05 - 0.15
noise_offset_random_strengthboolean默认值: False
Use random strength between 0~noise_offset for noise offset
adaptive_noise_scalenumber默认值: 0
取值范围: [-1.0, 1.0]
Add latent mean absolute value * this value to noise_offset
multires_noise_iterationsinteger默认值: 0
取值范围: [0, 64]
Enable multires noise (recommended values are 6-10)
multires_noise_discountnumber默认值: 0.3
取值范围: [0.0, 1.0]
Recommended values are 0.8. For LoRAs with small datasets, 0.1-0.3
sample_every_n_epochsinteger默认值: 0
Sample every n epochs
sample_samplerstring默认值: 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_promptsstring默认值:
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
seedinteger默认值: 0
取值范围: [0, inf)
Seed (Set to 0 to make random)
clip_skipinteger默认值: 1
取值范围: [0, 12]
Clip skip
stop_text_encoder_traininginteger默认值: 0
取值范围: [-1, 100]
Stop TE (% of total steps)
gradient_accumulation_stepsinteger默认值: 1
取值范围: [1, 120]
Number of updates steps to accumulate before performing a backward/update pass
optimizer_argsstring默认值:
(Optional) eg: relative_step=True scale_parameter=True warmup_init=True
lr_scheduler_argsstring默认值:
(Optional) eg: milestones=[1,10,30,50] gamma=0.1
enable_bucketboolean默认值: True
Enable buckets
random_cropboolean默认值: False
Random crop instead of center crop
min_bucket_resointeger默认值: 64
取值范围: [64, 4096]
Minimum size in pixel a bucket can be (>= 64)
max_bucket_resointeger默认值: 2048
取值范围: [64, 4096]
Maximum size in pixel a bucket can be (>= 64)
bucket_no_upscaleboolean默认值: True
Don't upscale bucket resolution
bucket_reso_stepsinteger默认值: 64
取值范围: [1, 128]
Bucket resolution steps
caption_dropout_every_n_epochsinteger默认值: 0
Dropout caption every n epochs
caption_dropout_ratenumber默认值: 0
取值范围: [0.0, 1.0]
Rate of caption dropout
weighted_captionsboolean默认值: False
Enable weighted captions in the standard style (token:1.3). No commas inside parens, or shuffle/dropout may break the decoder.
ip_noise_gammanumber默认值: 0
取值范围: [0.0, 1.0]
Enable input perturbation noise. used for regularization. recommended value: around 0.1
ip_noise_gamma_random_strengthboolean默认值: False
Use random strength between 0~ip_noise_gamma for input perturbation noise
min_timestepinteger默认值: 0
取值范围: [0, 1000]
Values greater than 0 will make the model more img2img focussed. 0 = image only
max_timestepinteger默认值: 1000
取值范围: [0, 1000]
Values lower than 1000 will make the model more img2img focussed. 1000 = noise only

返回响应(json)