SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2101.01909 · CVPR · 2021

Line Segment Detection Using Transformers without Edges

Zhuowen Tu, Yifan Xu, Weijian Xu, David Cheung

arXiv · PDF · Open in the Atlas

Code that ran

1 of 1 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 0 failures of our instrument; 0 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/2101.01909.json · badge: /api/ran/2101.01909.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/LETR marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
LETR Ran
ran on a synthesized input · constructed an object; no result was computed
mlpc-ucsd/LETR/src/models/letr.py
code served (permissive licence) · get_code("d41841292a61a7b1")
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, LETR: 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 torch import Tensor
from typing import Optional, List

torch.manual_seed(0)

# Create a minimal backbone that returns features and positional embeddings
class MinimalBackbone(nn.Module):
    def __init__(self):
        super().__init__()
        # The backbone needs to return a list of features at different layers
        # and positional embeddings for each layer
        self.conv1 = nn.Conv2d(3, 256, kernel_size=3, padding=1)
        self.conv2 = nn.Conv2d(256, 512, kernel_size=3, padding=1)
        self.conv3 = nn.Conv2d(512, 1024, kernel_size=3, padding=1)
        self.conv4 = nn.Conv2d(1024, 2048, kernel_size=3, padding=1)
    
    def forward(self, samples):
        # samples is a NestedTensor
        x = samples.tensors
        # Generate features at different scales
        f1 = self.conv1(x)
        f2 = self.conv2(f1)
        f3 = self.conv3(f2)
        f4 = self.conv4(f3)
        
        features = [
            NestedTensor(f1, samples.mask if samples.mask is not None else None),
            NestedTensor(f2, samples.mask if samples.mask is not None else None),
            NestedTensor(f3, samples.mask if samples.mask is not None else None),
            NestedTensor(f4, samples.mask if samples.mask is not None else None),
        ]
        
        # Positional embeddings for each layer (same structure as features)
        pos_embeddings = [
            torch.randn(2, 256, 4, 3),
            torch.randn(2, 512, 4, 3),
            torch.randn(2, 1024, 4, 3),
            torch.randn(2, 2048, 4, 3),
        ]
        
        return features, pos_embeddings

# Create a minimal transformer
class MinimalTransformer(nn.Module):
    def __init__(self, d_model=256, num_layers=2):
        super().__init__()
        self.d_model = d_model
        self.embedding = nn.Linear(d_model, d_model)
        self.layers = nn.ModuleList([nn.Linear(d_model, d_model) for _ in range(num_layers)])
    
    def forward(self, src, mask, query_embed, pos):
        # src: [batch, hidden_dim, height, width]
        # Flatten spatial dimensions
        batch_size, hidden_dim, h, w = src.shape
        src_flat = src.flatten(2).transpose(1, 2)  # [batch, h*w, hidden_dim]
        
        # Process through transformer layers
        x = src_flat
        for layer in self.layers:
            x = layer(x) + x
        
        # Return decoder hidden states (list of outputs from each decoder layer)
        # Shape: [num_layers, batch, num_queries, hidden_dim]
        hs = x.unsqueeze(0).expand(len(self.layers), -1, -1, -1)
        return [hs]

# Minimal args class
class Args:
    def __init__(self):
        self.layer1_num = 3  # Use the 4th layer (index 3)

# Define backbone and transformer
backbone = MinimalBackbone()
transformer = MinimalTransformer(d_model=256, num_layers=2)
args = Args()

# Create sample input tensors (batch=2, channels=3, height=4, width=3)
sample_tensors = [
    torch.randn(3, 4, 3),
    torch.randn(3, 4, 3),
]

ARGS = {
    'backbone': backbone,
    'transformer': transformer,
    'num_classes': 10,
    'num_queries': 5,
    'args': args,
    'aux_loss': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LETR — 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 LETR 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 1 samples lifted from this paper's linked repositories, 1 carry a function identity and 0 do not. Of the 1 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 1 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

In this paper, we present a joint end-to-end line segment detection algorithm using Transformers that is postprocessing and heuristics-guided intermediate processing (edge/junction/region detection) free. Our method, named LinE segment TRansformers (LETR), takes advantages of having integrated tokenized queries, a self-attention mechanism, and encoding-decoding strategy within Transformers by skipping standard heuristic designs for the edge element detection and perceptual grouping processes. We equip Transformers with a multi-scale encoder/decoder strategy to perform fine-grained line segment detection under a direct endpoint distance loss. This loss term is particularly suitable for detecting geometric structures such as line segments that are not conveniently represented by the standard bounding box representations. The Transformers learn to gradually refine line segments through layers of self-attention. In our experiments, we show state-of-the-art results on Wireframe and YorkUrban benchmarks. * indicates equal contribution.

For agents

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

get_harvested_code_for_paper("2101.01909")
get_code_for_paper("2101.01909")
have("2101.01909")

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

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

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

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

Connect an agent — have() is free.