Doppelgangers
Doppelgangers: Learning to Disambiguate Images of Similar Structures
Install / Use
/learn @RuojinCai/DoppelgangersREADME
Doppelgangers: Learning to Disambiguate Images of Similar Structures
Ruojin Cai<sup>1</sup>, Joseph Tung<sup>1</sup>, Qianqian Wang<sup>1</sup>, Hadar Averbuch-Elor<sup>2</sup>, Bharath Hariharan<sup>1</sup>, Noah Snavely<sup>1</sup> <br> <sup>1</sup>Cornell University, <sup>2</sup>Tel Aviv University <br> ICCV 2023 Oral
Project Page | Paper | Arxiv | Dataset
<p float="left"> <img src="assets/teaser_video.gif" height="320"/> </p>Implementation for paper "Doppelgangers: Learning to Disambiguate Images of Similar Structures", which proposes a learning-based approach to disambiguate distinct yet visually similar image pairs (doppelgangers) and applies it to structure-from-motion disambiguation.
Dependencies
- Create Conda environment with Python 3.8, PyTorch 1.12.0, and CUDA 10.2 using the following commands:
conda env create -f ./environment.yml
conda activate doppelgangers
- Download Colmap from their installation page (version 3.8+).
Pretrained Model
-
Pretrained model is available in the following link. To use the pretrained models, download the
<details> <summary>[Click to expand]</summary>checkpoint.tar.gzfile, unzip and putdoppelgangers_classifier_loftr.ptunder./weights/folder.
</details>cd weights/ wget -c https://doppelgangers.cs.cornell.edu/dataset/checkpoint.tar.gz tar -xf checkpoint.tar.gz mv doppelgangers/checkpoints/doppelgangers_classifier_loftr.pt ./ rm checkpoint.tar.gz rm -r doppelgangers/ -
We use LoFTR models for feature matching. Please download the LoFTR outdoor checkpoint
outdoor_ds.ckptin the following Google Drive link, and put it under./weights/folder.
Dataset
This section contains download links for several helpful datasets:
- SfM Disambiguation: Download the Structure from Motion disambigaution Dataset from the SfM disambiguation with COLMAP GitHub repository. Unzip the file under folder
./data/sfm_disambiguation/. - Pairwise Visual Disambiguation: Download the Doppelgangers Dataset by following these instructions and put the dataset under folder
./data/doppelgangers_dataset/.
SfM Disambiguation
Overview of applying Doppelgangers classifier to SfM disambiguation with COLMAP
- We begin by performing COLMAP feature extraction and matching, which generates a list of image pairs.
- Next, we run Doppelgangers classifiers on these image pairs, with LoFTR matches as input.
- We then remove image pairs from the COLMAP database if they have a predicted probability below the specified threshold. These pairs are more likely to be Doppelgangers.
- Finally, we perform COLMAP reconstruction with the pruned database.
Demo
We provide a demo on the Cup dataset to demonstrate how to use our Doppelgangers classifier in Structure from Motion disambiguation with COLMAP: ./notebook/demo_sfm_disambiguation.ipynb.
Script
We provide a script for SfM disambiguation. The COLMAP reconstruction with Doppelgangers classifier can be found at [output_path]/sparse_doppelgangers_[threshold]/.
# Usage:
# python script_sfm_disambiguation.py [path/to/example_config] --input_image_path [path/to/dataset] --output_path [path/to/output]
python script_sfm_disambiguation.py doppelgangers/configs/test_configs/sfm_disambiguation_example.yaml \
--colmap_exe_command colmap \
--input_image_path data/sfm_disambiguation/yan2017/cup/images \
--output_path results/cup/ \
--threshold 0.8 \
--pretrained weights/doppelgangers_classifier_loftr.pt
<details>
<summary>Details of the Arguments: [Click to expand]</summary>
-
To apply the Doppelgangers classifier on custom datasets, change the argument
--input_image_path [path/to/dataset]to the dataset path accordingly, and set the path for output results using the argument--output_path [path/to/output]. -
If you have already completed COLMAP feature extraction and matching stage, you can skip this stage with the
<details> <summary>Example [Click to expand]</summary>--skip_feature_matchingargument, and specify the path todatabase.dbfile using the argument--database_path [path/to/database.db].
</details>python script_sfm_disambiguation.py doppelgangers/configs/test_configs/sfm_disambiguation_example.yaml \ --colmap_exe_command colmap \ --input_image_path data/sfm_disambiguation/yan2017/cup/images \ --output_path results/cup/ \ --skip_feature_matching \ --database_path results/cup/database.db -
Use the argument
--skip_reconstructionto skip the standard COLMAP reconstruction w/o Doppelgangers classifier. -
Change doppelgangers threshold with argument
--thresholdand specify a value between 0 and 1. A smaller threshold includes more pairs, while a larger threshold filters out more pairs. The default threshold is set to 0.8. When the reconstruction is split into several components, consider using a smaller threshold. If the reconstruction is not completely disambiguated, consider using a larger threshold. -
Pretrained model can be specified by the argument
--pretrained [path/to/checkpoint].
Reconstruction Results
COLMAP reconstructions of test scenes with and without the Doppelgangers classifier, as described in the paper: reconstructions.tar.gz (3G)
These reconstructions can be imported and visualized in the COLMAP GUI.
Pairwise Visual Disambiguation
Method overview

(a) Given a pair of images, we extract keypoints and matches via feature matching methods. Note that this is a negative (doppelganger) pair picturing opposite sides of the Arc de Triomphe. The feature matches are primarily in the top part of the structure, where there are repeated elements, as opposed to the sculptures on the bottom part. (b) We create binary masks of keypoints and matches. We then align the image pair and masks with an affine transformation estimated from matches. (c) Our classifier takes the concatenation of the images and binary masks as input and outputs the probability that the given pair is positive.
Testing the pretrained model
# Usage:
# python test.py [path/to/config] --pretrained [path/to/checkpoint]
python test.py doppelgangers/configs/training_configs/doppelgangers_classifier_noflip.yaml \
--pretrained weights/doppelgangers_classifier_loftr.pt
Training
# Usage:
# python train.py [path/to/config]
# python train_multi_gpu.py [path/to/config]
python train.py doppelgangers/configs/training_configs/doppelgangers_classifier_noflip.yaml
# training with multiple gpus on Doppelgangers dataset with image flip augmentation
python train_multi_gpu.py doppelgangers/configs/training_configs/doppelgangers_classifier_flip.yaml
Citation
@inproceedings{cai2023doppelgangers,
title = {Doppelgangers: Learning to Disambiguate Images of Similar Structures},
author = {Cai, Ruojin and Tung, Joseph and Wang, Qianqian and Averbuch-Elor, Hadar and Hariharan, Bharath and Snavely, Noah},
journal = {ICCV},
year = {2023}
}
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
best-practices-researcher
The most comprehensive Claude Code skills registry | Web Search: https://skills-registry-web.vercel.app
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
isf-agent
a repo for an agent that helps researchers apply for isf funding
