SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_25328 · AAAI · 2023

Text-DIAE: A Self-Supervised Degradation Invariant Autoencoder for Text Recognition and Document Enhancement

Dimosthenis Karatzas, Ali Biten, Andres Mafla, Lluis Gomez, Mohamed Souibgui, Sanket Biswas, Alicia Fornés, Yousri Kessentini, Josep Lladós

Open in the Atlas

Code that ran

7 of 7 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; 0 honoured the contract we drafted, 2 violated it and 5 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/aaai_25328.json · badge: /api/ran/aaai_25328.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
dali92002/SSL-OCR canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
augmentor Ran
ran on a synthesized input
dali92002/SSL-OCR/htrAugmentor.py
code served (permissive licence) · get_code("81297627b46772ff")
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 int, shape (81, 91) 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 cv2
import numpy as np
import random

# Set seed for reproducibility
np.random.seed(0)
random.seed(0)

# Create a small grayscale image (document-like)
# The function expects img.shape to be (height, width) for a 2D array
small_img = np.random.randint(50, 200, size=(64, 64), dtype=np.uint8)

# Ensure the image has some structure (not all noise) so the augmentor can work
small_img[20:40, 20:40] = 255  # White region
small_img[25:35, 25:35] = 0    # Black region in center

ARGS = {
    'img': small_img
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — 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 int, shape (81, 91) — shape (81, 91) 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
convert_image_np Ran
ran on a synthesized input
dali92002/SSL-OCR/utils.py
code served (permissive licence) · get_code("57d96f9357b19248")
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 3, dtype family float, shape (4, 5, 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

torch.manual_seed(0)

# The function expects a tensor with shape (C, H, W) where C=3 (channels)
# It calls .numpy() and .transpose((1, 2, 0))
# So we need a 3D tensor with channels first format
inp_tensor = torch.rand(3, 4, 5)  # (C, H, W) = (3, 4, 5)

ARGS = {
    "inp": inp_tensor
}
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 ndarray, ndim 3, dtype family float, shape (4, 5, 3) — shape (4, 5, 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
create_mask Ran
ran on a synthesized input
dali92002/SSL-OCR/models/transformer.py
code served (permissive licence) · get_code("cf576b0db0e5f2e0")
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. 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

torch.manual_seed(0)

# Create small tensor arguments for create_mask function
# The function expects:
# - src: tensor of shape (src_seq_len, batch_size) containing token indices
# - tgt: tensor of shape (tgt_seq_len, batch_size) containing token indices

# Create source tensor: sequence length 3, batch size 2
# Values are token indices (0, 1, or 2 where 2 is PAD_IDX)
src = torch.tensor([
    [0, 1],
    [1, 0],
    [2, 1]
], dtype=torch.long)

# Create target tensor: sequence length 4, batch size 2
# Values are token indices (0, 1, or 2 where 2 is PAD_IDX)
tgt = torch.tensor([
    [0, 1],
    [1, 0],
    [0, 2],
    [2, 1]
], dtype=torch.long)

ARGS = {
    'src': src,
    'tgt': tgt
}
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 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
generate_square_subsequent_mask Ran
ran, violated the contract we drafted
dali92002/SSL-OCR/models/transformer.py
pointer only (licence: MIT); the stored copy get_code serves, from hkust-nisl/oat_eccv24, is pointer only (licence: NONE) · get_code("3ee8f4b0078c65d0")
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 hkust-nisl/oat_eccv24, 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.

pair Ran
ran, violated the contract we drafted
dali92002/SSL-OCR/models/diae.py
code served (permissive licence) · get_code("6ba8cee9f5daea41")
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 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 torch

torch.manual_seed(0)

# The function 'pair' takes a single parameter 't' and returns it as a tuple if it isn't already one
# We need to test both cases: when t is a tuple and when it's not

# Case 1: t is not a tuple (e.g., an integer, string, tensor, etc.)
t_not_tuple = 5

# Case 2: t is already a tuple
t_is_tuple = (3, 7)

# We'll use the non-tuple case as the primary test
ARGS = {
    "t": t_not_tuple
}
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 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
sort_batch Ran
ran on a synthesized input
dali92002/SSL-OCR/loadData.py
code served (permissive licence) · get_code("908534c91a8b06e9")
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 torch
import numpy as np

torch.manual_seed(0)

# Construct a batch: list of tuples (idx, img, img_width, label)
batch = [
    (0, np.random.rand(4, 3).astype('float32'), 5, 1),
    (1, np.random.rand(4, 3).astype('float32'), 3, 0),
]

ARGS = {
    'batch': batch
}
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
sort_batch Ran
ran on a synthesized input
dali92002/SSL-OCR/loadData_pretrain.py
code served (permissive licence) · get_code("a8c883a6d2d00e10")
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 torch
import numpy as np

torch.manual_seed(0)

# The function expects a batch, which is a list of tuples
# Each tuple contains: (idx, img, dist_img_bg, dist_img_blur, img_width, label)

batch = [
    (0, np.random.randn(3, 4, 5).astype('float32'), np.random.randn(3, 4, 5).astype('float32'), np.random.randn(3, 4, 5).astype('float32'), 5, 10),
    (1, np.random.randn(3, 4, 5).astype('float32'), np.random.randn(3, 4, 5).astype('float32'), np.random.randn(3, 4, 5).astype('float32'), 7, 20),
]

ARGS = {
    'batch': batch
}
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

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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 5 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
pair 90 other papers
25 dated earlier, 38 later, 26 same year, order not determinable, 1 undated · 8 only as an assembly brick
2004.13649 (2020-04)
Image Augmentation Is All You Need: Regularizing Deep Reinforcement Learning from Pixels
2010.11929 (2020-10)
An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
2103.15691 (2021-03)
ViViT: A Video Vision Transformer
and 87 more not named here
generate_square_subsequent_mask 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2006.10369 (2020-06)
Deep Encoder, Shallow Decoder: Reevaluating Non-autoregressive Machine Translation
2211.07727 (2022-11)
Logical Tasks for Measuring Extrapolation and Rule Comprehension
2310.11984 (2023-10)
From Interpolation to Extrapolation: Complete Length Generalization for Arithmetic Transformers
and 1 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 propose a Text-Degradation Invariant Auto Encoder (Text-DIAE), a self-supervised model designed to tackle two tasks, text recognition (handwritten or scene-text) and document image enhancement. We employ a transformer-based architecture that incorporates three pretext tasks as learning objectives to be optimized during pretraining without the usage of labelled data. Each of the pretext objectives is tailored for the final downstream tasks. We conduct several ablation experiments that confirm the design choice of the selected pretext tasks. Importantly, the proposed model does not exhibit limitations of previous state-of-the-art methods based on contrastive losses, while at the same time requiring substantially fewer data samples to converge. Finally, we demonstrate that our method surpasses the state-ofthe-art in existing supervised and self-supervised settings in handwritten and scene text recognition and document image enhancement. Our code and trained models will be made publicly available at https://github.com/dali92002/SSL-OCR.

For agents

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

get_harvested_code_for_paper("aaai_25328")
get_code_for_paper("aaai_25328")
have("aaai_25328")

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

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

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

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

Connect an agent — have() is free.