Skip to content

Repository files navigation

R-Bind: Unified Enhancement of Attribute and Relation Binding in Text-to-Image Diffusion Models

This is the implementation of paper: R-Bind: Unified Enhancement of Attribute and Relation Binding in Text-to-Image Diffusion Models (EMNLP 2025 Main)

Installation

pip install -r requirements.txt

Usage

We provide example input in example_sd15.json and example_sd3.json. The prompt can be modified, and the token id and token number should be updated accordingly. If you are not sure about token indices, use pipe.get_indices as shown in inference_sd3.py.

For the token id in extracted tokens, they correspond to

  • Entity-Relation-Entity Tokens, each represented by a list[list[int], list[int], list[int]]
  • Entity-Attribute Token, each represented by a list[list[int], list[int]]
  • Entity Token, each represented by a list[int]

Examples can be found in the corresponding json file.

After updating json file, run inference_sd15.sh or inference_sd3.sh to achieve the generated example. Please update the pretrained model path accordingly.

Not modifying anything in the examples would provided generation results similar to that in example_images/.

Citation

If you find our work interesting, please considering giving us a star and cite:

@inproceedings{zhang-wan-2025-r,
    title = "{R}-Bind: Unified Enhancement of Attribute and Relation Binding in Text-to-Image Diffusion Models",
    author = "Zhang, Huixuan  and
      Wan, Xiaojun",
    editor = "Christodoulopoulos, Christos  and
      Chakraborty, Tanmoy  and
      Rose, Carolyn  and
      Peng, Violet",
    booktitle = "Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing",
    month = nov,
    year = "2025",
    address = "Suzhou, China",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2025.emnlp-main.349/",
    doi = "10.18653/v1/2025.emnlp-main.349",
    pages = "6867--6881",
    ISBN = "979-8-89176-332-6",
    abstract = "Text-to-image models frequently fail to achieve perfect alignment with textual prompts, particularly in maintaining proper semantic binding between semantic elements in the given prompt. Existing approaches typically require costly retraining or focus on only correctly generating the attributes of entities (entity-attribute binding), ignoring the cruciality of correctly generating the relations between entities (entity-relation-entity binding), resulting in unsatisfactory semantic binding performance. In this work, we propose a novel training-free method R-Bind that simultaneously improves both entity-attribute and entity-relation-entity binding. Our method introduces three inference-time optimization losses that adjust attention maps during generation. Comprehensive evaluations across multiple datasets demonstrate our approach{'}s effectiveness, validity, and flexibility in enhancing semantic binding without additional training."
}

Acknowledgement

We thank Diffusers, Attend-and-Excite, SynGen for their extraordinary idea and code implementation.

About

The official implementation repository for our EMNLP 2025 paper, R-Bind: Unified Enhancement of Attribute and Relation Binding in Text-to-Image Diffusion Models.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages