Line as a Visual Sentence: Context-aware Line Descriptor for Visual Localization

Overview

Line as a Visual Sentence with LineTR

This repository contains the inference code, pretrained model, and demo scripts of the following paper. It supports both point(SuperPoint) and line features(LSD+LineTR).

@article{syoon-2021-linetr,
  author    = {Sungho Yoon and Ayoung Kim},
  title     = {{Line as a Visual Sentence}: Context-aware Line Descriptor for Visual Localization},
  booktitle = {IEEE Robotics and Automation Letters},
  year      = {2021}
}

Abstract

Along with feature points for image matching, line features provide additional constraints to solve visual geometric problems in robotics and computer vision (CV). Although recent convolutional neural network (CNN)-based line descriptors are promising for viewpoint changes or dynamic environments, we claim that the CNN architecture has innate disadvantages to abstract variable line length into the fixed-dimensional descriptor. In this paper, we effectively introduce the Line-Transformer dealing with variable lines. Inspired by natural language processing (NLP) tasks where sentences can be understood and abstracted well in neural nets, we view a line segment as a sentence that contains points (words). By attending to well-describable points on a line dynamically, our descriptor performs excellently on variable line length. We also propose line signature networks sharing the line's geometric attributes to neighborhoods. Performing as group descriptors, the networks enhance line descriptors by understanding lines' relative geometries. Finally, we present the proposed line descriptor and matching in a Point and Line Localization (PL-Loc). We show that the visual localization with feature points can be improved using our line features. We validate the proposed method for homography estimation and visual localization.

Getting Started

This code was tested with Python 3.6 and PyTorch 1.8 on Ubuntu 18.04.

# create and activate a new conda environment
conda create -y --name linetr
conda activate linetr

# install the dependencies
conda install -y python=3.6
pip install -r requirements.txt

Command

There are two demo scripts:

  1. demo_LineTR.py : run a live demo on a camera or video file
  2. match_line_pairs.py : find line correspondence for image pairs, listed in input_pairs.txt

Keyboard control:

  • n: select the current frame as the anchor
  • e/r: increase/decrease the keypoint confidence threshold
  • d/f: increase/decrease the nearest neighbor matching threshold for keypoints
  • c/v: increase/decrease the nearest neighbor matching threshold for keylines
  • k: toggle the visualization of keypoints
  • q: quit

The scripts are partially reusing SuperGluePretrainedNetwork.

BibTeX Citation

@ARTICLE{syoon-2021-linetr,
  author    = {Sungho Yoon and Ayoung Kim},
  title     = {{Line as a Visual Sentence}: Context-aware Line Descriptor for Visual Localization},
  booktitle = {IEEE Robotics and Automation Letters},
  year      = {2021},
  url       = {https://arxiv.org/abs/2109.04753}
}

Acknowledgment

This work was fully supported by [Localization in changing city] project funded by NAVER LABS Corporation.

Comments
  • Line Signature Networks

    Line Signature Networks

    Hi, thanks for this very nice work. I read the paper, but I have some questions:

    1. Is your "LineTR_weight.pth" trained on scannet like superglue? As far as I know scannet does not have the ground truth of the line.
    2. I noticed your fig2, just one figure input the transformer and line signature networks. Does it mean that training transformer and line line signature networks does not require the ground truth of scannet, just input line and point that have been detected?
    opened by Zhuyawen7 6
  • Question about line homography estimation

    Question about line homography estimation

    Thank you for your work. When i view your code,I noticed that there is no code for homography. Cloud you teach me how to achieve the result like Figure 5 in your paper?I have sent you an email. Looking forward to your reply.

    opened by ChrisLLLLL 3
  • Potential bug in the KeylineEncoder

    Potential bug in the KeylineEncoder

    Hi @yosungho,

    Thanks for this very nice work and for sharing the code, it is very insightful!

    When studying the code, I noticed something weird that might be a bug. It is located in the KeylineEncoder at line: https://github.com/yosungho/LineTR/blob/afd89effcc081fe75105ea9c3598fdc5e91b6179/models/line_transformer.py#L121 It seems that the line descriptor is not updated at each iteration, since the output of the desc_layer has a different name than the input (desc vs enc_output). This does not trigger any error from the compiler, but the effect is that only one iteration of desc_layers is effectively used... The previous iterations are just overwritten each time.

    Let me know if I got a wrong understanding of this line. Otherwise I think that the correction would be the following:

    for desc_layer in self.desc_layers:
       desc, enc_slf_attn = desc_layer(desc, slf_attn_mask=mask)
       enc_slf_attn_list += [enc_slf_attn] if return_attns else []
    enc_output = desc
    
    opened by rpautrat 2
  • code of line-based homography estimation

    code of line-based homography estimation

    Hi! I'm very interested in your work because recently I want to use line descriptors for homography estimation. I noticed that you implemented the code of the paper "Combining line and point correspondences for homography estimation". But I did not find out the code of that part in this repository for homography estimation. Could you provide the code for that part?

    opened by EchoTHChen 2
  • How to test with the trained model on my own dataset?

    How to test with the trained model on my own dataset?

    Hi, thanks for your great work. I wonder that how to test the model trained on my own dataset. I find that the match_line_pairs.py load superpoint model and linetr model but not my model_best.pth.tar? So how could I use it to infer.

    opened by jarvishou829 1
  • ZeroDivisionError

    ZeroDivisionError

    Hello, when i run the original code, it always occurs the ZeroDivisionError, it also happens after i change the dataset. The reason is that the TP and FP are both 0 at the same time, so the precision is very low. It seems like the network is not converging. What should i do? Traceback (most recent call last): File "train.py", line 263, in <module> main() File "train.py", line 93, in main is_best = run_epochs("val", conf, val_loader, model, None, logger, epoch, device, lr_scheduler) File "train.py", line 233, in run_epochs result.evaluate(pred, batch_data, loss.item(), batch_index) File "/home/linux/catkin_ws/LineTR-train/evaluations/metric.py", line 40, in evaluate precision, recall, f1_score = self.eval_pr.get_precision_recall(score_pred, score_gt) File "/home/linux/catkin_ws/LineTR-train/evaluations/evaluate_pr.py", line 31, in get_precision_recall precision = np.average(np.nan_to_num(TP / (TP+FP)))*100. ZeroDivisionError: division by zero

    opened by BlueAkoasm 1
  • Code of generating ground-truth line correspondences and 3D linemaps

    Code of generating ground-truth line correspondences and 3D linemaps

    Hello @yosungho, thank you for your paper!

    Would it be possible for you to, please provide the code for the generating ground-truth line correspondences and 3D linemaps part on InLoc, so it would be possible to test visual localization results? I have sent you an email (address provided in the paper) with the same question.

    opened by LizaAvsyannik 1
Owner
SungHo Yoon
Ph.D. Student studying SLAM and Machine Learning
SungHo Yoon
🐍💯pySBD (Python Sentence Boundary Disambiguation) is a rule-based sentence boundary detection that works out-of-the-box.

pySBD: Python Sentence Boundary Disambiguation (SBD) pySBD - python Sentence Boundary Disambiguation (SBD) - is a rule-based sentence boundary detecti

Nipun Sadvilkar 277 Feb 18, 2021
REST API for sentence tokenization and embedding using Multilingual Universal Sentence Encoder.

What is MUSE? MUSE stands for Multilingual Universal Sentence Encoder - multilingual extension (16 languages) of Universal Sentence Encoder (USE). MUS

Dani El-Ayyass 47 Sep 5, 2022
Using context-free grammar formalism to parse English sentences to determine their structure to help computer to better understand the meaning of the sentence.

Sentance Parser Executing the Program Make sure Python 3.6+ is installed. Install requirements $ pip install requirements.txt Run the program:

Vaibhaw 12 Sep 28, 2022
A sentence aligner for comparable corpora

About Yalign is a tool for extracting parallel sentences from comparable corpora. Statistical Machine Translation relies on parallel corpora (eg.. eur

Machinalis 128 Aug 24, 2022
Sentence Embeddings with BERT & XLNet

Sentence Transformers: Multilingual Sentence Embeddings using BERT / RoBERTa / XLM-RoBERTa & Co. with PyTorch This framework provides an easy method t

Ubiquitous Knowledge Processing Lab 9.1k Jan 2, 2023
Extract Keywords from sentence or Replace keywords in sentences.

FlashText This module can be used to replace keywords in sentences or extract keywords from sentences. It is based on the FlashText algorithm. Install

Vikash Singh 5.3k Jan 1, 2023
Sentence Embeddings with BERT & XLNet

Sentence Transformers: Multilingual Sentence Embeddings using BERT / RoBERTa / XLM-RoBERTa & Co. with PyTorch This framework provides an easy method t

Ubiquitous Knowledge Processing Lab 4.2k Feb 18, 2021
Extract Keywords from sentence or Replace keywords in sentences.

FlashText This module can be used to replace keywords in sentences or extract keywords from sentences. It is based on the FlashText algorithm. Install

Vikash Singh 4.7k Feb 17, 2021
Sentence boundary disambiguation tool for Japanese texts (日本語文境界判定器)

Bunkai Bunkai is a sentence boundary (SB) disambiguation tool for Japanese texts. Quick Start $ pip install bunkai $ echo -e '宿を予約しました♪!まだ2ヶ月も先だけど。早すぎ

Megagon Labs 160 Dec 23, 2022
SimCSE: Simple Contrastive Learning of Sentence Embeddings

SimCSE: Simple Contrastive Learning of Sentence Embeddings This repository contains the code and pre-trained models for our paper SimCSE: Simple Contr

Princeton Natural Language Processing 2.5k Jan 7, 2023
Language-Agnostic SEntence Representations

LASER Language-Agnostic SEntence Representations LASER is a library to calculate and use multilingual sentence embeddings. NEWS 2019/11/08 CCMatrix is

Facebook Research 3.2k Jan 4, 2023
Learning General Purpose Distributed Sentence Representations via Large Scale Multi-task Learning

GenSen Learning General Purpose Distributed Sentence Representations via Large Scale Multi-task Learning Sandeep Subramanian, Adam Trischler, Yoshua B

Maluuba Inc. 309 Oct 19, 2022
InferSent sentence embeddings

InferSent InferSent is a sentence embeddings method that provides semantic representations for English sentences. It is trained on natural language in

Facebook Research 2.2k Dec 27, 2022
source code for paper: WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach.

WhiteningBERT Source code and data for paper WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach. Preparation git clone https://github.com

null 49 Dec 17, 2022
Code for our ACL 2021 paper - ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer

ConSERT Code for our ACL 2021 paper - ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfer Requirements torch==1.6.0

Yan Yuanmeng 478 Dec 25, 2022
Cải thiện Elasticsearch trong bài toán semantic search sử dụng phương pháp Sentence Embeddings

Cải thiện Elasticsearch trong bài toán semantic search sử dụng phương pháp Sentence Embeddings Trong bài viết này mình sẽ sử dụng pretrain model SimCS

Vo Van Phuc 18 Nov 25, 2022
Shared code for training sentence embeddings with Flax / JAX

flax-sentence-embeddings This repository will be used to share code for the Flax / JAX community event to train sentence embeddings on 1B+ training pa

Nils Reimers 23 Dec 30, 2022
A Structured Self-attentive Sentence Embedding

Structured Self-attentive sentence embeddings Implementation for the paper A Structured Self-Attentive Sentence Embedding, which was published in ICLR

Kaushal Shetty 488 Nov 28, 2022
Korean Simple Contrastive Learning of Sentence Embeddings using SKT KoBERT and kakaobrain KorNLU dataset

KoSimCSE Korean Simple Contrastive Learning of Sentence Embeddings implementation using pytorch SimCSE Installation git clone https://github.com/BM-K/

null 34 Nov 24, 2022