SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper · ICCV · 2025

CoMPaSS: Enhancing Spatial Understanding in Text-to-Image Diffusion Models

Qingnan Fan, Qi Zhang, Hong Gu, Huaqi Zhang, Xinguo Liu, Gaoyang Zhang, Bingtao Fu, Runxing Liu

Code that ran

8 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 6 failures of our instrument; 1 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper.json · badge: /api/ran/Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
blurgyy/CoMPaSS canonical (classifier label)
classifier basis: census
8 ran · 1 no recorded run
FunctionStatusWhere it lives
coco_bbox_to_regular_bbox Ran
ran, violated the contract we drafted
blurgyy/CoMPaSS/SCOP/process_masks/__main__.py
code served (permissive licence) · get_code("da73b882efa99054")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# BoundingBox is a tuple of 4 floats: (x1, y1, w, h)
# coco_bbox_to_regular_bbox converts from COCO format to regular format
# It takes a bbox tuple and returns a bbox tuple

ARGS = {
    "bbox": (10.0, 20.0, 50.0, 30.0)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
collate_fn Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/SCOP/process_masks/__main__.py
code served (permissive licence) · get_code("60b9c80c20134c94")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import functools

torch.manual_seed(0)

# The function takes a list of list of dicts and flattens it using reduce
# Each inner list should contain dicts that can be concatenated with +
# For dicts, + operation doesn't work directly, so we need to use lists of dicts
# that can be concatenated with +

# Create sample instances: list of list of dicts
instances = [
    [{"key1": "value1"}, {"key2": "value2"}],
    [{"key3": "value3"}],
    [{"key4": "value4"}, {"key5": "value5"}, {"key6": "value6"}]
]

ARGS = {
    "instances": instances
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
deserialize_jsonl Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/SCOP/process_masks/__main__.py
code served (permissive licence) · get_code("90277c4fc252b1a2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from concurrent.futures import ThreadPoolExecutor

# Construct valid arguments for deserialize_jsonl
s = '{"key1": "value1"}\n{"key2": "value2"}\n{"key3": "value3"}'
exe = ThreadPoolExecutor(max_workers=2)

ARGS = {
    "s": s,
    "exe": exe,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
deserialize_jsonl Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/TENOR/sd/src/scop.py
code served (permissive licence) · get_code("044349e3dd13dfa6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from concurrent.futures import ThreadPoolExecutor

# Create a sample JSONL string with multiple JSON objects separated by newlines
s = '{"key1": "value1", "num": 42}\n{"key2": "value2", "num": 100}\n{"key3": "value3", "num": 200}'

# Create a ThreadPoolExecutor instance
exe = ThreadPoolExecutor(max_workers=2)

ARGS = {
    "s": s,
    "exe": exe
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_cross_attn_map_from_unet Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/TENOR/sd/src/attn_utils.py
code served (permissive licence) · get_code("3d0e4645fc144bfc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import abc

torch.manual_seed(0)

LOW_RESOURCE = False

class AttentionControl(abc.ABC):

    def step_callback(self, x_t):
        return x_t

    def between_steps(self):
        return

    @property
    def num_uncond_att_layers(self):
        return self.num_att_layers if LOW_RESOURCE else 0

    @abc.abstractmethod
    def forward(self, attn, is_cross: bool, place_in_unet: str):
        raise NotImplementedError

    def __call__(self, attn, is_cross: bool, place_in_unet: str):
        attn = self.forward(attn, is_cross, place_in_unet)
        self.cur_att_layer += 1
        if self.cur_att_layer == self.num_att_layers + self.num_uncond_att_layers:
            self.cur_att_layer = 0
            self.cur_step += 1
            self.between_steps()
        return attn

    def reset(self):
        self.cur_step = 0
        self.cur_att_layer = 0

    def __init__(self):
        self.cur_step = 0
        self.num_att_layers = -1
        self.cur_att_layer = 0

class AttentionStore(AttentionControl):

    @staticmethod
    def get_empty_store():
        return {'down_cross': [], 'mid_cross': [], 'up_cross': [], 'down_self': [], 'mid_self': [], 'up_self': []}

    def forward(self, attn, is_cross: bool, place_in_unet: str):
        key = f"{place_in_unet}_{('cross' if is_cross else 'self')}"
        self.step_store[key].append(attn.clone())
        return attn

    def between_steps(self):
        assert len(self.attention_store) == 0
        self.attention_store = self.step_store
        self.step_store = self.get_empty_store()

    def get_average_attention(self):
        average_attention = {key: [item / self.cur_step for item in self.attention_store[key]] for key in self.attention_store}
        return average_attention

    def reset(self):
        super(AttentionStore, self).reset()
        self.step_store = self.get_empty_store()
        self.attention_store = {}

    def __init__(self):
        super(AttentionStore, self).__init__()
        self.step_store = self.get_empty_store()
        self.attention_store = {}

# Create an AttentionStore instance with sample attention data
attention_store = AttentionStore()
attention_store.num_att_layers = 12
attention_store.cur_step = 2

# Populate attention_store with sample attention tensors
# For resolution 512, reses will be [64, 32, 16, 8]
# We need tensors with shape (batch, seq_len, hidden_dim) where seq_len = res^2

# Simulate cross attention tensors for different positions and resolutions
attention_store.attention_store = {
    'down_cross': [
        torch.randn(2, 4096, 8),  # 64x64 = 4096
        torch.randn(2, 1024, 8),  # 32x32 = 1024
    ],
    'mid_cross': [
        torch.randn(2, 256, 8),   # 16x16 = 256
    ],
    'up_cross': [
        torch.randn(2, 64, 8),    # 8x8 = 64
        torch.randn(2, 4096, 8),  # 64x64 = 4096
    ],
    'down_self': [],
    'mid_self': [],
    'up_self': [],
}
attention_store.cur_step = 2

ARGS = {
    'attention_store': attention_store,
    'training_resolution': 512,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_word_idx Ran
ran, honoured the contract we drafted
blurgyy/CoMPaSS/TENOR/sd/src/loss_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from caraj7/comat, is pointer only (licence: NONE) · get_code("b2840876374a5c28")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from caraj7/comat, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_coco_instance_annotations Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/SCOP/data_processing.py
code served (permissive licence) · get_code("58ce950999bdbe8a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from pathlib import Path
from tempfile import TemporaryDirectory
import torch

# Create a temporary directory structure with a valid COCO annotations file
temp_dir = TemporaryDirectory()
coco_root = Path(temp_dir.name)
annotations_dir = coco_root / 'annotations'
annotations_dir.mkdir(parents=True, exist_ok=True)

# Create a minimal valid COCO instances annotation file
coco_data = {
    "info": {
        "description": "COCO 2017 Dataset",
        "version": "1.0",
        "year": 2017,
        "contributor": "COCO Consortium",
        "date_created": "2017-01-01"
    },
    "licenses": [
        {
            "id": 1,
            "name": "Attribution-NonCommercial-ShareAlike License",
            "url": "http://creativecommons.org/licenses/by-nc-sa/2.0/"
        }
    ],
    "images": [
        {
            "id": 1,
            "width": 640,
            "height": 480,
            "file_name": "image1.jpg",
            "license": 1,
            "flickr_url": "",
            "coco_url": "",
            "date_captured": "2017-01-01 00:00:00"
        }
    ],
    "annotations": [
        {
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "bbox": [10, 10, 100, 100],
            "area": 10000,
            "iscrowd": 0
        }
    ],
    "categories": [
        {
            "id": 1,
            "name": "person",
            "supercategory": "person"
        }
    ]
}

instances_path = annotations_dir / 'instances_train2017.json'
instances_path.write_text(json.dumps(coco_data))

ARGS = {
    'coco_root': coco_root
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
serialize_jsonl Ran
ran; our contract draft was wrong, not the code
blurgyy/CoMPaSS/SCOP/models.py
code served (permissive licence) · get_code("5b10068ee2f4a6c8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from typing import Any

torch_seed = 0

ARGS = {
    "data_list": [
        {
            "id": 1,
            "name": "sample_one",
            "value": 42,
            "nested": {"key": "value"}
        },
        {
            "id": 2,
            "name": "sample_two",
            "value": 3.14,
            "items": [1, 2, 3]
        },
        {
            "id": 3,
            "empty_field": None,
            "flag": True
        }
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_grounding_loss_by_layer Not yet run
unverified (harvested, no recorded run)
blurgyy/CoMPaSS/TENOR/sd/src/loss_utils.py
code served (permissive licence) · get_code("5bb97b933b5fd6d8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
get_word_idx 1 other paper
1 dated earlier
2404.03653 (2024-04)
CoMat: Aligning Text-to-Image Diffusion Model with Image-to-Text Concept Matching

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Text-to-image (T2I) diffusion models excel at generating photorealistic images but often fail to render accurate spatial relationships. We identify two core issues underlying this common failure: 1) the ambiguous nature of data concerning spatial relationships in existing datasets, and 2) the inability of current text encoders to accurately interpret the spatial semantics of input descriptions. We propose CoMPaSS, a versatile framework that enhances spatial understanding in T2I models. It first addresses data ambiguity with the Spatial Constraints-Oriented Pairing (SCOP) data engine, which curates spatially-accurate training data via principled constraints. To leverage these priors, CoMPaSS also introduces the Token ENcoding ORdering (TENOR) module, which preserves crucial token ordering information lost by text encoders, thereby reinforcing the prompt's linguistic structure. Extensive experiments on four popular T2I models (UNet and MMDiT-based) show CoMPaSS sets a new state of the art on key spatial benchmarks, with substantial relative gains on VISOR (+98%), T2I-CompBench Spatial (+67%), and GenEval Position (+131%). Code is available at github.com/blurgyy/CoMPaSS.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper")
get_code_for_paper("Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper")
have("Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper.svg)](https://syntology.ai/paper/Zhang_CoMPaSS_Enhancing_Spatial_Understanding_in_Text-to-Image_Diffusion_Models_ICCV_2025_paper)

Connect an agent — have() is free.