Wan 2.2 14B Image Trainer Training

fal-ai/wan-22-image-trainer
Wan 2.2 text to image LoRA trainer. Fine-tune Wan 2.2 for subjects and styles with unprecedented detail.
Training
Commercial use

About

Endpoint for basic input.

1. Calling the API#

Install the client#

The client provides a convenient way to interact with the model API.

npm install --save @fal-ai/client

Setup your API Key#

Set FAL_KEY as an environment variable in your runtime.

export FAL_KEY="YOUR_API_KEY"

Submit a request#

The client API handles the API submit protocol. It will handle the request status updates and return the result when the request is completed.

import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/wan-22-image-trainer", {
  input: {
    training_data_url: "",
    trigger_phrase: ""
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);

2. Authentication#

The API uses an API Key for authentication. It is recommended you set the FAL_KEY environment variable in your runtime when possible.

API Key#

In case your app is running in an environment where you cannot set environment variables, you can set the API Key manually as a client configuration.
import { fal } from "@fal-ai/client";

fal.config({
  credentials: "YOUR_FAL_KEY"
});

3. Queue#

Submit a request#

The client API provides a convenient way to submit requests to the model.

import { fal } from "@fal-ai/client";

const { request_id } = await fal.queue.submit("fal-ai/wan-22-image-trainer", {
  input: {
    training_data_url: "",
    trigger_phrase: ""
  },
  webhookUrl: "https://optional.webhook.url/for/results",
});

Fetch request status#

You can fetch the status of a request to check if it is completed or still in progress.

import { fal } from "@fal-ai/client";

const status = await fal.queue.status("fal-ai/wan-22-image-trainer", {
  requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b",
  logs: true,
});

Get the result#

Once the request is completed, you can fetch the result. See the Output Schema for the expected result format.

import { fal } from "@fal-ai/client";

const result = await fal.queue.result("fal-ai/wan-22-image-trainer", {
  requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b"
});
console.log(result.data);
console.log(result.requestId);

4. Files#

Some attributes in the API accept file URLs as input. Whenever that's the case you can pass your own URL or a Base64 data URI.

Data URI (base64)#

You can pass a Base64 data URI as a file input. The API will handle the file decoding for you. Keep in mind that for large files, this alternative although convenient can impact the request performance.

Hosted files (URL)#

You can also pass your own URLs as long as they are publicly accessible. Be aware that some hosts might block cross-site requests, rate-limit, or consider the request as a bot.

Uploading files#

We provide a convenient file storage that allows you to upload files and use them in your requests. You can upload files using the client API and use the returned URL in your requests.

import { fal } from "@fal-ai/client";

const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });
const url = await fal.storage.upload(file);

Read more about file handling in our file upload guide.

5. Schema#

Input#

training_data_url string* required

URL to the training data.

trigger_phrase string* required

Trigger phrase for the model.

include_synthetic_captions boolean

Whether to include synthetic captions.

use_face_detection boolean

Whether to use face detection for the training data. When enabled, images will use the center of the face as the center of the image when resizing. Default value: true

use_face_cropping boolean

Whether to use face cropping for the training data. When enabled, images will be cropped to the face before resizing.

use_masks boolean

Whether to use masks for the training data. Default value: true

steps integer

Number of training steps. Default value: 1000

learning_rate float

Learning rate for training. Default value: 0.0007

is_style boolean

Whether the training data is style data. If true, face specific options like masking and face detection will be disabled.

{
  "training_data_url": "",
  "trigger_phrase": "",
  "use_face_detection": true,
  "use_face_cropping": false,
  "use_masks": true,
  "steps": 1000,
  "learning_rate": 0.0007,
  "is_style": false
}

Output#

diffusers_lora_file File* required

Low noise LoRA file.

high_noise_lora File* required

High noise LoRA file.

config_file File* required

Config file helping inference endpoints after training.

{
  "diffusers_lora_file": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "high_noise_lora": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "config_file": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  }
}

Other types#

TrainingStage#

num_steps integer

Number of training steps for this stage. Default value: 50

num_warmup_steps integer

Number of warmup steps for this stage. Default value: 10

resolution ResolutionEnum

Resolution for this training stage. Default value: "1024"

Possible enum values: 64, 128, 256, 512, 768, 1024, 1280, 1536

aspect_ratio AspectRatioEnum

Aspect ratio for this training stage. Default value: "3:4"

Possible enum values: 21:9, 16:9, 4:3, 1:1, 3:4, 9:16, 9:21

batch_size integer

Batch size for this training stage. Default value: 1

learning_rate float

Learning rate for this training stage. Default value: 0.0001

learning_rate_scheduler LearningRateScheduleEnum

Learning rate scheduler. Default value: "linear"

Possible enum values: linear, cosine, cosine_with_restarts, polynomial, constant, constant_with_warmup, piecewise_constant

transformer_trainer_style TransformerTrainerStyleEnum

The style of the transformer trainer. Either 'both', 'split', 'transformer_1', or 'transformer_2'. Default value: "in_sequence"

Possible enum values: both, split, transformer_1_only, transformer_2_only, in_sequence

split_train_timestep float

The timestep to split the training into two parts. Only applicable when transformer_trainer_style is 'split'. Default value: 0.875

File#

url string* required

The URL where the file can be downloaded from.

content_type string

The mime type of the file.

file_name string

The name of the file. It will be auto-generated if not provided.

file_size integer

The size of the file in bytes.

file_data string

File data