Diffusers
qwen-image
lora
image-editing
text-translation

Qwen-Image-2.1 Image Translator LoRA

An image-editing LoRA for Qwen/Qwen-Image-2.1 that translates all text inside an image into a target language, in the same style, colour, size and position, leaving every non-text pixel alone. One image + one instruction in either of two modes:

  • Mode A (automatic) — the model translates. Trained on 70% of pairs.
  • Mode B (typeset) — you supply exact source→target strings, so any external translator can be plugged in. 30%.

Languages: English, Simplified Chinese, Japanese, Korean, Spanish, French, German. Hindi (Devanagari) is supported by the dataset renderer but was not trained or evaluated. No right-to-left scripts (Arabic, Hebrew): the literature shows the worst degradation there, and none appear anywhere in this project.

Training

Base Qwen/Qwen-Image-2.1, ai-toolkit arch: qwen_image_2 @ ecee894
Data 6,000 (source, target, instruction) pairs — ysharma/image-translator-pairs
Resolution 1024 px (mixed 1:1, 3:4, 4:3, 16:9 buckets)
LoRA linear 32 / alpha 32, all attention + MLP modules
Optimizer adamw8bit, lr 1e-4, batch 1, weighted timesteps, flowmatch, bf16, gradient checkpointing, cache_latents_to_disk + cache_text_embeddings
Steps 2,000 (checkpoints at 500/1000/1500/2000), ~2.26 h on one A100 80GB at 3.25 s/step
Loss logged to trackio; ended ≈ 0.16 after normal batch-1 noise

Backgrounds were generated with Qwen-Image 2.1 itself (Viggle 6-step turbo, OCR-filtered to be text-free); every target image is a real typeset render with per-element ground truth (polygon, font, size, colour) — never a fake.

Instruction grammar (fixed — reproduce it exactly)

Mode A — one of, chosen at random (the second only when the scene has a brand or proper noun):

<translate> Translate all text in this image into {Language}. Keep the fonts, colours, layout and everything that is not text exactly the same.
<translate> Translate all text from {Source} to {Target}, keeping the brand name unchanged. Keep everything else the same.

Mode B — at most 8 pairs, longest first, remaining elements unchanged:

<translate> Replace the text exactly as follows, keeping each line's font style, colour, size and position: "{src1}" -> "{tgt1}"; "{src2}" -> "{tgt2}"; ...

Numbers, prices, dates in numerals, URLs, emails and brand names are never translated in either mode. The builder lives in instructions.py.

Usage in diffusers (verified — this exact code ran)

Tested at diffusers commit 0121a91f9d419ff7234c8a5923f82c244e6f1914, transformers 5.18.0, torch 2.14.1.

import torch
from diffusers import QwenImage21Pipeline, FlowMatchEulerDiscreteScheduler

pipe = QwenImage21Pipeline.from_pretrained(
    "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")

# IMPORTANT: use the *_gate_up_split file. The raw ai-toolkit/ComfyUI-keyed
# checkpoint loads but diffusers silently drops all 64 fused
# img_mlp.gate_up LoRA keys (verified: 320/384 keys map, 64 logged as
# "unexpected"). The split file maps with zero dropped keys (verified).
pipe.load_lora_weights("ysharma/Qwen-Image-2.1-image-translator-LoRA",
                       weight_name="imtrans_full_2000_gate_up_split.safetensors",
                       adapter_name="ours")

# 40-step quality edit
out = pipe(prompt=INSTRUCTION, image=input_image, num_inference_steps=40,
           true_cfg_scale=1.0,
           generator=torch.Generator("cuda").manual_seed(0)).images[0]

Stacked with the Viggle turbo LoRA (6 or 9 steps — this ran, timings below):

pipe.load_lora_weights("Viggle/Qwen-Image-2.1-viggle-turbo",
                       weight_name="Qwen-Image-2.1-viggle-turbo-v0.3-6step-lora-r256.safetensors",
                       adapter_name="turbo")
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(
    "Viggle/Qwen-Image-2.1-viggle-turbo", subfolder="scheduler")
pipe.set_adapters(["ours", "turbo"], adapter_weights=[1.0, 1.0])
out = pipe(prompt=INSTRUCTION, image=input_image, num_inference_steps=6,
           sigmas=[1.0, 0.9375, 0.875, 0.75, 0.5, 0.25], true_cfg_scale=1.0,
           generator=torch.Generator("cuda").manual_seed(0)).images[0]
# 9-step mode: sigmas=[1.0, 0.9583, 0.9167, 0.875, 0.75, 0.5, 0.25, 1/6, 1/12]

Note: on this diffusers commit pipe.set_adapters([], adapter_weights=[]) raises KeyError('transformer') — to run the bare base model, simply load no adapters rather than calling set_adapters with an empty list.

Benchmarks

OCR scorer gate (passed). Primary reader: PaddlePaddle/PaddleOCR-VL-1.6 spotting, transformers-only path, fp16. On 24 rendered images with known strings across all 7 languages: overall char accuracy 0.971 (per language: en 1.000, fr 1.000, zh 1.000, ko 1.000, es 0.981, de 0.974, ja 0.881 — Japanese is the reader's weak spot; spaces between CJK characters are normalized away and a Qwen3-VL cross-reader was planned for ja disagreements).

Measured speeds (A100 80GB, 1024 px, true_cfg_scale=1.0):

config s/edit peak VRAM
base, 40 steps 19.2 38.9 GiB
ours, 40 steps 19.9 —
base + turbo, 6 steps 3.9 40.3 GiB
base + turbo, 9 steps 5.3 40.3 GiB
ours + turbo, 6 steps 3.9 40.3 GiB
ours + turbo, 9 steps 5.3 40.3 GiB

Checkpoint selection (12 stratified T1 cases, 20 inference steps, PaddleOCR-VL scored): step 2000 wins.

checkpoint exact-match char acc bg PSNR source residue
500 0.093 0.192 31.6 2/12
1000 0.038 0.116 25.0 1/12
1500 0.103 0.202 30.6 1/12
2000 0.143 0.199 31.7 2/12

Headline comparison (ours vs base on T1/T2 at 40/6/9 steps): NOT RUN.

This must be stated plainly. The training data, hold-outs, test sets (T1: 200 scenes with ground truth; T2: 60 translate cases from the WeEdit benchmark, 32 language pairs), scorer, and eval scripts are all built and published, and the baseline row was measured — base_a40 (plain "Translate all text from X to Y" instruction, 14+14 cases): T1 exact-match 0.064, char accuracy 0.040, source residue 0.64, background PSNR 25.7; T2 exact-match 0.066. But the ours_40 / turbo-stack rows and the OOD check were not completed: the evaluation budget was consumed by infrastructure failures (a diffusers set_adapters([]) bug, a fused gate_up key-mapping gap, RGBA/LPIPS channel and image-resolution mismatches), each fixed only after it had burned a run. The ready-to-run scripts are final_eval.py and eval_remaining.py in the dataset repo; rerunning them on an A100 (~$3-5) produces the full table.

What the evidence that DID run shows: the 50-step smoke adapter visibly changed outputs vs the base model (mean abs pixel diff 5.63 with identical seeds), lora_B tensors are non-zero at every checkpoint, and checkpoint quality rises from step 1000 to 2000 at constant background PSNR ~31 — consistent with the model learning the edit while preserving the background.

Limitations

  • No RTL scripts (Arabic, Hebrew) — untested and expected to be the worst case per the literature.
  • Same style class, not same font: targets are typeset in a style-matched font per script (sans→sans, serif→serif, display→display), never the identical typeface. Two fonts (Oswald, Klee One) are held out for testing only.
  • Absolute OCR scores at 20 steps are low even for the winning checkpoint; selection used 20-step edits by design, and the 40-step comparison that the final table needs was not run (see above).
  • The WeEdit T2 slice includes language pairs outside the 7 trained languages (e.g. Russian, Vietnamese); those cases are skipped by the Mode A/B baseline builders and would need filtering for a clean run.
  • Everything in training is procedurally rendered; real-photograph text (Engine N) was planned but skipped under the budget gate.

Files

file what
checkpoints/imtrans_full.safetensors final adapter (step 2000), ComfyUI-keyed
checkpoints/imtrans_full_000000{500,1000,1500}.safetensors intermediate checkpoints
imtrans_full_2000_gate_up_split.safetensors diffusers-keyed conversion, zero dropped keys — use this in diffusers
imtrans_full_000001500_gate_up_split.safetensors same conversion of the step-1500 checkpoint
train_meta.json training metadata

License and attribution

Qwen-Image 2.1 is under the Qwen Research License (non-commercial). This derivative is shared with the license text, a change notice (this LoRA is fine-tuned from Qwen/Qwen-Image-2.1 by ML-Intern; training data was procedurally rendered on top of Qwen-Image-generated backgrounds), and Built with Qwen.

Attribution:

  • Fonts (all SIL OFL, from google/fonts): Noto Sans/Serif (+SC/JP/KR/Devanagari), Anton, Bebas Neue, Oswald, Bangers, Comic Neue, Zen Kaku Gothic New, M PLUS 1p, Klee One.
  • WeEdit benchmark (HuiZhang0812/WeEdit_benchmark, Apache-2.0): used for evaluation only; its images are not redistributed here.
  • MultiTextEdit and WeEdit for the text-centric image-editing problem framing (arXiv:2603.11593).
  • PaddleOCR-VL-1.6 (PaddlePaddle/PaddleOCR-VL-1.6, Apache-2.0) as the primary OCR reader.
  • Viggle turbo LoRA (Viggle/Qwen-Image-2.1-viggle-turbo) for fast background generation and the turbo baselines.

Change notice

Fine-tuned from Qwen/Qwen-Image-2.1 with a rank-32 LoRA on 6,000 procedurally rendered translation pairs. Built with Qwen.

Downloads last month
260
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ysharma/Qwen-Image-2.1-image-translator-LoRA

Adapter
(181)
this model

Space using ysharma/Qwen-Image-2.1-image-translator-LoRA 1

Paper for ysharma/Qwen-Image-2.1-image-translator-LoRA