SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.01918 · CVPR · 2022

Text Spotting Transformers

Xiang Zhang, Uc Diego, Zhuowen Tu, Subarna Tripathi, Yongwen Su

arXiv · PDF · Open in the Atlas

Code that ran

7 of 12 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; 5 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/2204.01918.json · badge: /api/ran/2204.01918.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
mlpc-ucsd/TESTR community
Papers with Code archive
7 ran · 5 no recorded run
FunctionStatusWhere it lives
DeformableCompositeTransformerDecoder Ran
ran on a synthesized input · constructed an object; no result was computed
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("d390248d94c9ed63")
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, DeformableCompositeTransformerDecoder: 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
from torch import nn
import copy

torch.manual_seed(0)

# Create a minimal decoder layer that matches the expected interface
class MinimalDecoderLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, output, query_pos, output_text, query_pos_text, reference_points_input, src, src_spatial_shapes, src_level_start_index, src_padding_mask, text_padding_mask):
        # Return modified output and output_text
        return output, output_text

# Create decoder layer instance
decoder_layer = MinimalDecoderLayer()

# Set num_layers
num_layers = 2

# Set return_intermediate flag
return_intermediate = True

ARGS = {
    "decoder_layer": decoder_layer,
    "num_layers": num_layers,
    "return_intermediate": return_intermediate,
}
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 DeformableCompositeTransformerDecoder — 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 DeformableCompositeTransformerDecoder 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
NestedTensor Ran
ran on a synthesized input · constructed an object; no result was computed
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("d515f52b31b887cc")
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, NestedTensor: 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 typing import Optional

torch.manual_seed(0)

# Construct tensors - batch_size=2, feature_dim=4
tensors = torch.randn(2, 4)

# Construct optional mask - same batch dimension
mask = torch.ones(2, dtype=torch.bool)

# Define ARGS dict mapping all parameters
ARGS = {
    "tensors": tensors,
    "mask": mask
}
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 NestedTensor — 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 NestedTensor 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
PositionalEncoding1D Ran
ran on a synthesized input
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("f77cafa6068b7559")
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 2, 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 numpy as np
import torch
from torch import nn

class PositionalEncoding1D(nn.Module):

    def __init__(self, num_pos_feats=64, temperature=10000, normalize=False, scale=None):
        """
        :param channels: The last dimension of the tensor you want to apply pos emb to.
        """
        super().__init__()
        self.channels = num_pos_feats
        dim_t = torch.arange(0, self.channels, 2).float()
        if scale is not None and normalize is False:
            raise ValueError('normalize should be True if scale is passed')
        if scale is None:
            scale = 2 * np.pi
        self.scale = scale
        self.normalize = normalize
        inv_freq = 1.0 / temperature ** (dim_t / self.channels)
        self.register_buffer('inv_freq', inv_freq)

    def forward(self, tensor):
        """
        :param tensor: A 2d tensor of size (len, c)
        :return: Positional Encoding Matrix of size (len, c)
        """
        if tensor.ndim != 2:
            raise RuntimeError('The input tensor has to be 2D!')
        x, orig_ch = tensor.shape
        pos_x = torch.arange(1, x + 1, device=tensor.device).type(self.inv_freq.type())
        if self.normalize:
            eps = 1e-06
            pos_x = pos_x / (pos_x[-1:] + eps) * self.scale
        sin_inp_x = torch.einsum('i,j->ij', pos_x, self.inv_freq)
        emb_x = torch.cat((sin_inp_x.sin(), sin_inp_x.cos()), dim=-1)
        emb = torch.zeros((x, self.channels), device=tensor.device).type(tensor.type())
        emb[:, :self.channels] = emb_x
        return emb[:, :orig_ch]


INIT_ARGS = {
    'num_pos_feats': 8,
    'temperature': 10000,
    'normalize': False,
    'scale': None,
}

ARGS = {
    'tensor': torch.randn(5, 6),
}

if __name__ == '__main__':
    model = PositionalEncoding1D(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Input shape: {ARGS['tensor'].shape}")
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
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 2, 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)
_MSDeformAttnFunction Ran
ran on a synthesized input · constructed an object; no result was computed
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("959e178e913b90c4")
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, _MSDeformAttnFunction: 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)

# Mock the _C module since it's a compiled extension
class MockCExtension:
    @staticmethod
    def ms_deform_attn_forward(value, value_spatial_shapes, value_level_start_index, sampling_locations, attention_weights, im2col_step):
        # Return output with shape (batch, channels, num_queries, num_heads)
        batch_size = value.shape[0]
        num_queries = sampling_locations.shape[1]
        num_heads = sampling_locations.shape[2]
        channels = value.shape[-1]
        return torch.randn(batch_size, channels, num_queries, num_heads, dtype=value.dtype)
    
    @staticmethod
    def ms_deform_attn_backward(value, value_spatial_shapes, value_level_start_index, sampling_locations, attention_weights, grad_output, im2col_step):
        # Return gradients for value, sampling_locations, and attention_weights
        grad_value = torch.randn_like(value)
        grad_sampling_loc = torch.randn_like(sampling_locations)
        grad_attn_weight = torch.randn_like(attention_weights)
        return grad_value, grad_sampling_loc, grad_attn_weight

# Replace _C in the module namespace with mock
import sys
mock_c = MockCExtension()

# Parameters:
# value: (batch, sum_spatial_sizes, channels)
batch_size = 2
channels = 4
num_levels = 2
spatial_h1, spatial_w1 = 2, 3
spatial_h2, spatial_w2 = 3, 2
sum_spatial = spatial_h1 * spatial_w1 + spatial_h2 * spatial_w2

value = torch.randn(batch_size, sum_spatial, channels, dtype=torch.float32)

# value_spatial_shapes: (num_levels, 2) containing (height, width) for each level
value_spatial_shapes = torch.tensor([
    [spatial_h1, spatial_w1],
    [spatial_h2, spatial_w2]
], dtype=torch.long)

# value_level_start_index: (num_levels,) cumulative index where each level starts
value_level_start_index = torch.tensor(
    [0, spatial_h1 * spatial_w1],
    dtype=torch.long
)

# sampling_locations: (batch, num_queries, num_heads, num_levels, 2)
# values in [-1, 1] representing normalized coordinates
num_queries = 5
num_heads = 3
sampling_locations = torch.rand(batch_size, num_queries, num_heads, num_levels, 2, dtype=torch.float32)
sampling_locations = sampling_locations * 2 - 1  # Normalize to [-1, 1]

# attention_weights: (batch, num_queries, num_heads, num_levels)
attention_weights = torch.randn(batch_size, num_queries, num_heads, num_levels, dtype=torch.float32)
attention_weights = torch.softmax(attention_weights, dim=-1)

# im2col_step: integer parameter
im2col_step = 64

ARGS = {
    'value': value,
    'value_spatial_shapes': value_spatial_shapes,
    'value_level_start_index': value_level_start_index,
    'sampling_locations': sampling_locations,
    'attention_weights': attention_weights,
    'im2col_step': im2col_step,
}
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 _MSDeformAttnFunction — 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 _MSDeformAttnFunction 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
inverse_sigmoid_offset Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("e15093f6736408d0")
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, 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)

# The function inverse_sigmoid_offset takes:
# - x: a tensor (used with clamp, arithmetic operations, log)
# - eps: a float (default 1e-05)
# - offset: a boolean (default True)

# Create a small tensor with values in a reasonable range for the function
# Values should be in roughly [-1, 2] range to test the offset behavior
x = torch.tensor([[-0.5, 0.0, 0.5, 1.0],
                   [0.2, 0.7, 0.3, 0.9]], dtype=torch.float32)

ARGS = {
    "x": x,
    "eps": 1e-05,
    "offset": True
}
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, 4) — shape (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
nested_tensor_from_tensor_list Ran
ran; our contract draft was wrong, not the code
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("874889b24390cf77")
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 NestedTensor. 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
from typing import List

torch.manual_seed(0)

# Create a list of 3D tensors with different sizes
# Each tensor has shape (C, H, W) where C=channels, H=height, W=width
tensor1 = torch.randn(3, 4, 5)  # 3 channels, 4 height, 5 width
tensor2 = torch.randn(3, 6, 7)  # 3 channels, 6 height, 7 width

tensor_list = [tensor1, tensor2]

ARGS = {
    "tensor_list": tensor_list
}
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 NestedTensor — a NestedTensor output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NestedTensor 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
sigmoid_offset Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("7430fe026bcbe067")
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, 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 tensor for the input x
x = torch.randn(2, 4)

# Define ARGS dict with all parameters
ARGS = {
    "x": x,
    "offset": True
}
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, 4) — shape (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
DeformableCompositeTransformerDecoderLayer Not yet run
unverified (harvested, no recorded run)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("45aa5f258a89a820")
How it ran

no invocation recorded.

DeformableTransformer Not yet run
unverified (harvested, no recorded run)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("d38f59f1328eb490")
How it ran

no invocation recorded.

DeformableTransformerEncoderLayer Not yet run
unverified (harvested, no recorded run)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("a9154eacf08507d1")
How it ran

no invocation recorded.

MSDeformAttn Not yet run
unverified (harvested, no recorded run)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("debe8b805c7fb525")
How it ran

no invocation recorded.

TESTR Not yet run
unverified (harvested, no recorded run)
mlpc-ucsd/TESTR/adet/modeling/testr/models.py
code served (permissive licence) · get_code("570d37f8635c97aa")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 3 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
NestedTensor
brick of this paper's assembly: helper
32 other papers
18 dated earlier, 1 the same month, 13 later · 28 only as an assembly brick
2005.12872 (2020-05)
End-to-End Object Detection with Transformers
2101.01909 (2021-01)
Line Segment Detection Using Transformers without Edges
2103.04503 (2021-03)
End-to-End Human Object Interaction Detection with HOI Transformer
and 29 more not named here
nested_tensor_from_tensor_list
brick of this paper's assembly: helper
19 other papers
11 dated earlier, 8 later · 11 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.05399 (2021-03)
QPIC: Query-Based Pairwise Human-Object Interaction Detection with Image-Wide Contextual Information
and 16 more not named here
DeformableTransformerEncoderLayer
brick of this paper's assembly: helper
5 other papers
1 dated earlier, 4 later
2103.11161 (2021-03)
MonteFloor: Extending MCTS for Reconstructing Accurate Large-Scale Floor Plans
2209.02242 (2022-09)
PTSEFormer: Progressive Temporal-Spatial Enhanced TransFormer Towards Video Object Detection
2308.09351 (2023-08)
RLIPv2: Fast Scaling of Relational Language-Image Pre-training
and 2 more not named here

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

In this paper, we present TExt Spotting TRansformers (TESTR), a generic end-to-end text spotting framework using Transformers for text detection and recognition in the wild. TESTR builds upon a single encoder and dual decoders for the joint text-box control point regression and character recognition. Other than most existing literature, our method is free from Region-of-Interest operations and heuristics-driven post-processing procedures; TESTR is particularly effective when dealing with curved text-boxes where special cares are needed for the adaptation of the traditional bounding-box representations. We show our canonical representation of control points suitable for text instances in both Bezier curve and polygon annotations. In addition, we design a bounding-box guided polygon detection (box-to-polygon) process. Experiments on curved and arbitrarily shaped datasets demonstrate state-of-theart performances of the proposed TESTR algorithm.

For agents

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

get_harvested_code_for_paper("2204.01918")
get_code_for_paper("2204.01918")
have("2204.01918")

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

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

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

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

Connect an agent — have() is free.