DT-LSD: Deformable Transformer-based Line Segment Detection

May 1, 2025 ยท View on GitHub

arXiv

DT-LSD: Deformable Transformer-based Line Segment Detection

This repository contains the official implementation for DT-LSD (Deformable Transformer-based Line Segment Detector)

Model Architecture

TODO

  • Training
  • Evaluation
  • Upload source code
  • Upload weight
  • Inference
  • Upload arxiv paper

๐Ÿš€ Updates

  • We have released a new model called LINEA.
    • LINEA presents a new attention mechanism called line attention.
    • LINEA has four model sizes: n, s, and l.
    • Try LINEA hugging face space

Results

sap_wireframe aph_wireframe

sap_york aph_york

DatasetsAP10sAP15APHFHFPS
Wireframe71.773.989.185.88.9
YorkUrban33.235.165.968.08.9

Installation

  1. Clone this repository.

    git clone https://github.com/SebastianJanampa/DTLSD.git
    cd DTLSD
    
  2. Install Pytorch and torchvision

    Follow the instructions on https://pytorch.org/get-started/locally/.

    # an example:
    conda install -c pytorch pytorch torchvision
    
  3. Install other needed packages

    pip install -r requirements.txt
    
  4. Compiling CUDA operators

    cd models/dtlsd/ops
    python setup.py build install
    # unit test (should see all checking is True)
    python test.py
    cd ../../..
    

Dataset

To reproduce our results, you need to process two datasets, ShanghaiTech and YorkUrban.

mkdir data
cd data
wget https://github.com/SebastianJanampa/storage/releases/download/v1.0.0/wireframe_processed.zip
wget https://github.com/SebastianJanampa/storage/releases/download/v1.0.0/york_processed.zip

unzip wireframe_processed.zip
unzip york_processed.zip

rm *zip
cd ..

Pretraining weights

Download the weights from DINO_SWIN_4scales_36_epochs from the DINO repo, and place it in the pretrain folder.

Run

  1. Training
bash scripts/train/DTLSD_SWIN_4_scales_24_epochs.sh 
  1. Testing
bash scripts/train/DTLSD_SWIN_4_scales_24_epochs.sh

Demo

Download the DTLSD weights

wget https://github.com/SebastianJanampa/storage/releases/download/v1.0.0/DTLSD_checkpoint0035.pth

If wget doesn't work, download it from this link, and place it in the main folder. Then run

python demo.py

Citation

@InProceedings{Janampa_2025_WACV,
    author    = {Janampa, Sebastian and Pattichis, Marios},
    title     = {DT-LSD: Deformable Transformer-Based Line Segment Detection},
    booktitle = {Proceedings of the Winter Conference on Applications of Computer Vision (WACV)},
    month     = {February},
    year      = {2025},
    pages     = {3477-3486}
}