SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.13867 · CVPR · 2022

Vision-Language Pre-Training for Boosting Scene Text Detectors

Xiang Bai, Sibo Song, Jun Tang, Jianqiang Wan, Zhibo Yang, Cong Yao, Wenqing Cheng

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure of our instrument; 1 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.13867.json · badge: /api/ran/2204.13867.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
CVI-SZU/STKM community
Papers with Code archive
6 ran · 1 no recorded run
FunctionStatusWhere it lives
Attention_Blosk Ran
ran on a synthesized input
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("a6d8c280c44ff126")
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 tuple. 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

INIT_ARGS = {
    'Dim_K': 4,
    'Dim_V': 4,
    'Embedding_Size': 8,
    'Num_Head': 2,
    'Dropout': 0.1
}

batch_size = 2
seq_len = 3

q = torch.randn(batch_size, seq_len, INIT_ARGS['Embedding_Size'])
k = torch.randn(batch_size, seq_len, INIT_ARGS['Embedding_Size'])
v = torch.randn(batch_size, seq_len, INIT_ARGS['Embedding_Size'])
mask = torch.ones(batch_size, seq_len)
mask[0, -1] = 0  # Example mask with one zero entry

ARGS = {
    'q': q,
    'k': k,
    'v': v,
    'mask': mask
}
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 tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("9b153d776f334bc5")
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, Encoder: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

# Create small test input
# The Encoder expects:
# - x: input tensor of shape (batch_size, seq_len, vocab_size)
# - mask: attention mask of shape (batch_size, seq_len)

batch_size = 2
seq_len = 3
vocab_size = 5
num_layers = 2
Dim_K = 4
Dim_V = 4
Embedding_Size = 8
Num_Head = 2

# Create dummy input data
x = torch.randn(batch_size, seq_len, vocab_size)
mask = torch.ones(batch_size, seq_len)

ARGS = {
    'vocab_size': vocab_size,
    'num_layers': num_layers,
    'Dim_K': Dim_K,
    'Dim_V': Dim_V,
    'Embedding_Size': Embedding_Size,
    'Num_Head': Num_Head,
}
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 Encoder — 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 Encoder 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
Encoder_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("ddbe5cd199ca5fc2")
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, Encoder_Layer: 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

torch.manual_seed(0)

# Define the helper functions and classes that are used
def attention_sdp(Dim_K, q, k, v, mask):
    c = np.sqrt(Dim_K)
    attention_wight = torch.matmul(q, k.transpose(2, 3)) / c
    if mask is not None:
        mask = mask.unsqueeze(1)
        attention_wight = attention_wight.masked_fill(mask == 0, -1000000000.0)
    attention_wight = torch.nn.functional.softmax(attention_wight, 3)
    a = torch.matmul(attention_wight, v)
    return (a, attention_wight)

class Attention_Blosk(nn.Module):
    def __init__(self, Dim_K, Dim_V, Embedding_Size=512, Num_Head=8, Dropout=0.1):
        super(Attention_Blosk, self).__init__()
        self.Dim_K = Dim_K
        self.Dim_V = Dim_V
        self.Num_Head = Num_Head
        self.Wq = nn.Linear(Embedding_Size, Dim_K * Num_Head)
        self.Wk = nn.Linear(Embedding_Size, Dim_K * Num_Head)
        self.Wv = nn.Linear(Embedding_Size, Dim_V * Num_Head)
        self.Wout = nn.Linear(Dim_V * Num_Head, Embedding_Size)
        self.dropout = nn.Dropout(Dropout)
        self.LayerNorm = nn.LayerNorm(Embedding_Size)

    def forward(self, q, k, v, mask):
        x = q
        batch_size = q.shape[0]
        q = self.Wq(q).view(batch_size, -1, self.Num_Head, self.Dim_K).transpose(1, 2)
        k = self.Wk(k).view(batch_size, -1, self.Num_Head, self.Dim_K).transpose(1, 2)
        v = self.Wv(v).view(batch_size, -1, self.Num_Head, self.Dim_V).transpose(1, 2)
        attention_out, attention_wight = attention_sdp(self.Dim_K, q, k, v, mask)
        attention_out = attention_out.transpose(1, 2).contiguous().view(batch_size, -1, self.Num_Head * self.Dim_V)
        attention_out = self.Wout(attention_out)
        attention_out = self.dropout(attention_out)
        attention_out = self.LayerNorm(x + attention_out)
        return (attention_out, attention_wight)

class Feed_Forward_Net(nn.Module):
    def __init__(self, Embedding_Size, Mid_Size, Dropout=0.1):
        super(Feed_Forward_Net, self).__init__()
        self.Linear1 = nn.Linear(Embedding_Size, Mid_Size)
        self.RelU = nn.ReLU()
        self.Linear2 = nn.Linear(Mid_Size, Embedding_Size)
        self.dropout = nn.Dropout(Dropout)
        self.LayerNorm = nn.LayerNorm(Embedding_Size)

    def forward(self, x):
        res = x
        output = self.Linear1(x)
        output = self.RelU(output)
        output = self.Linear2(output)
        output = self.dropout(output)
        output = self.LayerNorm(res + output)
        return output

class Encoder_Layer(nn.Module):
    def __init__(self, Dim_K, Dim_V, Embedding_Size=512, Num_Head=8):
        super(Encoder_Layer, self).__init__()
        self.attention = Attention_Blosk(Dim_K, Dim_V, Embedding_Size=Embedding_Size, Num_Head=Num_Head)
        self.Feed_Forward_Net = Feed_Forward_Net(Embedding_Size, Mid_Size=1024)

    def forward(self, x, mask):
        output, attention_ = self.attention(x, x, x, mask)
        output = self.Feed_Forward_Net(output)
        return (output, attention_)

# Setup arguments for Encoder_Layer
Dim_K = 2
Dim_V = 3
Embedding_Size = 4
Num_Head = 2

# Create input tensor: batch_size=2, seq_len=5, embedding_size=4
x = torch.randn(2, 5, Embedding_Size)

# Create mask tensor: batch_size=2, seq_len=5 (all ones means no masking)
mask = torch.ones(2, 5, dtype=torch.bool)

ARGS = {
    'Dim_K': Dim_K,
    'Dim_V': Dim_V,
    'Embedding_Size': Embedding_Size,
    'Num_Head': Num_Head,
}
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 Encoder_Layer — 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 Encoder_Layer 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
Feed_Forward_Net Ran
ran on a synthesized input · constructed an object; no result was computed
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("04a294c280204626")
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, Feed_Forward_Net: 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)

class Feed_Forward_Net(nn.Module):

    def __init__(self, Embedding_Size, Mid_Size, Dropout=0.1):
        super(Feed_Forward_Net, self).__init__()
        self.Linear1 = nn.Linear(Embedding_Size, Mid_Size)
        self.RelU = nn.ReLU()
        self.Linear2 = nn.Linear(Mid_Size, Embedding_Size)
        self.dropout = nn.Dropout(Dropout)
        self.LayerNorm = nn.LayerNorm(Embedding_Size)

    def forward(self, x):
        res = x
        output = self.Linear1(x)
        output = self.RelU(output)
        output = self.Linear2(output)
        output = self.dropout(output)
        output = self.LayerNorm(res + output)
        return output

# Create a small instance
embedding_size = 8
mid_size = 16
dropout = 0.1

model = Feed_Forward_Net(
    Embedding_Size=embedding_size,
    Mid_Size=mid_size,
    Dropout=dropout
)

# Create a small input tensor (batch_size=2, embedding_size=8)
x = torch.randn(2, embedding_size)

# Test the forward pass
output = model(x)

ARGS = {
    "Embedding_Size": 8,
    "Mid_Size": 16,
    "Dropout": 0.1
}
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 Feed_Forward_Net — 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 Feed_Forward_Net 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
Pos_Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("1008247d190df035")
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, Pos_Encoder: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 numpy as np
import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'Embedding_Size': 4,
    'maxlen': 8
}
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 Pos_Encoder — 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 Pos_Encoder 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
attention_sdp Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("ceef05668f1db913")
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. 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 numpy as np
import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Construct arguments for attention_sdp
Dim_K = 8

# q, k, v are query, key, value tensors
# Expected shapes: (batch, num_heads, seq_len, dim_per_head)
batch_size = 2
num_heads = 3
seq_len_q = 4
seq_len_k = 5
dim_per_head = 8

q = torch.randn(batch_size, num_heads, seq_len_q, dim_per_head)
k = torch.randn(batch_size, num_heads, seq_len_k, dim_per_head)
v = torch.randn(batch_size, num_heads, seq_len_k, dim_per_head)

# mask: optional attention mask
# Expected shape: (batch, 1, seq_len_q, seq_len_k) after unsqueeze
# Using 1s where attention is allowed, 0s where it's masked
mask = torch.ones(batch_size, 1, seq_len_q, seq_len_k)
mask[:, :, :, -1] = 0  # Mask out last position as example

ARGS = {
    "Dim_K": Dim_K,
    "q": q,
    "k": k,
    "v": v,
    "mask": mask
}
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 tuple — a tuple output has no array shape of its own; none is 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
Tensor Not yet run
unverified (harvested, no recorded run)
CVI-SZU/STKM/model/transformers.py
code served (permissive licence) · get_code("515bc2c7a38069cb")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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 7 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

Recently, vision-language joint representation learning has proven to be highly effective in various scenarios. In this paper, we specifically adapt vision-language joint learning for scene text detection, a task that intrinsically involves cross-modal interaction between the two modalities: vision and language, since text is the written form of language. Concretely, we propose to learn contextualized, joint representations through vision-language pretraining, for the sake of enhancing the performance of scene text detectors. Towards this end, we devise a pre-training architecture with an image encoder, a text encoder and a cross-modal encoder, as well as three pretext tasks: imagetext contrastive learning (ITC), masked language modeling (MLM) and word-in-image prediction (WIP). The pretrained model is able to produce more informative representations with richer semantics, which could readily benefit existing scene text detectors (such as EAST and PSENet) in the down-stream text detection task. Extensive experiments on standard benchmarks demonstrate that the proposed paradigm can significantly improve the performance of various representative text detectors, outperforming previous pre-training approaches. The code and pre-trained models will be publicly released.

For agents

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

get_harvested_code_for_paper("2204.13867")
get_code_for_paper("2204.13867")
have("2204.13867")

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

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

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

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

Connect an agent — have() is free.