Skip to main content
Back

Bilibili's TextFlux Renders Multilingual Text in Images With 1% of Training Data

Bilibili researchers ditch OCR encoders and train on 30K images to render text in any language directly inside real photos.

Pro

  • Bilibili and PKU release TextFlux, an OCR-free DiT model for multilingual scene text rendering.
  • Replaces OCR encoders with a rendered glyph image concatenated to the scene at input.
  • Trained on 30,405 images, roughly 1% of what AnyWord-3M-scale methods use.
  • Hits 64.1% reconstruction accuracy on ReCTS Chinese vs 25.2% for AnyText2.
  • Adapts to new languages with fewer than 1,000 samples and generalizes zero-shot to unseen scripts.
  • Weights and code available on Hugging Face and GitHub, with a single-line beta.

Putting readable text into an AI-generated image has been one of diffusion models' most stubborn weaknesses, and the problem gets worse the moment you leave English. Chinese storefronts, Japanese menus, Korean signage, curved logos across a shop window: existing systems either spell things wrong or make the text look like a sticker pasted onto the photo. A team from bilibili and Peking University has now proposed a way to fix both problems at once, without the specialized machinery the field had converged on.

Their model, called TextFlux, is an OCR-free framework using a Diffusion Transformer (DiT, based on FLUX.1-Fill-dev) for high-fidelity multilingual scene text synthesis. It simplifies the learning task by providing direct visual glyph guidance through spatial concatenation of rendered glyphs with the scene image, enabling the model to focus on contextual reasoning and visual fusion. In plainer terms, instead of teaching the model how each character is shaped, they hand it a picture of the target text and ask it to blend that picture into the scene.

The two-headed problem in scene text synthesis

Scene text synthesis covers two related tasks: reconstructing text in a masked area and editing text already in an image. Both are hard for the same reason. A model has to get the glyph structure right (the strokes of a Chinese character, the curl of a lowercase g) and it has to make that text look like it actually belongs in the scene, matching lighting, perspective, curvature and material.

The dominant response has been to bolt on extra machinery. Methods like AnyText, GlyphControl, TextDiffuser and DreamText attach OCR encoders that extract features for font, glyph shape and color, then inject those features as conditions into a diffusion model. This works for spelling but produces the pasted-on look, and it comes with heavy costs: architectural complexity, custom loss functions, and the need for datasets like AnyWord-3M (three million images) or MARIO-10M just to cover multiple languages.

Diagram comparing traditional OCR-encoder pipelines with the TextFlux spatial concatenation approach

Skip the encoders, hand over a picture of the letters

TextFlux's core trick is almost embarrassingly simple. The target text is rendered as white characters on a black background at the same resolution as the scene image. That glyph image is then concatenated spatially (side by side or top to bottom) with the scene image, and the pair is fed into a FLUX.1-Fill-dev inpainting backbone along with a prompt that explicitly tells the model what the two panels are.

The prompt template does the semantic wiring. It describes IMAGE1 as a template rendering of the words and IMAGE2 as the scene where those same words should appear naturally integrated. During inference, the pipeline generates the glyph strip automatically from the user's text, runs the model, then crops the template panel off the output.

The bet behind this design is that a pretrained diffusion transformer already knows how to do inpainting with proper style, lighting and geometry. What it does not know is how to spell, especially in scripts with thousands of characters. Handing it a rendered glyph converts the hard part (learning to spell) into the easy part (learning to restyle a visual reference).

1% of the data, better numbers

The training footprint is where the paper gets provocative. TextFlux uses a training set of just 30,405 images: roughly 10,000 English, 15,000 Chinese, and about 1,000 each for Japanese, Korean, French, German and Italian. Full-parameter training runs on two 80GB A100s for about four days; a LoRA version trains on a single A100 with rank 128.

Despite that, results on the AnyWord test set and harder benchmarks like TotalText and ReCTS are strong. On multi-line reconstruction sequence accuracy, TextFlux hits 77.3% on English AnyWord and 61.4% on Chinese AnyWord, versus 23.7% and 28.1% for AnyText2. On the difficult ReCTS Chinese signboard set, it reaches 64.1% reconstruction accuracy against 25.2% for AnyText2. FID and LPIPS scores also drop substantially, and a user study rated the outputs 8.0 out of 10, roughly double the baselines.

Qualitative comparison of source images against AnyText, AnyText2 and TextFlux across English, Chinese, Japanese and Korean scenes

Zero-shot glyphs and low-resource languages

Because the model treats the glyph strip as a visual reference rather than a learned token, it generalizes to characters it never saw during training. The paper shows successful renders in Mongolian and Russian without any language-specific data, plus rare Chinese characters absent from the training set. Adding a new language reportedly needs fewer than 1,000 samples.

An ablation makes the case sharper. Without the concatenation trick and only LoRA fine-tuning, sequence accuracy on ReCTS collapses to 5.2%. With concatenation but no training, it climbs to 9.2%, enough to render simple Chinese but not against complex backgrounds. Concat plus LoRA jumps to 54.6%, and full-parameter fine-tuning reaches 64.1%. The visual reference does most of the work; training teaches integration.

The team also tested whether the text encoders still matter. Removing CLIP or T5 individually causes only marginal drops on non-Latin scripts, suggesting the visual channel now carries most of the character information the model needs.

Where it breaks

TextFlux inherits some limits from its design. Very small text loses fidelity because the glyph template downsamples through the VAE and comes out blurry. Tight bounding-box masks that clip characters produce visible artifacts, though looser user-drawn masks work better. And cursive writing systems like Arabic and Hindi remain difficult: isolated glyph templates do not match the connected forms these scripts actually use, so the model can reproduce direction and general shape but not clean joins.

Full training also is not cheap. Four days on two A100s is a fraction of what competing methods need, but it still requires a backbone with strong contextual reasoning; the authors note that weaker pretrained models will not carry the paradigm.

What is available

Both the full model and the LoRA variant are open. Weights are on Hugging Face, and code, training scripts and evaluation tooling live in the GitHub repo. There is also a beta optimized for single-line editing: TextFlux-beta and TextFlux-LoRA-beta, new versions of our model specifically optimized for single-line text editing. Significantly improves the quality of single-line text rendering. Increases inference speed for single-line text by approximately 1.4x. Dramatically enhances the accuracy of small text synthesis. The beta swaps the full-size mask for a single-line image strip as the glyph condition, cutting compute and giving a cleaner supervisory signal.

The practical implications land in poster generation, sign localization, product mockups, dubbing on-screen text for other markets, and any editing task where you need multilingual text to actually sit inside a photo. It is also a useful data point for a broader argument: for tasks like text rendering, spatial in-context references may be a cheaper and more general control mechanism than purpose-built condition encoders.