SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.12920 · 2024

Zero-Shot Medical Phrase Grounding with Off-the-shelf Diffusion Models

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 3 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 3 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2404.12920.json · badge: /api/ran/2404.12920.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
vios-s/ldm-phrase-grounding canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
get_bb_from_largest_component Ran
ran, honoured the contract we drafted
vios-s/ldm-phrase-grounding/metrics/utils.py
code served (permissive licence) · get_code("10140d764aa99bb7")
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 int; 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 numpy as np
from scipy import ndimage

# Create a simple binary image with a labeled component
# The function expects a labeled array where find_objects can identify regions
binary_image = np.zeros((10, 10), dtype=int)
# Create a rectangular region filled with label 1
binary_image[2:7, 3:8] = 1

# Verify that find_objects works on this
test_objects = ndimage.find_objects(binary_image)
assert test_objects is not None and len(test_objects) > 0, "Need at least one object"

largest_component = binary_image

ARGS = {
    "largest_component": largest_component
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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 int — 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
get_mask_otsu Ran
ran; our contract draft was wrong, not the code
vios-s/ldm-phrase-grounding/sampler.py
code served (permissive licence) · get_code("0ce3795836af80ec")
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
from skimage.filters import threshold_multiotsu

torch.manual_seed(0)

# Create a small heatmap tensor with shape (2, 3)
# Values should be in a reasonable range for threshold_multiotsu
heatmap = torch.rand(2, 3) * 255.0

# Define n_classes
n_classes = 2

ARGS = {
    "heatmap": heatmap,
    "n_classes": n_classes,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
skimage, 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
get_prompt_embeds Ran
ran, honoured the contract we drafted
vios-s/ldm-phrase-grounding/models_local/get_models.py
code served (permissive licence) · get_code("cf6de9501c2993aa")
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 3, dtype family float, shape (1, 2, 4) 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 tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.model_max_length = 77
    
    def __call__(self, prompt, padding=None, max_length=None, truncation=None, return_tensors=None):
        # Return a simple namespace with input_ids
        # Simulate tokenizing to 2 tokens (batch_size=1, seq_len=2)
        class TokenizerOutput:
            def __init__(self):
                self.input_ids = torch.tensor([[101, 102]], dtype=torch.long)  # shape: (1, 2)
        
        return TokenizerOutput()

# Create a minimal text encoder (nn.Module)
class MinimalTextEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(1000, 4)  # vocab_size=1000, embed_dim=4
    
    def forward(self, input_ids):
        # input_ids shape: (seq_len,) after squeeze(1)
        # Return tuple where first element is embeddings
        embeds = self.embedding(input_ids)  # shape: (seq_len, 4)
        return (embeds,)  # return as tuple

tokenizer = MinimalTokenizer()
text_encoder = MinimalTextEncoder()
prompt = "a photo of a cat"

ARGS = {
    "prompt": prompt,
    "tokenizer": tokenizer,
    "text_encoder": text_encoder,
}
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 3, dtype family float, shape (1, 2, 4) — shape (1, 2, 4) 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
largest_connected_component Ran
ran, violated the contract we drafted
vios-s/ldm-phrase-grounding/metrics/utils.py
code served (permissive licence) · get_code("3bd98c6271cef4d2")
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 ndarray, ndim 2, dtype family float, shape (4, 5) 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 numpy as np
from scipy import ndimage

# Create a small binary image with connected components
# We'll make a 4x5 binary array with a few distinct connected regions
binary_image = np.array([
    [1, 1, 0, 0, 0],
    [1, 1, 0, 0, 0],
    [0, 0, 1, 0, 0],
    [0, 0, 0, 1, 1]
], dtype=np.int32)

ARGS = {
    "binary_image": binary_image
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 5) — shape (4, 5) 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
mIoU Ran
ran; our contract draft was wrong, not the code
vios-s/ldm-phrase-grounding/metrics/eval_metrics.py
code served (permissive licence) · get_code("0529eba846aece7c")
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 float, 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

torch.manual_seed(0)

# sim_map: a 2D tensor of similarity scores
# The function indexes it as [y:y+h, x:x+w], so it needs at least 2 dimensions
# Let's make it 10x10 with float values between 0 and 1
sim_map = torch.rand(10, 10, dtype=torch.float32)

# gt_boxes: List of bounding boxes in format [x, y, w, h]
# Each box specifies a region: starting at (x, y) with width w and height h
gt_boxes = [
    [1, 1, 3, 2],  # x=1, y=1, width=3, height=2
    [5, 5, 2, 3],  # x=5, y=5, width=2, height=3
]

# thresholds: already has a default, but we can override it
thresholds = [0.1, 0.2, 0.3, 0.4, 0.5]

ARGS = {
    "sim_map": sim_map,
    "gt_boxes": gt_boxes,
    "thresholds": thresholds,
}
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 float, 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
nanvar Ran
ran; our contract draft was wrong, not the code
vios-s/ldm-phrase-grounding/metrics/utils.py
code served (permissive licence) · get_code("39da679eef535fe1")
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

torch.manual_seed(0)

# The function takes a tensor and computes the variance while ignoring NaN values
# It calls: tensor.nanmean(), tensor.square(), and operations on the tensor
# We need a tensor with some NaN values to properly test the nanvar function

tensor = torch.randn(2, 4)
# Insert some NaN values to test the nan-handling
tensor[0, 1] = float('nan')
tensor[1, 3] = float('nan')

ARGS = {
    'tensor': tensor
}
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
normalise_to_01 Ran
ran, honoured the contract we drafted
vios-s/ldm-phrase-grounding/sampler.py
code served (permissive licence) · get_code("ec6fd1be92e74fb3")
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, 2) 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

torch.manual_seed(0)

# Create a small heatmap tensor with values that have a range
# The function calls .min(), .max() on the heatmap, so it needs to support those
heatmap = torch.tensor([
    [0.1, 0.5],
    [0.3, 0.9]
], dtype=torch.float32)

ARGS = {
    "heatmap": heatmap
}
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, 2) — shape (2, 2) 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
CNR Not yet run
unverified (harvested, no recorded run)
vios-s/ldm-phrase-grounding/metrics/eval_metrics.py
code served (permissive licence) · get_code("8fb17b2d83d78dee")
How it ran

no invocation recorded.

mIoU_old Not yet run
unverified (harvested, no recorded run)
vios-s/ldm-phrase-grounding/metrics/eval_metrics.py
code served (permissive licence) · get_code("6fa294952b71cdb1")
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, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 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.

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

Repositories linked to this paper

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

Abstract

Localizing the exact pathological regions in a given medical scan is an important imaging problem that traditionally requires a large amount of bounding box ground truth annotations to be accurately solved. However, there exist alternative, potentially weaker, forms of supervision, such as accompanying free-text reports, which are readily available. The task of performing localization with textual guidance is commonly referred to as phrase grounding. In this work, we use a publicly available Foundation Model, namely the Latent Diffusion Model, to perform this challenging task. This choice is supported by the fact that the Latent Diffusion Model, despite being generative in nature, contains cross-attention mechanisms that implicitly align visual and textual features, thus leading to intermediate representations that are suitable for the task at hand. In addition, we aim to perform this task in a zero-shot manner, i.e., without any training on the target task, meaning that the model's weights remain frozen. To this end, we devise strategies to select features and also refine them via post-processing without extra learnable parameters. We compare our proposed method with state-of-the-art approaches which explicitly enforce image-text alignment in a joint embedding space via contrastive learning. Results on a popular chest X-ray benchmark indicate that our method is competitive with SOTA on different types of pathology, and even outperforms them on average in terms of two metrics (mean IoU and AUC-ROC). Source code will be released upon acceptance at https://github.com/vios-s.

For agents

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

get_harvested_code_for_paper("2404.12920")
get_code_for_paper("2404.12920")
have("2404.12920")

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

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

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

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

Connect an agent — have() is free.