SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2208.13721 · 2022

CounTR: Transformer-based Generalised Visual Counting

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 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, 0 violated it and 3 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-24; 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/2208.13721.json · badge: /api/ran/2208.13721.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
Verg-Avesta/CounTR canonical (classifier label)
classifier basis not recorded on the link
4 ran · 0 no recorded run
FunctionStatusWhere it lives
drop_path Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Verg-Avesta/CounTR/models_crossvit.py
pointer only (licence: MIT); the stored copy get_code serves, from AHKerrigan/GeoGuessNet, is pointer only (licence: NONE) · get_code("e3aa4e8e74369506")
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 AHKerrigan/GeoGuessNet, 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.

load_image Ran
ran on a synthesized input
Verg-Avesta/CounTR/demo_zero.py
code served (permissive licence) · get_code("1f53c50f46429972")
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
from PIL import Image
import io

torch.manual_seed(0)

# Create a minimal valid image file in memory
# PIL Image.open needs a file-like object or path, so we create a small RGB image
img_array = torch.randint(0, 256, (100, 150, 3), dtype=torch.uint8).numpy()
pil_image = Image.fromarray(img_array, mode='RGB')

# Save to a temporary bytes buffer and then create a real file path
# Since we can't do file I/O, we'll create the image directly and mock the path
# Actually, we need a real file. Let's use a minimal approach with a temp file.
import tempfile
import os

temp_dir = tempfile.gettempdir()
img_path = os.path.join(temp_dir, 'test_image_setup.png')
pil_image.save(img_path)

ARGS = {
    'img_path': img_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, torch, torchvision — 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
transform_pre_train Ran
ran on a synthesized input
Verg-Avesta/CounTR/util/FSC147.py
code served (permissive licence) · get_code("b3dfc95b707288c3")
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 Compose. 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
import json
import tempfile
import os
from argparse import Namespace
from PIL import Image

torch.manual_seed(0)

# Create temporary directory and files
temp_dir = tempfile.mkdtemp()

# Create image directory
im_dir = os.path.join(temp_dir, 'images')
os.makedirs(im_dir, exist_ok=True)

# Create annotation file
anno_file = os.path.join(temp_dir, 'annotations.json')
annotations = {
    'image1': {
        'boxes': [[10, 20, 30, 40], [50, 60, 70, 80]]
    }
}
with open(anno_file, 'w') as f:
    json.dump(annotations, f)

# Create data split file
data_split_file = os.path.join(temp_dir, 'data_split.json')
data_split = {
    'train': ['image1'],
    'test': []
}
with open(data_split_file, 'w') as f:
    json.dump(data_split, f)

# Create class file
class_file = os.path.join(temp_dir, 'classes.txt')
with open(class_file, 'w') as f:
    f.write('class1 attr1 attr2\n')
    f.write('class2 attr3 attr4\n')

ARGS = {
    'args': Namespace(
        im_dir=im_dir,
        anno_file=anno_file,
        data_split_file=data_split_file,
        do_aug=True,
        class_file=class_file
    )
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, cv2, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
transform_val Ran
ran on a synthesized input
Verg-Avesta/CounTR/util/FSC147.py
code served (permissive licence) · get_code("75f6c7e715903362")
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 Compose. 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 json
import tempfile
import os
from argparse import Namespace
from PIL import Image
import torch
import numpy as np

torch.manual_seed(0)

# Create temporary directory for test files
tmpdir = tempfile.mkdtemp()

# Create a minimal annotations file
annotations = {
    "image1": {"dots": [[10, 20], [50, 60]], "lines_boxes": [[5, 10, 30, 40], [40, 50, 80, 90], [100, 100, 150, 150], [160, 160, 200, 200]]}
}
anno_file = os.path.join(tmpdir, "annotations.json")
with open(anno_file, 'w') as f:
    json.dump(annotations, f)

# Create a minimal data split file
data_split = {
    "train": ["image1"],
    "val": ["image1"]
}
data_split_file = os.path.join(tmpdir, "data_split.json")
with open(data_split_file, 'w') as f:
    json.dump(data_split, f)

# Create a minimal class file
class_file = os.path.join(tmpdir, "classes.txt")
with open(class_file, 'w') as f:
    f.write("class1 attr1 attr2\n")
    f.write("class2 attr3 attr4\n")

# Create a minimal image directory
im_dir = os.path.join(tmpdir, "images")
os.makedirs(im_dir, exist_ok=True)

# Create a minimal test image
test_image = Image.new('RGB', (200, 200), color='red')
test_image.save(os.path.join(im_dir, "image1.jpg"))

# Create args Namespace with all required parameters
ARGS = {
    'args': Namespace(
        im_dir=im_dir,
        anno_file=anno_file,
        data_split_file=data_split_file,
        class_file=class_file,
        do_aug=True
    )
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, scipy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 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, 1 later) and 3 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
drop_path 66 other papers
10 dated earlier, 54 later, 2 undated · 15 only as an assembly brick
1906.01502 (2019-06)
How multilingual is Multilingual BERT?
2011.10566 (2020-11)
Exploring Simple Siamese Representation Learning
2103.03230 (2021-03)
Barlow Twins: Self-Supervised Learning via Redundancy Reduction
and 63 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-24.

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 consider the problem of generalised visual object counting, with the goal of developing a computational model for counting the number of objects from arbitrary semantic categories, using arbitrary number of "exemplars", i.e. zero-shot or few-shot counting. To this end, we make the following four contributions: (1) We introduce a novel transformer-based architecture for generalised visual object counting, termed as Counting Transformer (CounTR), which explicitly capture the similarity between image patches or with given "exemplars" with the attention mechanism;(2) We adopt a two-stage training regime, that first pre-trains the model with self-supervised learning, and followed by supervised fine-tuning;(3) We propose a simple, scalable pipeline for synthesizing training images with a large number of instances or that from different semantic categories, explicitly forcing the model to make use of the given "exemplars";(4) We conduct thorough ablation studies on the large-scale counting benchmark, e.g. FSC-147, and demonstrate state-of-the-art performance on both zero and few-shot settings.

For agents

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

get_harvested_code_for_paper("2208.13721")
get_code_for_paper("2208.13721")
have("2208.13721")

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

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

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

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

Connect an agent — have() is free.