TL;DR
While modern text-to-image models generate stunning imagery, they are notoriously blind to precise numerical color specifications like hex codes or RGB values. NumColor solves this by introducing a tokenizer-agnostic character-level aggregator paired with a perceptually grounded color codebook. This plug-and-play framework improves numerical color accuracy by 4–9× and transfers zero-shot across multiple state-of-the-art diffusion models without changing their weights.
What Problem Does This Paper Address?
If you ask a model like FLUX or Stable Diffusion 3 to generate a car in #3979CC (a specific shade of blue), you will likely get a car of an arbitrary color or a chaotic rainbow artifact.
This failure stems from two compounding issues:
- Tokenizer Fragmentation: Standard text encoders (like CLIP or T5) use subword tokenization. They fragment a hex code like
#FF5733into meaningless sub-tokens (#,FF,57,33). This breaks cross-attention, preventing the model from binding the color to the target object. - Data Scarcity: Massive text-image datasets predominantly describe colors using natural language ("red", "navy blue") rather than explicit numerical codes, leaving models with no understanding of numerical color spaces.
Methods
The authors introduce NumColor, a two-stage framework designed to restore numerical color understanding:
- Color Token Aggregator (CTA): A lightweight, character-level sequence labeler (CNN + Transformer + CRF) that scans the input text. It identifies numerical color spans regardless of how the underlying text encoder tokenizes them, unifying the fragments into a single coherent token.
- The ColorBook: Instead of learning an embedding for all 16.7 million RGB values, the authors uniformly sample the perceptually uniform CIE Lab color space to create a compact codebook of 6,707 anchor colors. Continuous colors are handled via soft nearest-neighbor interpolation over the 8 closest anchors.
- Pre-Contextualization Injection: Crucially, the interpolated color embedding is injected into the T5 text encoder before the self-attention layers. This allows bidirectional attention between the color token and the object token (e.g.,
#FF5733$\leftrightarrow$car), ensuring proper color-object binding. - Geometric Regularization: To keep the embedding space aligned with human color perception, the authors introduce two auxiliary losses during training: directional alignment and interpolation consistency. These losses force the embedding space to mirror the geometric distances of the CIE Lab space.
Datasets
To train the ColorBook without the lighting and material ambiguities found in real-world photography, the authors curated a new synthetic dataset:
- NumColor-Data: A large-scale dataset containing 500,000 rendered images. The authors took 100 3D meshes from Objaverse-XL and composited them into 34 indoor/outdoor scenes in Blender. Each object was assigned a uniform Lambertian material with its albedo set exactly to a target Lab color under controlled D65 illumination. This creates an unambiguous, pixel-perfect color-to-text correspondence.
For evaluation, the authors utilized GenColorBench, testing the model on 9.8K numerical color prompts across various granularities.
Key Insights and Ideas
- Character-Level Processing Bypasses Tokenization Flaws: Operating directly on raw characters allows the framework to remain completely agnostic to the specific subword tokenization scheme used by different models (CLIP, T5, GPT-2).
- The Power of Pre-Contextualization: Injecting learned embeddings after text encoding is architecturally broken for color binding because the object has already been contextualized with fragmented noise. Injecting before the transformer layers allows the color and object to naturally bind through self-attention.
- Universal Zero-Shot Transfer: Because the ColorBook modifies the T5 text embedding space—which is shared across many modern diffusion pipelines—NumColor can be trained exclusively on FLUX and deployed zero-shot to SD3, SD3.5, PixArt-α, and PixArt-Σ without any model-specific adaptation.
Key Results
- Massive Accuracy Gains: NumColor improves numerical color accuracy by 4–9× across five distinct diffusion models on GenColorBench. For instance, on FLUX, color accuracy at the ISCC-L1 granularity surged from a baseline of 13.82% to 55.71%.
- Aesthetic Coherence: By eliminating chaotic color interpretations, NumColor improved color harmony scores by 10–30×, drastically reducing rainbow artifacts and color bleeding.
- Robust Cross-Model Generalization: When transferred zero-shot to other architectures, NumColor delivered average accuracy improvements of +37.4% on SD3, +36.8% on SD3.5, and +37.3% on PixArt-Σ.
Limitations and Future Work
Despite its precision, NumColor inherits two core limitations from its underlying diffusion backbones:
- Color Leakage: Because cross-attention lacks explicit spatial grounding, specified colors occasionally bleed from the target object into the background or surrounding elements.
- Memory Color Bias: Pretrained models possess strong semantic priors (e.g., "bananas are yellow"). If you ask NumColor to generate a green or blue banana using hex codes, the model's internal object-color priors sometimes override the color embedding, resisting the recoloring effect.
Future work will likely target these spatial and semantic binding conflicts to achieve even stricter color fidelity.
Summary updated