This is an asynchronous API; only the task_id is returned initially. Utilize this task_id to query the Task Result API at Get Style Training Result API to retrieve the results of the image generation.
This parameter controls the extent of model parameter updates during each iteration. A higher learning rate results in larger updates, potentially speeding up the learning process but risking overshooting the optimal solution. Conversely, a lower learning rate ensures smaller, more precise adjustments, which may lead to a more stable convergence at the cost of slower training.
Enum: 1e-4, 1e-5, 1e-6, 2e-4, 5e-5
This parameter specifies the maximum number of training steps to be executed before halting the training process. It sets a limit on the duration of training, ensuring that the model does not continue to train indefinitely. If the max_train_steps set to 2000 and images amount in parameter image_dataset_items is 10, the number of training steps per graph is 200. Minimum value is 1.
A seed is a number from which Stable Diffusion generates noise, which, makes training deterministic. Using the same seed and set of parameters will produce identical LoRA each time, Minimum 1.
This parameter specifies the type of learning rate scheduler to be used during the training process. The scheduler dynamically adjusts the learning rate according to one of the specified strategies. constant: Maintains a fixed learning rate throughout training. linear: Gradually decreases the learning rate linearly from a higher to a lower value. cosine: Adjusts the learning rate following a cosine curve, decreasing it initially and then increasing towards the end. cosine_with_restarts: Similar to cosine, but resets the rate periodically to avoid local minima. polynomial: Decreases the learning rate according to a polynomial decay. constant_with_warmup: Starts with a lower learning rate and warms up to a constant rate after a specified number of steps.
Enum: constant, linear, cosine, cosine_with_restarts, polynomial, constant_with_warmup
This parameter determines the number of initial training steps during which the learning rate increases gradually, effective only when the lr_scheduler is set to one of the following modes: linear, cosine, cosine_with_restarts, polynomial, or constant_with_warmup. The warmup phase helps in stabilizing the training process before the main learning rate schedule begins. The minimum value for this parameter is 0, indicating no warmup, Minimum 0.
Type of components. When set to face_crop_region, args can be set to args: [name: ratio, value: 1.0], ratio > 1 means more non-facial area will be included. When set to resize, args can be set to args: [name: width, value: 512, name: height, value: 512], which mean all the images will be cropped to 512*512. When set to face_restore, args can be set to args: [name: method, value:gfpgan_1.4], which mean face restore will be open.
Enum: face_crop_region, resize, face_restore
Represents the current status of a task, particularly useful for monitoring and managing the progress of training tasks. Each status indicates a specific phase in the task’s lifecycle.
Enum: UNKNOWN, QUEUING, TRAINING, SUCCESS, CANCELED, FAILED
Currently we only supports uploading images in png / jpeg / webp format.
Each task supports uploading up to 50 images. In order to make the final effect good, the images uploaded should meet some basic conditions, such as: “portrait in the center”, “no watermark”, “clear picture”, etc.
In this step, we will begin the model training process, which is expected to take approximately 10 minutes, depending on the actual server’s availability.
There are four types of parameters for model traning: Model info parameters, dataset parameters, components parameters,expert parameters, you can set them according to our tables below.
Here are some tips to train a good model:
At least 10 photos of faces that meet the requirements.
For parameters instance_prompt, we suggests using “a close photo of ohwx <man|\woman>”
For parameters base_model, value v1-5-pruned-emaonly has better generalization ability and can be used in combination with various Base models, such as dreamshaper 2.5D, value epic-realism has a strong sense of reality.
Type
Parameters
Description
Model info parameters
name
Name of your training model
Model info parameters
base_model
base_model type
Model info parameters
width
Target image width
Model info parameters
height
Target image height
dataset parameters
image_dataset_items
Array: consist of imageUrl and image caption
dataset parameters
- image_dataset_items.assets_id
images assets_id, which can be found in step Get image upload URL
components parameters
components
Array: consist of name and args, this is a common parameters configured for training.
components parameters
- components.name
Type of components, Enum: face_crop_region, resize, face_restore
components parameters
- components.args
Detail values of components.name
expert parameters
expert_setting
expert parameters.
expert parameters
- instance_prompt
Captions for all the training images, here is a guidance of how to make a effective prompt : Click Here
expert parameters
- batch_size
batch size of training.
expert parameters
- max_train_steps
Max train steps, 500 is enought for lora model training.
expert parameters
- …
More expert parameters can be access at api reference.
After model deployed successfully, we can download the model files or generate images directly.
3.2.1 Use the generated models to create images
In order to use the trained lora models, We need to add model_name into the request of endpoint /v3/async/txt2img or /v3/async/img2img. Currently trained lora model can not be used in /v3 endpoint.
Below is a example of how to generate images with trained model:
Please set the Content-Type header to application/json in your HTTP request to indicate that you are sending JSON data. Currently, only JSON format is supported.
HTTP status codes in the 2xx range indicate that the request has been successfully accepted, while status codes in the 5xx range indicate internal server errors.