SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.13921 · 2023

Compositional Text-to-Image Synthesis with Attention Map Control of Diffusion Models

arXiv · PDF · Open in the Atlas

Code that ran

10 of 14 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 6 have no contract verdict; 2 failures of our instrument; 4 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2305.13921.json · badge: /api/ran/2305.13921.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
OPPO-Mente-Lab/attention-mask-control canonical (classifier label)
classifier basis: census
10 ran · 4 no recorded run
FunctionStatusWhere it lives
custom_decoder Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/custom_dataset.py
code served (permissive licence) · get_code("2948eb1d2e3a4170")
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 Image. 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 io
import PIL.Image
import numpy as np

# Create a small PNG image (grayscale)
png_img = PIL.Image.new('L', (4, 3), color=128)
png_bytes = io.BytesIO()
png_img.save(png_bytes, format='PNG')
png_data = png_bytes.getvalue()

# Create a small JPG image (RGB)
jpg_img = PIL.Image.new('RGB', (4, 3), color=(255, 0, 0))
jpg_bytes = io.BytesIO()
jpg_img.save(jpg_bytes, format='JPEG')
jpg_data = jpg_bytes.getvalue()

# Test with PNG key
png_key = "image.png"

# Test with JPG key
jpg_key = "image.jpg"

ARGS = {
    "key": png_key,
    "data": png_data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 2 and dtype family int 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
dice_loss Ran
ran, violated the contract we drafted
OPPO-Mente-Lab/attention-mask-control/boxnet_models/segmentation.py
code served (permissive licence) · get_code("ac8fe530cdad4d8c")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 torch.nn as nn

torch.manual_seed(0)

# Create sample inputs and targets tensors
# The function expects tensors that can be flattened and have sigmoid applied
# Shape: batch_size=2, spatial_dims flattened to create predictions
batch_size = 2
num_spatial = 4

# inputs: predictions before sigmoid, shape (batch_size, num_spatial)
inputs = torch.randn(batch_size, num_spatial)

# targets: binary labels matching inputs shape, values 0 or 1
targets = torch.randint(0, 2, (batch_size, num_spatial), dtype=torch.float32)

# num_boxes: number of boxes for normalization
num_boxes = 2

ARGS = {
    "inputs": inputs,
    "targets": targets,
    "num_boxes": num_boxes,
}
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 Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
expand_text Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/custom_dataset.py
code served (permissive licence) · get_code("156b5fef80b6fc81")
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 random

prompt_list = ['{}']

def expand_text(text):
    pat = random.choice(prompt_list)
    return pat.format(text)

# Setup code
text_input = "hello world"

ARGS = {
    "text": text_input
}
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
load_bbox Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/coco_preprocess.py
code served (permissive licence) · get_code("4ceef3594b69a5ef")
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 numpy as np
from unittest.mock import MagicMock

torch.manual_seed(0)

# Create a mock COCO object
coco = MagicMock()

# Mock the getAnnIds method to return some annotation IDs
coco.getAnnIds.return_value = [1, 2]

# Mock the loadAnns method to return annotation dictionaries
anns = [
    {
        'category_id': 10,
        'iscrowd': 0,
        'bbox': [10.0, 20.0, 30.0, 40.0]
    },
    {
        'category_id': 11,
        'iscrowd': 1,
        'bbox': [50.0, 60.0, 70.0, 80.0]
    }
]
coco.loadAnns.return_value = anns

# Mock the loadCats method to return category dictionaries
def mock_loadCats(cat_ids):
    cat_map = {
        10: {'name': 'dog', 'id': 10},
        11: {'name': 'cat', 'id': 11}
    }
    return [cat_map[cat_id] for cat_id in cat_ids]

coco.loadCats.side_effect = mock_loadCats

# Create names list with the category names
names = ['dog', 'cat']

# Set up parameters
imgId = 42
filename = 'test_image.jpg'

ARGS = {
    'coco': coco,
    'imgId': imgId,
    'names': names,
    'filename': filename
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
load_captions Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/coco_preprocess.py
code served (permissive licence) · get_code("75fc999b2834b581")
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 numpy as np

class MockCOCO:
    """Stand-in COCO object that provides getAnnIds and loadAnns methods."""
    
    def __init__(self):
        self.annotations = {
            101: {'id': 1, 'image_id': 101, 'caption': 'A cat on a mat'},
            101: {'id': 2, 'image_id': 101, 'caption': 'The cat is sleeping'},
            102: {'id': 3, 'image_id': 102, 'caption': 'A dog running'},
        }
        # Store as list with proper structure
        self.anns_list = [
            {'id': 1, 'image_id': 101, 'caption': 'A cat on a mat'},
            {'id': 2, 'image_id': 101, 'caption': 'The cat is sleeping'},
            {'id': 3, 'image_id': 102, 'caption': 'A dog running'},
        ]
    
    def getAnnIds(self, imgIds):
        """Return annotation ids for given image ids."""
        if isinstance(imgIds, (list, tuple)):
            imgIds = imgIds
        else:
            imgIds = [imgIds]
        
        result = []
        for ann in self.anns_list:
            if ann['image_id'] in imgIds:
                result.append(ann['id'])
        return result
    
    def loadAnns(self, annIds):
        """Load annotations by their ids."""
        result = []
        for ann_id in annIds:
            for ann in self.anns_list:
                if ann['id'] == ann_id:
                    result.append(ann)
                    break
        return result

coco = MockCOCO()
imgId = 101

ARGS = {
    'coco': coco,
    'imgId': imgId,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
save_input_hook Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/train_boxnet.py
code served (permissive licence) · get_code("ae52c3450f164ea5")
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 Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal nn.Module to use as 'self'
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create module instance
module = SimpleModule()

# Create input and output tensors
# inp should be a tuple (as it comes from hook)
inp_tensor = torch.randn(2, 4)
inp = (inp_tensor,)

# Create output tensor
out = torch.randn(2, 3)

ARGS = {
    "self": module,
    "inp": inp,
    "out": out
}
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 Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
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
save_out_hook Ran
ran; our contract draft was wrong, not the code
OPPO-Mente-Lab/attention-mask-control/train_boxnet.py
code served (permissive licence) · get_code("bd578666f3556b90")
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 Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal module
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create module instance
module = SimpleModule()

# Create small tensors for input and output
inp = (torch.randn(2, 4),)  # Small batch, small dim
out = torch.randn(2, 3)  # Output tensor

# Define arguments for save_out_hook
ARGS = {
    'self': module,
    'inp': inp,
    'out': out
}
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 Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
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
sigmoid_focal_loss Ran
ran; our contract draft was wrong, not the code
OPPO-Mente-Lab/attention-mask-control/boxnet_models/segmentation.py
code served (permissive licence) · get_code("5c0711aada67957e")
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) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for inputs and targets
# inputs: predictions (logits) - shape (2, 4) for batch_size=2, num_predictions=4
inputs = torch.randn(2, 4, requires_grad=True)

# targets: binary labels - shape (2, 4) matching inputs
targets = torch.randint(0, 2, (2, 4), dtype=torch.float32)

# num_boxes: number of boxes for normalization
num_boxes = 2

# alpha and gamma are already float parameters with defaults
alpha = 0.25
gamma = 2.0

ARGS = {
    "inputs": inputs,
    "targets": targets,
    "num_boxes": num_boxes,
    "alpha": alpha,
    "gamma": gamma,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
tokenize Ran
ran, honoured the contract we drafted
OPPO-Mente-Lab/attention-mask-control/train_boxnet.py
pointer only (licence: MIT); the stored copy get_code serves, from siqi0905/gardiff, is pointer only (licence: NONE) · get_code("534b549a2186b672")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from siqi0905/gardiff, 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.

view_images Ran
ran on a synthesized input
OPPO-Mente-Lab/attention-mask-control/p2p.py
code served (permissive licence) · get_code("9911847e9b3e81ac")
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 Image. 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 os
import numpy as np
from PIL import Image
import tempfile

# Create a temporary directory for saving images
temp_dir = tempfile.mkdtemp()

# Create sample image data as numpy arrays
# Images should be (height, width, channels) with values in appropriate range
image1 = np.random.randint(0, 256, (32, 48, 3), dtype=np.uint8)
image2 = np.random.randint(0, 256, (32, 48, 3), dtype=np.uint8)
image3 = np.random.randint(0, 256, (32, 48, 3), dtype=np.uint8)
image4 = np.random.randint(0, 256, (32, 48, 3), dtype=np.uint8)

# Create a list of images
images_list = [image1, image2, image3, image4]

ARGS = {
    'images': images_list,
    'num_rows': 2,
    'offset_ratio': 0.02,
    'save_img': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
build_transformer Not yet run
unverified (harvested, no recorded run)
OPPO-Mente-Lab/attention-mask-control/boxnet_models/transformer.py
code served (permissive licence) · get_code("9083e7dd88fe1570")
How it ran

no invocation recorded.

cv2ImgAddText Not yet run
unverified (harvested, no recorded run)
OPPO-Mente-Lab/attention-mask-control/p2p.py
code served (permissive licence) · get_code("8569a155ef139702")
How it ran

no invocation recorded.

get_consume_samples Not yet run
unverified (harvested, no recorded run)
OPPO-Mente-Lab/attention-mask-control/universal_datamodule.py
code served (permissive licence) · get_code("ff6b336fe24b3a0e")
How it ran

no invocation recorded.

text_under_image Not yet run
unverified (harvested, no recorded run)
OPPO-Mente-Lab/attention-mask-control/p2p.py
code served (permissive licence) · get_code("75f3f5c72eded945")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 5 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 4 later) and 9 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
sigmoid_focal_loss 56 other papers
27 dated earlier, 26 later, 3 same year, order not determinable · 1 only as an assembly brick
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.11731 (2021-03)
Meta-DETR: Image-Level Few-Shot Object Detection with Inter-Class Correlation Exploitation
and 53 more not named here
dice_loss 40 other papers
22 dated earlier, 16 later, 2 same year, order not determinable · 1 only as an assembly brick
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2010.04159 (2020-10)
Deformable DETR: Deformable Transformers for End-to-End Object Detection
2103.12115 (2021-03)
End-to-End Trainable Multi-Instance Pose Estimation with Transformers
and 37 more not named here
build_transformer 32 other papers
16 dated earlier, 16 later
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2103.12115 (2021-03)
End-to-End Trainable Multi-Instance Pose Estimation with Transformers
2104.04369 (2021-04)
Video-aided Unsupervised Grammar Induction
and 29 more not named here
save_out_hook 1 other paper
1 dated earlier
2303.17870 (2023-03)
GlyphDraw: Seamlessly Rendering Text with Intricate Spatial Structures in Text-to-Image Generation
tokenize 1 other paper
1 later
2409.08258 (2024-09)
Improving Virtual Try-On with Garment-focused Diffusion Models

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-24.

Repositories linked to this paper

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

Abstract

Recent text-to-image (T2I) diffusion models show outstanding performance in generating high-quality images conditioned on textual prompts. However, they fail to semantically align the generated images with the prompts due to their limited compositional capabilities, leading to attribute leakage, entity leakage, and missing entities. In this paper, we propose a novel attention mask control strategy based on predicted object boxes to address these issues. In particular, we first train a BoxNet to predict a box for each entity that possesses the attribute specified in the prompt. Then, depending on the predicted boxes, a unique mask control is applied to the cross- and self-attention maps. Our approach produces a more semantically accurate synthesis by constraining the attention regions of each token in the prompt to the image. In addition, the proposed method is straightforward and effective and can be readily integrated into existing cross-attention-based T2I generators. We compare our approach to competing methods and demonstrate that it can faithfully convey the semantics of the original text to the generated content and achieve high availability as a ready-to-use plugin. Please refer to https://github.com/OPPOMente-Lab/attention-mask-control.

For agents

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

get_harvested_code_for_paper("2305.13921")
get_code_for_paper("2305.13921")
have("2305.13921")

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

curl https://syntology.ai/api/ran/2305.13921.json

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

[![Syntology run record](https://syntology.ai/api/ran/2305.13921.svg)](https://syntology.ai/paper/2305.13921)

Connect an agent — have() is free.