Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doppelgangers support #308

Open
awarebayes opened this issue Sep 19, 2023 · 5 comments
Open

Doppelgangers support #308

awarebayes opened this issue Sep 19, 2023 · 5 comments

Comments

@awarebayes
Copy link

There is a repository, which aims to avoid incorrect image registration called 'Doppelgangers': link.
Implementing it into the pipeline should be straightforward, since it is a binary classifier, also I am currently working on it.

My pipeline is the following:

  1. netvlad
  2. pairs from retrieval
  3. feature extractor (superglue)
  4. feature matcher (lightglue)
  5. !!!! Doppelgangers for each feature pair generates probability that they are a correct match
  6. for pairs with probability < thresh delete them from matches.hdf5
  7. run sfm
  8. ??? profit

This issue is for mainly tracking pull request, as well, as maybe some help I will need along the way

@sarlinpe
Copy link
Member

Yes we already looked into this - it looks very promising. After discussing with the author @RuojinCai and experiments by @veichta, it looks like the model might not generalize well to types of matches (especially sparse matches) that are different than it was trained on (dense LoFTR). If someone can train a new model for DISK/SP+LightGlue (or, better, that generalizes to any sparse matches), then I'd be happy to integrate it (and add it to COLMAP down the road).

For the integration, I see two alternate designs:

  1. Create a new step that takes feature and match files and outputs a new match file from which incorrect image pairs are removed.
python -m hloc.remove_flase_pairs --features path/to/features.h5 --matches path/to/matches.h5 --output path/to/cleaned_matches.h5
  1. Create a new step that adds a doppelganger_score attribute to each image pair group in the match file:
python -m hloc.add_doppelganger_score --features path/to/features.h5 --matches path/to/matches.h5

And skip importing pairs with doppelganger_score < threshold in hloc.triangulation.import_matches.

Design 2. makes it easier to run the reconstruction with different thresholds without running the doppelganger network again, but it is more invasive - so I'd go for 1. for now.

cc @Phil26AT

@awarebayes
Copy link
Author

The doppelganger score is very weird, it's just logits of size (2,), and not probabilities. We can of course softmax them

@awarebayes
Copy link
Author

Here is what I ended up doing:
https://github.com/awarebayes/doppelgangers-hloc#usage-with-hloc

I need some more data from hloc, in my matches.h5, I created a merge request: #309

I tested it with lightglue, somewhat works. Interesting remarks about superpoint+lightglue.

As for the final stage, I overwrite matches.h5 directly and delele 'bad' pairs: https://github.com/awarebayes/doppelgangers-hloc/blob/main/doppelgangers/utils/overwrite_hloc.py#L8

I believe it is possible to train doppelgangers since the architecture is a very simple CNN, and dataset is public and not really large.

@awarebayes
Copy link
Author

And here is how I use HLOC matches and features to load the data: https://github.com/awarebayes/doppelgangers-hloc/blob/main/doppelgangers/datasets/hloc_dataset.py

@awarebayes
Copy link
Author

I will try to train doppelgangers with superpoint + lightglue today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants