Train a Dreambooth Model with Custom Images (V2)
Overview
Using this endpoint you can train a Dreambooth model with your own images. You can train a model on any object or person.
Request
--request POST 'https://stablediffusionapi.com/api/v3/fine_tune_v2' \
Make a POST
request to https://stablediffusionapi.com/api/v3/fine_tune_v2 endpoint and pass the required parameters as a request body.
Now you can train a model on any other models used as a base model and get its style. You can choose to train on models like midjourney
, portraitplus
and many more.
Get the base_model_id from here.
You can also read our blog article to learn more about model training.
Body Attributes
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
instance_prompt | Text prompt with how you want to call your trained person/object |
class_prompt | Classification of the trained person/object |
base_model_id | Base model ID to train your model on |
images | Pass accessible direct links to images, cropped to 512 x 512 px. A good number is about 7-8 images. |
learning_rate_unet | Learning rate for the unet model. Leave it null for the default "1e-6" value. |
steps_unet | Number of steps for the unet model; Leave it null for the default "1500" value. |
learning_rate_text_encoder | Learning rate for text encoder model. Leave it null for the default "1e-6" value. |
steps_text_encoder | Number of steps for text encoder model. Leave it null for the default "350" value. |
training_type | The type of the object you are training on |
webhook | Get a post call when training is complete |
Learning Rate Values
This the complete list of all the possible values for the learning_rate_unet
and learning_rate_text_encoder
parameters.
["1e-5", "1e-6", "1e-7", "1e-8", "1e-9", "1e-10", "2e-0", "2e-1", "2e-2", "2e-3", "2e-4", "2e-5", "2e-6", "2e-7", "2e-8", "2e-9", "2e-10", "3e-0", "3e-1", "3e-2", "3e-3", "3e-4", "3e-5", "3e-6", "3e-7", "3e-8", "3e-9", "3e-10", "4e-0", "4e-1", "4e-2", "4e-3", "4e-4", "4e-5", "4e-6", "4e-7", "4e-8", "4e-9", "4e-10", "5e-0", "5e-1", "5e-2", "5e-3", "5e-4", "5e-5", "5e-6", "5e-7", "5e-8", "5e-9", "5e-10", "6e-0", "6e-1", "6e-2", "6e-3", "6e-4", "6e-5", "6e-6", "6e-7", "6e-8", "6e-9", "6e-10"]
Training Types
The table below lists all the possible values for the training_type
parameter.
Value | Description |
---|---|
men | Train on faces of men |
female | Train on faces of females |
couple | Train on couples of male and female; in images array pass images of couples, instead of a single person |
null | Train on object or anything |
Webhook Post JSON
This is an example webhook post call in JSON format.
{
"status": "success",
"training_status": "deploying_gpu",
"logs": "it will take upto 25 minutes",
"model_id": "F5jvdzGnYi",
}
Training Status Values
The table below describes all possible training statuses.
Status | Description |
---|---|
deploying_gpu | Deploying GPU |
training_started | Training started |
training_success | Training completed successfully |
trained_model_compressing | Compressing the trained model |
trained_model_uploading | Uploading the trained model |
trained_model_uploaded | Trained model uploaded |
deploying_model | Deploying the trained model |
model_ready | The trained model is ready for use |
Example
Body
{
"key": "",
"instance_prompt": "photo of adhik person",
"class_prompt": "photo of person",
"base_model_id": "portraitplus-diffusion",
"images": [
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00001.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00002.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00003.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00004.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00005.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00006.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00007.png"
],
"seed": "0",
"training_type": "men",
"learning_rate_unet": "2e-6",
"steps_unet": "1500",
"learning_rate_text_encoder": "1e-6",
"steps_text_encoder": "350",
"webhook": ""
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"instance_prompt": "photo of adhik person",
"class_prompt": "photo of person",
"base_model_id": "portraitplus-diffusion",
"images": [
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00001.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00002.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00003.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00004.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00005.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00006.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00007.png"
],
"seed": "0",
"training_type": "men",
"learning_rate_unet": "2e-6",
"steps_unet": "1500",
"learning_rate_text_encoder": "1e-6",
"steps_text_encoder": "350",
"webhook": ""
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://stablediffusionapi.com/api/v3/fine_tune_v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"instance_prompt" => "photo of adhik person",
"class_prompt" => "photo of person",
"base_model_id" => "portraitplus-diffusion",
"images" => [
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00001.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00002.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00003.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00004.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00005.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00006.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00007.png"
],
"seed" => "0",
"training_type" => "men",
"learning_rate_unet" => "2e-6",
"steps_unet" => "1500",
"learning_rate_text_encoder" => "1e-6",
"steps_text_encoder" => "350",
"webhook" => ""
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://stablediffusionapi.com/api/v3/fine_tune_v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://stablediffusionapi.com/api/v3/fine_tune_v2',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"instance_prompt": "photo of adhik person",
"class_prompt": "photo of person",
"base_model_id": "portraitplus-diffusion",
"images": [
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00001.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00002.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00003.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00004.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00005.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00006.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00007.png"
],
"seed": "0",
"training_type": "men",
"learning_rate_unet": "2e-6",
"steps_unet": "1500",
"learning_rate_text_encoder": "1e-6",
"steps_text_encoder": "350",
"webhook": ""
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://stablediffusionapi.com/api/v3/fine_tune_v2"
payload = json.dumps({
"key": "",
"instance_prompt": "photo of adhik person",
"class_prompt": "photo of person",
"base_model_id": "portraitplus-diffusion",
"images": [
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00001.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00002.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00003.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00004.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00005.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00006.png",
"https://stablediffusionapi.com/storage/avatars/AdhikJoshi_00007.png"
],
"seed": "0",
"training_type": "men",
"learning_rate_unet": "2e-6",
"steps_unet": "1500",
"learning_rate_text_encoder": "1e-6",
"steps_text_encoder": "350",
"webhook": ""
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\": \"\",\n \"instance_prompt\": \"a photo of adhik person\",\n \"class_prompt\" : \"a photo of person\",\n \"base_model_id\" : \"portraitplus-diffusion\",\n \"images\": [\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00000.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00001.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00002.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00003.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00004.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00005.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00006.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00007.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00008.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00009.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00010.png\",\n \"https://stablediffusionapi.com/storage/generations/AdhikJoshi_00011.png\"\n ],\n \"seed\": \"0\",\n \"training_type\": \"men\",\n \"learning_rate_unet\": \"2e-6\",\n \"steps_unet\": \"1500\",\n \"learning_rate_text_encoder\": \"1e-6\",\n \"steps_text_encoder\": \"350\",\n \"webhook\": \"\"\n}");
Request request = new Request.Builder()
.url("https://stablediffusionapi.com/api/v3/fine_tune")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"messege": "deploying_gpu",
"data": "it will take upto 25 minutes.",
"training_id": "F5jvdzGnYi"
}