Code for "LoFTR: Detector-Free Local Feature Matching with Transformers", CVPR 2021

Overview

LoFTR: Detector-Free Local Feature Matching with Transformers

Project Page | Paper


LoFTR: Detector-Free Local Feature Matching with Transformers
Jiaming Sun*, Zehong Shen*, Yu'ang Wang*, Hujun Bao, Xiaowei Zhou
CVPR 2021

demo_vid


Code release ETA

We plan to release the inference-only code and pretrained model within the upcoming week, stay tuned. The entire codebase for data pre-processing, training and validation is under major refactoring and will be released around June. Please subscribe to this discussion thread if you wish to be notified of the code release. In the meanwhile, discussions about the paper are welcomed in the discussion panel.

Citation

If you find this code useful for your research, please use the following BibTeX entry.

@article{sun2021loftr,
  title={{LoFTR}: Detector-Free Local Feature Matching with Transformers},
  author={Sun, Jiaming and Shen, Zehong and Wang, Yuang and Bao, Hujun and Zhou, Xiaowei},
  journal={CVPR},
  year={2021}
}

Copyright

This work is affiliated with ZJU-SenseTime Joint Lab of 3D Vision, and its intellectual property belongs to SenseTime Group Ltd.

Copyright SenseTime. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Megadepth results

    Megadepth results

    Hi, I met a gap between val and test in Medadepth dataset. I recently use 4 gpus to train the model for 15 epochs. The map(@20) is 0.766 on val_list and 0.720 on test_list. I want to know if it is normal?

    opened by zwyking 12
  • Unable to reproduce inference results

    Unable to reproduce inference results

    Hi,

    First I'd like to sincerely thank the author for sharing this amazing work. When I tried the provided colab with default setting (indoor), the resulting plot was quite poor. Screenshot 2021-08-16 185650

    Similar problem occurred when I cloned the repo and tested on both indoor and outdoor pairs on indoor_ds.ckpt and outdoor_ds.ckpt

    Can anyone advise on this? Thank you very much!

    opened by howard5758 11
  • the problem during training

    the problem during training

    Thank you for your amazing work. I have some question that the expec_f_gt after spvs_fine() function are all very large number. And this case cause the correct_mask in computing fine loss is zero.

    opened by xiezhiqing0112 11
  • About test evaluation content

    About test evaluation content

    In your paper, the evaluation comparison demonstrated includes the accuracy of the prediction. But I opened loftr_ pred_ eval. NPY found that the only content in it was' pair name '', identifier '', mconf '', mkpts1f '', mkpts0f '', EPI '', R '', tT'', inliers'。 How to show the prediction accurac? P3%S O(4OWH2ZLUZ$@5(M EC)O7(P$N~BPQ PQ(IILJDD y

    opened by FujiwaraZayako 10
  • memory consumption exceeds 80gb!!

    memory consumption exceeds 80gb!!

    I have tried matching 2 (2000*2000) images. It took around 80 gb memory for finding 17k matched keypoints. Attached the screenshot.. Screenshot from 2021-11-05 12-38-06 was that normal?

    opened by sanjaypavo 10
  • Questions on training

    Questions on training

    Hi, thanks for your great work. I tried to reproduce the training code, and then I met some problems:

    1. I tried to set match threshold to 0.2 without loading pretrained model, and I found there will be 0 matches from coarse mathcing layer.
    2. If I load the pretrained model to train, the Loss_coarse would go up while Loss_fine going down, and as training time goes on, the num of points from coarse matching layer reduces to 0.
    3. Should I use gradient clipping?
    opened by Devoe-97 9
  • Reproduce Visual Localization Work

    Reproduce Visual Localization Work

    Thanks for amazing work! About the reproduction for the visual localization work with hloc, I have some confusions. As for my understanding, loftr will give a match result include local keypoints0, local keypoint1 and their matching confidence although the matching process is "local features" free. So the local key point locations are concerned with the image pairs. Different image pairs may produce different keypoints. Like pair (image a, image b) and pair (image a, image c) may result totally different keypoints distribution on image a. During the sfm procedure in hloc,, triangluation process requires long keypoints tracks to ensure the 3D points' quality. So how to handle this situation while different keyframe pairs produce variance keypoints for one keyframe.
    Is there any strategy or principle to combine the keypoints which are close distributed?

    opened by Zhongyuan-Li 9
  • Regarding information required to be able to train on custom dataset

    Regarding information required to be able to train on custom dataset

    What exactly would I need to provide to be able to train LoFTR on a custom dataset? It was pointed out in some of the previous issues that all one would need would be depth map, extrinsics and intrinsics for every image and the ground truth is generated on the fly.

    The npz files seem to have fields - 'image_paths', 'depth_paths', 'intrinsics', 'poses', 'pair_infos'. Assuming 'poses' is just the extrinsics (R | t), how exactly is 'pair_infos' generated and how are the covisibility scores calculated?

    opened by amanshenoy 8
  • Question on bordering operation in CoarseMatching

    Question on bordering operation in CoarseMatching

    Hi, thanks for the fabulous work!

    I was looking for works leveraging dense feature matching operations and ended up in this repository. I am new to the feature matching task, so please be patient with me :)

    1. What is the purpose of bordering the matching mask? (The mask_border() function)

    2. In the function, does indexing [..-b:0..] apply borders on any portion of tensors? If it is intended, I don't get the purpose of it.

    Thanks!

    opened by codeslake 7
  • a simple question about saving npzfile

    a simple question about saving npzfile

    Hi, I have tried to use np.savez_compressed() to save the npz and read data from the npz I created, it still is NpzFile object, not dict object. this issue

    opened by Devoe-97 6
  • Update for the trained weights ?

    Update for the trained weights ?

    Hello, Thank you for the great works.

    I have tried to use your method for outdoor images. However, after bug fixing, it seems that the weight "outdoor_ds.ckpt" is not working as good as it used to be... Therefore, could you please provide the update for the "outdoor_ds.ckpt" as well?

    opened by GabbySuwichaya 6
  • Colab Weights downloading doesnt work

    Colab Weights downloading doesnt work

    There seems to be some error when downloading the weights:

    FileNotFoundError                         Traceback (most recent call last)
    [<ipython-input-29-011ecbd77aeb>](https://localhost:8080/#) in <module>
          6   matcher.load_state_dict(torch.load("weights/indoor_ds.ckpt")['state_dict'])
          7 elif image_type == 'outdoor':
    ----> 8   matcher.load_state_dict(torch.load("weights/outdoor_ds.ckpt")['state_dict'])
          9 else:
         10   raise ValueError("Wrong image_type is given.")
    
    2 frames
    [/usr/local/lib/python3.8/dist-packages/torch/serialization.py](https://localhost:8080/#) in __init__(self, name, mode)
        249 class _open_file(_opener):
        250     def __init__(self, name, mode):
    --> 251         super(_open_file, self).__init__(open(name, mode))
        252 
        253     def __exit__(self, *args):
    
    FileNotFoundError: [Errno 2] No such file or directory: 'weights/outdoor_ds.ckpt'
    
    opened by geoeo 4
  • Extract feature and key points using the demo

    Extract feature and key points using the demo

    I want to extract the key points and corresponding feature vector using the demo. My question is the following, how can you do it using the notebook demo. I know perhaps keypoints are returned in the dictionary ( mkpts0 = batch['mkpts0_f'].cpu().numpy() mkpts1 = batch['mkpts1_f'].cpu().numpy()).

    How can I get the correponding feature vector. Perhaps in loftr.py these (feat_f0_unfold, feat_f1_unfold) are corresponding feature vectors ? could you please guide me.

    I am someone who is new to the field, so excuse me if the questions are super obvious.

    opened by tinaplus 0
  • Quantifying the LoFTR

    Quantifying the LoFTR

    Greetings there!

    I want to calculate a similarity score between two images (i.e. as we calculate the cosine similarity). So that an image can be said x percentage similar to another image. A score with a fixed range i.e. may be -1 to 1 or 0 to 1. Is there any way to calculate such a score?

    opened by HarshitBardana 2
  • KeyError: 'spv_b_ids'

    KeyError: 'spv_b_ids'

    Hello,

    I am trying to train the LoFTR model and run into KeyError: 'spv_b_ids'. On other Github issues, I saw that LoFTR to be used in eval() mode, however, I want to train the LoFTR model. What's the appropriate solution?

    Thank you.

    opened by yash0307 0
Owner
ZJU3DV
ZJU3DV is a research group of State Key Lab of CAD&CG, Zhejiang University. We focus on the research of 3D computer vision, SLAM and AR.
ZJU3DV
git git《Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking》(CVPR 2021) GitHub:git2] 《Masksembles for Uncertainty Estimation》(CVPR 2021) GitHub:git3]

Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking Ning Wang, Wengang Zhou, Jie Wang, and Houqiang Li Accepted by CVPR

NingWang 236 Dec 22, 2022
[CVPR 21] Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021.

Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, CVPR 2021. Ayan Kumar Bhunia, Pinaki nath Chowdhury, Yongxin Yan

Ayan Kumar Bhunia 44 Dec 12, 2022
[CVPR 2022] CoTTA Code for our CVPR 2022 paper Continual Test-Time Domain Adaptation

CoTTA Code for our CVPR 2022 paper Continual Test-Time Domain Adaptation Prerequisite Please create and activate the following conda envrionment. To r

Qin Wang 87 Jan 8, 2023
[CVPR 2021] Released code for Counterfactual Zero-Shot and Open-Set Visual Recognition

Counterfactual Zero-Shot and Open-Set Visual Recognition This project provides implementations for our CVPR 2021 paper Counterfactual Zero-S

null 144 Dec 24, 2022
Code for Multiple Instance Active Learning for Object Detection, CVPR 2021

Language: 简体中文 | English Introduction This is the code for Multiple Instance Active Learning for Object Detection, CVPR 2021. Installation A Linux pla

Tianning Yuan 269 Dec 21, 2022
Code for our CVPR 2021 paper "MetaCam+DSCE"

Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-Identification (CVPR'21) Introduction Code for our CVPR 2021

FlyingRoastDuck 59 Oct 31, 2022
Official code of the paper "ReDet: A Rotation-equivariant Detector for Aerial Object Detection" (CVPR 2021)

ReDet: A Rotation-equivariant Detector for Aerial Object Detection ReDet: A Rotation-equivariant Detector for Aerial Object Detection (CVPR2021), Jiam

csuhan 334 Dec 23, 2022
Code for "Neural Parts: Learning Expressive 3D Shape Abstractions with Invertible Neural Networks", CVPR 2021

Neural Parts: Learning Expressive 3D Shape Abstractions with Invertible Neural Networks This repository contains the code that accompanies our CVPR 20

Despoina Paschalidou 161 Dec 20, 2022
Code for Multiple Instance Active Learning for Object Detection, CVPR 2021

MI-AOD Language: 简体中文 | English Introduction This is the code for Multiple Instance Active Learning for Object Detection (The PDF is not available tem

Tianning Yuan 269 Dec 21, 2022
Official code for the paper: Deep Graph Matching under Quadratic Constraint (CVPR 2021)

QC-DGM This is the official PyTorch implementation and models for our CVPR 2021 paper: Deep Graph Matching under Quadratic Constraint. It also contain

Quankai Gao 55 Nov 14, 2022
Code for CVPR 2021 paper: Anchor-Free Person Search

Introduction This is the implementationn for Anchor-Free Person Search in CVPR2021 License This project is released under the Apache 2.0 license. Inst

null 158 Jan 4, 2023
Code of paper "CDFI: Compression-Driven Network Design for Frame Interpolation", CVPR 2021

CDFI (Compression-Driven-Frame-Interpolation) [Paper] (Coming soon...) | [arXiv] Tianyu Ding*, Luming Liang*, Zhihui Zhu, Ilya Zharkov IEEE Conference

Tianyu Ding 95 Dec 4, 2022
Code release for "Transferable Semantic Augmentation for Domain Adaptation" (CVPR 2021)

Transferable Semantic Augmentation for Domain Adaptation Code release for "Transferable Semantic Augmentation for Domain Adaptation" (CVPR 2021) Paper

null 66 Dec 16, 2022
Code for "NeuralRecon: Real-Time Coherent 3D Reconstruction from Monocular Video", CVPR 2021 oral

NeuralRecon: Real-Time Coherent 3D Reconstruction from Monocular Video Project Page | Paper NeuralRecon: Real-Time Coherent 3D Reconstruction from Mon

ZJU3DV 1.4k Dec 30, 2022
Official PyTorch Code of GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Monocular 3D Object Detection (CVPR 2021)

GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Monocular 3D Object Detection GrooMeD-NMS: Grouped Mathematically Differentiable NMS for Mo

Abhinav Kumar 76 Jan 2, 2023
Official code for the CVPR 2021 paper "How Well Do Self-Supervised Models Transfer?"

How Well Do Self-Supervised Models Transfer? This repository hosts the code for the experiments in the CVPR 2021 paper How Well Do Self-Supervised Mod

Linus Ericsson 157 Dec 16, 2022
Demo code for paper "Learning optical flow from still images", CVPR 2021.

Depthstillation Demo code for "Learning optical flow from still images", CVPR 2021. [Project page] - [Paper] - [Supplementary] This code is provided t

null 130 Dec 25, 2022
Official PyTorch code of Holistic 3D Scene Understanding from a Single Image with Implicit Representation (CVPR 2021)

Implicit3DUnderstanding (Im3D) [Project Page] Holistic 3D Scene Understanding from a Single Image with Implicit Representation Cheng Zhang, Zhaopeng C

Cheng Zhang 149 Jan 8, 2023
Official code of CVPR 2021's PLOP: Learning without Forgetting for Continual Semantic Segmentation

PLOP: Learning without Forgetting for Continual Semantic Segmentation This repository contains all of our code. It is a modified version of Cermelli e

Arthur Douillard 116 Dec 14, 2022