UniVL: Unified Vision-Language Embedding for Spatially Grounded Contextual Image Generation

Jiayun Wang, Yu Wang, Weijie Gan, Zhenting Wang, Wei Wei

TL;DR

What if, instead of feeding an image generator a spatial mask and a separate text prompt, you just typed the word "flower" directly onto the image where you want the flower to go? UniVL does exactly this—using an OCR-pretrained vision model to read pixel-rendered text labels inside masked regions, completely eliminating the massive, compute-heavy text encoder usually required for diffusion models. The result is an image generator that handles multi-region edits in a single pass, runs up to 44% faster, and actually produces higher-quality images than standard text-prompted baselines.

What Problem Does This Paper Address?

If you want a modern diffusion model to edit a specific part of an image, you are immediately faced with a translation problem between two separate worlds: what you want (semantics) and where you want it (geometry).

Standard controllable generation pipelines handle this by splitting the labor. A vision encoder processes a spatial mask or depth map (the where), while a massive standalone language encoder—like the 4.7B-parameter T5 in FLUX—processes a global text prompt (the what). Because text prompts lack explicit spatial coordinates and masks lack semantic meaning, stitching them together gets messy—especially if you want to put three different objects in three different spots at once. Worse, running a giant language encoder and appending hundreds of text tokens to the diffusion sequence eats up huge amounts of memory and compute.

Figure 1: Conditioning paradigm for contextual image generation: existing (left) vs. our UNIVL (right). The user’s intent is the same: inpaint a target region with a desired object. Existing methods take two inputs from two domains, a masked image (vision) and a global text prompt (language), each processed by its own encoder before the diffusion model and decoder. In UNIVL, the same intent is captured by a single unified visual condition: our pipeline renders the text label as pixels inside the mask, and the UNIVL encoder (an OCR-pretrained vision backbone adapted to our task) reads the spatial layout and the label in one pass. No text encoder is used, and the generated image contains the requested object (“flower”) at the specified location.

The authors ask a wonderfully literal question: Since text rendered as pixels at a specific location naturally carries both its meaning and its coordinates, can an optical character recognition (OCR) vision encoder act as our sole conditioning interface?

Methods

To make this work, the authors introduce UniVL, built atop a pretrained Diffusion Transformer (FLUX.1-dev with an inpainting LoRA). Instead of taking text tokens, the pipeline blackens out user-defined mask regions and renders short text labels (white Courier font) directly inside them.

The novel UniVL Encoder reads this single image by combining two streams via a mask-aware fusion operator:

  1. Outside the masks: A frozen FLUX VAE encoder extracts low-level visual features to preserve the unedited background.
  2. Inside the masks: An OCR-pretrained CLIP backbone (adapted from DeepSeek-OCR using parameter-efficient LoRA) reads the pixel-rendered text, passing its semantic features through a linear adapter to match the VAE's latent dimensions.

Because a diffusion model isn't naturally inclined to turn pictures of text into realistic objects (as opposed to just generating literal street signs), the authors use a two-stage training recipe:

  • Stage 1 (Feature Alignment): Before touching the diffusion model, the UniVL encoder is trained so its output embeddings match the actual VAE latent representation of the ground-truth target image. It learns to map the word "flower" in pixels into the visual latent space of an actual flower.
  • Stage 2 (Diffusion Fine-Tuning): The aligned UniVL embeddings are fed directly into the Diffusion Transformer alongside noisy latents—with no text encoder in sight. Along with standard flow-matching and alignment losses, the authors add auxiliary CLIP image and text losses on decoded region crops to ensure the generated pixels semantically match the requested label.

Datasets

To train and test this new paradigm, the authors built UniVL-ImgGen, a benchmark of ~477K unique images and 710K mask-text records spanning 28K object phrases. It blends two data types:

  • Multi-region detection data: Derived from LAION-5B using Grounding DINO and CLIP filtering, providing scenes packed with multiple labeled bounding boxes.
  • Image-editing data: Sourced from ImgEdit (add, replace, and extract tasks), ensuring the model actively relies on the rendered text rather than lazily guessing objects from surrounding context.

They also evaluate zero-shot generalization on COCO val2017 and ADE20K.

Key Insights and Ideas

  • Optical compression works in reverse: Recent vision-language models (like DeepSeek-OCR) showed that rendering text into pixels is a remarkably efficient way to compress language for visual understanding. UniVL proves the exact inverse works for visual synthesis: an OCR encoder can unpack pixel-text into rich generative instructions.
  • Compute savings live in the sequence length, not just the encoder: Dropping the T5 encoder slashes encoder parameters by ~92% (4.92B down to 401.6M). However, the biggest runtime speedup actually comes from removing 511 text tokens from the Diffusion Transformer's attention sequence at every denoising step.
  • Alignment before diffusion is crucial: Skipping Stage 1 and training end-to-end degrades image quality noticeably (FID worsens from 11.13 to 13.05). Giving the OCR encoder a head start to "speak VAE" stabilizes generation.
  • Effortless multi-region composability: Because labels live inside their respective masks, editing five distinct regions with different objects requires just one forward pass, avoiding the "concept bleeding" common in global text prompts.

Key Results

Evaluated on UniVL-ImgGen against fine-tuned baselines (like OminiControl, ControlNet-FLUX, and FLUX.1 Fill):

  • Superior Image Quality: Without using any text encoder, UniVL beats text-prompted OminiControl on full-image FID (11.13 vs. 13.50), PSNR (19.61 vs. 16.13), and in-mask PSNR (18.6 vs. 17.6). It even outperforms FLUX.1 Fill (12.67 FID).
  • Substantial Speedups: Compared to OminiControl with T5, UniVL reduces inference TFLOPs by up to 51.8% and wall-clock runtime by 44.2% at $256\times256$ resolution (and 20.6% faster at $512\times512$). Note that savings shrink to 8.0% at $1024\times1024$, where image tokens vastly outnumber the removed text tokens.
  • Backbone & Zero-Shot Generalization: Zero-shot on COCO, UniVL achieves the best FID (16.99), SSIM, and PSNR among unprompted methods. Applying the exact same recipe to a different backbone (SD3.5-Medium) yields a strong 11.93 FID.

Limitations and Future Work

UniVL's elegance comes with physical and linguistic boundaries, which the authors test thoroughly:

  • Short, object-level labels only: UniVL thrives on 1–3 word nouns and simple attributes (e.g., "red sports car"), which make up 96% of its training data. It fails on styles ("watercolor style dog"), negations ("dog not black"), and relational clauses ("dog under table"). If you need complex prose, the authors show you can pair UniVL with T5 as a hybrid, though you forfeit the speedups.
  • The "squint test" for mask sizes: Because text is rendered as pixels, masks covering less than 0.5% of the image (under $36\times36$ pixels at $512^2$) leave the text illegible, causing generation to fail. Very large masks ($\ge30\%$ area) also see a dip in quality.
  • Geometry and pseudo-labels: The model was trained on standardized Courier text inside non-overlapping rectangles; heavy mask overlap creates visual ambiguity, and automated dataset construction left ~20% of training labels with imperfect semantic matches according to human auditors. Future extensions were not explicitly outlined beyond hybrid text-conditioning.

Summary updated

Abstract

We introduce spatially grounded contextual image generation, a new controllable image generation task that reframes the conditioning paradigm. Instead of supplying a reference image and a global text prompt through two separate encoders (vision and language), UniVL is trained to bind semantics to spatial locations directly from a single unified visual input, in which the textual instruction is rendered onto the spatial mask, removing the need for a standalone text encoder at inference. This enables contextual image generation, which follows user’s specified what should appear where instructions, as well as waiving the need of text encoder to save computation significantly. For the task, we propose a framework in which the UniVL encoder—adapted from an optical-character-recognition-pretrained backbone—reads the unified condition optically, producing a UniVL embedding fVIL that fuses visual and semantic intents to spatial locations, packed as a single token sequence. A two-stage pipeline aligns UniVL in VAE embedding space and then conditions a pretrained diffusion backbone entirely on UniVL embeddings, eliminating the standalone text encoder (e.g., T5). The reframing is deliberately minimalist for text, but the empirical payoff is large. On UniVL-ImgGen, a benchmark of 477K mask-annotated images that we construct to support training and evaluation, UniVL achieves superior image quality over text-prompted baselines (FID: 14 → 11, PSNR: 16 → 20) while eliminating the text encoder entirely, reducing inference TFLOPs by up to 52% and runtime by up to 44%. Additional ablation studies verify components of different parts of the proposed method, paving way for efficient and spatially grounded image generation with unified conditioning paradigm. Our code is available at https://github.com/Accenture/UniVL.
BibTeX
@inproceedings{wang2026univl,
  author = {Jiayun Wang and Yu Wang and Weijie Gan and Zhenting Wang and Wei Wei},
  title = {{UniVL: Unified Vision-Language Embedding for Spatially Grounded Contextual Image Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=EPyIDzDBau},
}
Figure