SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.10447 · ECCV · 2022

Weakly Supervised Object Localization via Transformer with Implicit Spatial Calibration

Ruimao Zhang, Xiang Wan, Jiong Wang, Haotian Bai

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 3 failures of our instrument; 3 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/2207.10447.json · badge: /api/ran/2207.10447.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
164140757/SCM community
Papers with Code archive
7 ran · 3 no recorded run
FunctionStatusWhere it lives
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("ce23b9a90f7e4277")
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 an instance of its own class, Attention: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "dim": 8,
    "num_heads": 2,
    "qkv_bias": False,
    "qk_scale": None,
    "attn_drop": 0.1,
    "proj_drop": 0.1,
    "vis": False,
}
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 Attention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attention 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
Block Ran
ran on a synthesized input · constructed an object; no result was computed
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("cf9b5254c1c546d6")
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 an instance of its own class, Block: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn
from timm.models.layers import DropPath

torch.manual_seed(0)

ARGS = {
    "dim": 64,
    "num_heads": 8,
    "mlp_ratio": 4.0,
    "qkv_bias": False,
    "qk_scale": None,
    "drop": 0.1,
    "attn_drop": 0.1,
    "drop_path": 0.1,
    "act_layer": nn.GELU,
    "norm_layer": nn.LayerNorm,
    "vis": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Block — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Block 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
Fuse Ran
ran on a synthesized input · constructed an object; no result was computed
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("ffeae770a3f8ffce")
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 an instance of its own class, Fuse: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn
import numpy as np
from scipy.sparse import coo_matrix, diags

torch.manual_seed(0)
np.random.seed(0)

# Create a simple grid_size: 2D grid with 3x4 patches
grid_size = (3, 4)

# Create adjacency matrix for a 3x4 grid
# For simplicity, create a sparse matrix manually
num_patch = 3 * 4  # 12 patches
idx_row = []
idx_col = []

# Add some simple adjacency relationships (each patch connects to neighbors)
for i in range(num_patch):
    row = i // 4
    col = i % 4
    # Connect to right neighbor
    if col < 3:
        idx_row.append(i)
        idx_col.append(i + 1)
    # Connect to bottom neighbor
    if row < 2:
        idx_row.append(i)
        idx_col.append(i + 4)

adjMat = coo_matrix(
    (np.ones(len(idx_row), dtype=int), (idx_row, idx_col)),
    shape=(num_patch, num_patch),
    dtype=int
)

# Create in-degree matrix
idMat = diags(adjMat.sum(axis=0).A1)

# Create Laplacian matrix
lapMat = idMat - adjMat

ARGS = {
    "grid_size": grid_size,
    "iteration": 5,
    "num_connect": 4,
    "dilation": 1,
    "adjMat": adjMat,
    "idMat": idMat,
    "lapMat": lapMat,
    "loss_rate": 1.0,
    "init_cfg": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Fuse — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Fuse 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
HybridEmbed Ran
ran on a synthesized input
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("b780b9943fd000fc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, 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 torch.nn as nn
from timm.models.layers import DropPath, to_2tuple, trunc_normal_


class SimpleBackbone(nn.Module):
    """Minimal CNN backbone that returns a list with feature map as last element."""
    def __init__(self, in_chans=3, out_chans=4):
        super().__init__()
        self.conv1 = nn.Conv2d(in_chans, out_chans, kernel_size=3, padding=1)
        self.conv2 = nn.Conv2d(out_chans, out_chans, kernel_size=3, padding=1, stride=2)
        self.feature_info = type('obj', (object,), {'channels': lambda: [out_chans]})()
    
    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        return [x]


class HybridEmbed(nn.Module):
    """ CNN Feature Map Embedding
    Extract feature map from CNN, flatten, project to embedding dim.
    """

    def __init__(self, backbone, img_size=224, feature_size=None, in_chans=3, embed_dim=768):
        super().__init__()
        assert isinstance(backbone, nn.Module)
        img_size = to_2tuple(img_size)
        self.img_size = img_size
        self.backbone = backbone
        if feature_size is None:
            with torch.no_grad():
                training = backbone.training
                if training:
                    backbone.eval()
                o = self.backbone(torch.zeros(1, in_chans, img_size[0], img_size[1]))[-1]
                feature_size = o.shape[-2:]
                feature_dim = o.shape[1]
                backbone.train(training)
        else:
            feature_size = to_2tuple(feature_size)
            feature_dim = self.backbone.feature_info.channels()[-1]
        self.num_patches = feature_size[0] * feature_size[1]
        self.proj = nn.Linear(feature_dim, embed_dim)

    def forward(self, x):
        x = self.backbone(x)[-1]
        x = x.flatten(2).transpose(1, 2)
        x = self.proj(x)
        return x


backbone = SimpleBackbone(in_chans=3, out_chans=4)

INIT_ARGS = {
    'backbone': backbone,
    'img_size': 32,
    'feature_size': None,
    'in_chans': 3,
    'embed_dim': 8,
}

ARGS = {
    'x': torch.randn(2, 3, 32, 32),
}

if __name__ == '__main__':
    model = HybridEmbed(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: (2, {model.num_patches}, 8)")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
timm, 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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
embeddings_to_cosine_similarity_matrix Ran
ran; our contract draft was wrong, not the code
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("bb789660ac0c59bb")
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 (2, 3, 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

torch.manual_seed(0)

# Create a small tensor of shape (B, N, D)
# B = batch size = 2
# N = sequence length = 3
# D = embedding dimension = 4
tokens = torch.randn(2, 3, 4)

ARGS = {
    "tokens": tokens
}
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 (2, 3, 3) — shape (2, 3, 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
inverse_schulz Ran
ran; our contract draft was wrong, not the code
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("ac13c6b3c1647de2")
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 (2, 4, 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

torch.manual_seed(0)

# Create a small batch of square matrices
# Shape: (batch_size=2, matrix_dim=4, matrix_dim=4)
# Make them well-conditioned for matrix inversion
batch_size = 2
matrix_dim = 4

# Create random matrices and ensure they're well-conditioned
X = torch.randn(batch_size, matrix_dim, matrix_dim)
# Scale to improve conditioning
X = X / (torch.norm(X, dim=(-2, -1), keepdim=True) + 0.1)

ARGS = {
    "X": X,
    "iteration": 5,
    "alpha": 0.002
}
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 (2, 4, 4) — shape (2, 4, 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
norm_cam Ran
ran; our contract draft was wrong, not the code
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("e0c1b88633b751da")
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 (2, 4, 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 numpy as np
from einops import rearrange, repeat

torch.manual_seed(0)

# Test case 1: 3D tensor (B, H, W)
cam_3d = torch.randn(2, 4, 3)

# Test case 2: 2D tensor (B, features)
cam_2d = torch.randn(2, 5)

# Test case 3: 4D tensor (B, C, H, W)
cam_4d = torch.randn(2, 3, 4, 5)

# Use the 3D case as the primary test
ARGS = {
    "cam": cam_3d
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, numpy, 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 (2, 4, 3) — shape (2, 4, 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
Encoder Not yet run
unverified (harvested, no recorded run)
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("234c278bead3ee45")
How it ran

no invocation recorded.

SCM Not yet run
unverified (harvested, no recorded run)
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("c2d706c181c15ef2")
How it ran

no invocation recorded.

VisionTransformer Not yet run
unverified (harvested, no recorded run)
164140757/SCM/lib/models/deit.py
code served (permissive licence) · get_code("c56f1df1064bfab1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 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
HybridEmbed
brick of this paper's assembly: helper
2 other papers
2 dated earlier · 1 only as an assembly brick
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
2204.12484 (2022-04)
ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation

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

Weakly Supervised Object Localization (WSOL), which aims to localize objects by only using image-level labels, has attracted much attention because of its low annotation cost in real applications. Recent studies leverage the advantage of self-attention in visual Transformer for long-range dependency to re-active semantic regions, aiming to avoid partial activation in traditional class activation mapping (CAM). However, the long-range modeling in Transformer neglects the inherent spatial coherence of the object, and it usually diffuses the semantic-aware regions far from the object boundary, making localization results significantly larger or far smaller. To address such an issue, we introduce a simple yet effective Spatial Calibration Module (SCM) for accurate WSOL, incorporating semantic similarities of patch tokens and their spatial relationships into a unified diffusion model. Specifically, we introduce a learnable parameter to dynamically adjust the semantic correlations and spatial context intensities for effective information propagation. In practice, SCM is designed as an external module of Transformer, and can be removed during inference to reduce the computation cost. The object-sensitive localization ability is implicitly embedded into the Transformer encoder through optimization in the training phase. It enables the generated attention maps to capture the sharper object boundaries and filter the object-irrelevant background area. Extensive experimental results demonstrate the effectiveness of the proposed method, which significantly outperforms its counterpart TS-CAM on both CUB-200 and ImageNet-1K benchmarks. The code is available at https://github.com/164140757/SCM.

For agents

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

get_harvested_code_for_paper("2207.10447")
get_code_for_paper("2207.10447")
have("2207.10447")

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

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

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

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

Connect an agent — have() is free.