Z-LAN: Low-Rank Adaptation for Multilingual Text Rendering in Diffusion Models
This repository contains the official implementation of Z-LAN, a parameter-efficient fine-tuning framework for multilingual text rendering in diffusion models using Low-Rank Adaptation (LoRA).
🔥 News
2026-04: Paper accepted to Pattern Recognition Letters
2026-03: Released all 9 LoRA adapters on ModelScope
2026-02: Initial release
📋 Overview
Z-LAN enables accurate multilingual text rendering in diffusion models through language-specific LoRA adapters trained on minimal synthetic datasets (fewer than 100 images per language). The framework achieves:
94.9% average text rendering accuracy across 9 languages
import requests
import base64
from PIL import Image
from io import BytesIO
API_URL = "https://api-inference.modelscope.cn/v1/images/generations"
API_KEY = "your-api-key"
def generate_image(prompt, lora_id):
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "Tongyi-MAI/Z-Image",
"prompt": prompt,
"loras": lora_id,
"num_inference_steps": 50,
"guidance_scale": 7.5
}
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# Example: Generate image with Armenian text
result = generate_image(
prompt="zlan-Armenian, a red apple with Armenian text 'Խնձոր' below",
lora_id="ccArtermices/zlan-Armenian"
)
Usage with Local Diffusers
from diffusers import StableDiffusionXLPipeline
import torch
# Load base model
pipe = StableDiffusionXLPipeline.from_pretrained(
"Tongyi-MAI/Z-Image",
torch_dtype=torch.float16
).to("cuda")
# Load LoRA adapter
pipe.load_lora_weights("ccArtermices/zlan-Armenian")
# Generate image
image = pipe(
prompt="zlan-Armenian, a red apple with Armenian text 'Խնձոր' below",
num_inference_steps=50,
guidance_scale=7.5
).images[0]
image.save("output.png")
📁 Repository Structure
zlan/
├── data/
│ ├── prompts-multiLan.txt # Evaluation prompts
│ └── fonts/ # Unicode fonts for synthetic data
├── scripts/
│ ├── generate_synthetic_images.py # Synthetic data generation
│ ├── train_lora.py # LoRA training script
│ └── verify_images_cloud.py # MLLM-based verification
├── evaluation/
│ ├── lora_evaluation.py # Main evaluation pipeline
│ └── analyze_evaluation.py # Analysis and visualization
├── figures/ # Paper figures
└── README.md
🔧 Training Your Own LoRA Adapter
Step 1: Prepare Synthetic Data
from scripts.generate_synthetic_images import generate_synthetic_dataset
# Generate synthetic training images
generate_synthetic_dataset(
language="Armenian",
vocabulary=["Խնձոր", "Կատու", "Գիրք", ...], # Target words
font_path="fonts/NotoSansArmenian-Regular.ttf",
output_dir="data/synthetic/Armenian",
num_images=100
)
For questions and feedback, please open an issue on GitHub or contact the authors.
Note: The LoRA adapters are trained on minimal synthetic data and may not generalize to all use cases. We recommend testing on your specific application before deployment.
Z-LAN: Low-Rank Adaptation for Multilingual Text Rendering in Diffusion Models
This repository contains the official implementation of Z-LAN, a parameter-efficient fine-tuning framework for multilingual text rendering in diffusion models using Low-Rank Adaptation (LoRA).
🔥 News
📋 Overview
Z-LAN enables accurate multilingual text rendering in diffusion models through language-specific LoRA adapters trained on minimal synthetic datasets (fewer than 100 images per language). The framework achieves:
🌍 Supported Languages
🚀 Quick Start
Installation
Usage with ModelScope API
Usage with Local Diffusers
📁 Repository Structure
🔧 Training Your Own LoRA Adapter
Step 1: Prepare Synthetic Data
Step 2: Train LoRA Adapter
Step 3: Evaluate
📊 Results
Main Results
Error Reduction
📝 Citation
If you find this work useful, please cite:
📄 License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
🙏 Acknowledgments
📧 Contact
For questions and feedback, please open an issue on GitHub or contact the authors.
Note: The LoRA adapters are trained on minimal synthetic data and may not generalize to all use cases. We recommend testing on your specific application before deployment.