# Token Merging for Training-Free Semantic Binding in Text-to-Image Synthesis

## Setup

create a conda environment:

```
conda env create -f environment.yaml
conda activate tome
```

or:

```
pip install -r requirements.txt
```

Finally, run:

```
python -m spacy download en_core_web_trf
```

## Inference

set `nlp_path` in config file to use SpaCy.  

More details are showed in config file and we provide a demo config file `demo.py`.

generate imgs by use the following command:

```
python run_tome.py
```

## Demo

prompt `a cat wearing sunglasses and a dog wearing hat`
Left one is generated by sdxl, right one is generated by our method. The details are shown in `demo.py`

<img src="pics/demo_standard.png" width="600" height="600" style="zoom:50%;" > <img src="pics/demo_tome.png" width="600" height="600" style="zoom:50%;" >
