Feature 01Integration

Integrating ERNIE-Image LoRAs Into Your Brand System

Train a brand-specific LoRA on ERNIE-Image, plug it into the standard and turbo LoRA endpoints, and run the cost math end to end. Real training submit code, real inference code, real dollar figures per asset.

By ernie-api editorial..7 min read

If you ship marketing creative at real volume, your image model has to respect three constraints: your color palette, your typography feel, and your visual grammar (rounded vs sharp, flat vs gradient). A raw ERNIE-Image call gets you one on a good day. A brand-trained LoRA gets you all three on every call.

This walks the full loop: training on fal-ai/ernie-image-trainer, inference on fal-ai/ernie-image/lora and /lora/turbo, and real cost per asset.

Why a LoRA beats prompt engineering

You can get close with a long prompt. By render fifty, the rounded sans has turned gothic, the cream has shifted to beige, the grain has vanished. A LoRA bakes brand preferences into a small adapter. Thirty to a hundred training images teach ERNIE your palette, grammar, and typography bias. Once trained, it is a 50 to 200 MB file you plug into every inference call. The prompt becomes a scene description; brand feel comes from the weights.

Brand LoRA training dataset
Brand LoRA training dataset

Step 1: build the training set

Collect 30 to 100 brand-consistent images: posters, product shots, social graphics. Caption each focused on content, not style. 1024x1024 square is safest. Zip image-caption pairs and upload to fal storage.

Step 2: submit the training job

JAVASCRIPT
1import { fal } from "@fal-ai/client";
2
3fal.config({ credentials: process.env.FAL_KEY });
4
5const trainingData = await fal.storage.upload(
6 new File([await fetch("./brand-dataset.zip").then(r => r.blob())], "brand.zip")
7);
8
9const { request_id } = await fal.queue.submit("fal-ai/ernie-image-trainer", {
10 input: {
11 images_data_url: trainingData,
12 trigger_word: "brandstyle",
13 steps: 1500,
14 learning_rate: 0.0004,
15 resolution: 1024,
16 is_style: true
17 }
18});
19
20let status = await fal.queue.status("fal-ai/ernie-image-trainer", { requestId: request_id });
21while (status.status !== "COMPLETED") {
22 await new Promise(r => setTimeout(r, 30000));
23 status = await fal.queue.status("fal-ai/ernie-image-trainer", { requestId: request_id });
24}
25
26const result = await fal.queue.result("fal-ai/ernie-image-trainer", { requestId: request_id });
27const loraUrl = result.data.diffusers_lora_file.url;

The trigger_word activates the LoRA in every inference prompt. Pick a made-up word. is_style: true teaches visual style, not a subject. Training takes 15 to 40 minutes. 1500 steps on 60 images is the sweet spot for brand style.

Step 3: inference with the LoRA

JAVASCRIPT
1const result = await fal.subscribe("fal-ai/ernie-image/lora", {
2 input: {
3 prompt: "brandstyle launch poster, paper airplane over a city skyline, headline reads 'TAKEOFF', subhead reads 'April 2026'",
4 loras: [{ path: loraUrl, scale: 0.9 }],
5 image_size: "portrait_16_9",
6 num_inference_steps: 50,
7 guidance_scale: 4.5,
8 seed: 77
9 },
10 logs: true
11});

scale: 0.9 is LoRA strength. Drop to 0.6 if the LoRA overrides prompt content. For drafts, swap to /lora/turbo at 8 steps: one third the cost.

JAVASCRIPT
1await fal.subscribe("fal-ai/ernie-image/lora/turbo", {
2 input: {
3 prompt: "brandstyle social thumbnail, teal notebook on a cream desk",
4 loras: [{ path: loraUrl, scale: 0.9 }],
5 image_size: "landscape_16_9",
6 num_inference_steps: 8
7 }
8});
LoRA inference with trigger word
LoRA inference with trigger word

Step 4: cost math

Real numbers for a 50-asset campaign.

Training. 1500 steps on 60 images is $8 to $15. Call it $12.

Inference. /lora is $0.03/MP ($0.03 at 1024x1024, $0.055 at 1792x1024). /lora/turbo is $0.01/MP.

Fifty landscape assets with three variants each (150 renders) on standard: 150 * $0.055 = $8.25. Plus $12 training: $20.25 total.

Smarter path: 150 turbo drafts at $0.018 = $2.70, then promote 50 winners to standard at $2.75. Total $5.45 inference plus $12 training, roughly $17.50 all in, $0.35 per finished branded image. A freelance illustrator runs $200 to $500 per asset.

Step 5: the feedback loop

First LoRA ships; the teal is not quite your teal. Retrain with 10 to 20 new examples, bump to 2000 steps. Keep the trigger word. Swap the URL in production config; every render pulls updated weights.

One 60-image run captures palette, illustration grammar, and typography weight. Style lives in the LoRA; content lives in the prompt. Train once, infer a thousand times.


00Back to the archive
Also reading