8000 Warn user when reading legacy flann index by ahojnnes · Pull Request #3372 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Warn user when reading legacy flann index #3372

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

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/colmap/exe/colmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ int main(int argc, char** argv) {
commands.emplace_back("vocab_tree_builder", &colmap::RunVocabTreeBuilder);
commands.emplace_back("vocab_tree_matcher", &colmap::RunVocabTreeMatcher);
commands.emplace_back("vocab_tree_retriever", &colmap::RunVocabTreeRetriever);
commands.emplace_back("vocab_tree_upgrader", &colmap::RunVocabTreeUpgrader);

if (argc == 1) {
return ShowHelp(commands);
Expand Down
16 changes: 0 additions & 16 deletions src/colmap/exe/vocab_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,4 @@ int RunVocabTreeRetriever(int argc, char** argv) {
return EXIT_SUCCESS;
}

int RunVocabTreeUpgrader(int argc, char** argv) {
std::string input_path;
std::string output_path;

OptionManager options;
options.AddRequiredOption("input_path", &input_path);
options.AddRequiredOption("output_path", &output_path);
options.Parse(argc, argv);

std::unique_ptr<retrieval::VisualIndex> index =
retrieval::VisualIndex::Read(input_path);
index->Write(output_path);

return EXIT_SUCCESS;
}

} // namespace colmap
1 change: 0 additions & 1 deletion src/colmap/exe/vocab_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ namespace colmap {

int RunVocabTreeBuilder(int argc, char** argv);
int RunVocabTreeRetriever(int argc, char** argv);
int RunVocabTreeUpgrader(int argc, char** argv);

} // namespace colmap
18 changes: 15 additions & 3 deletions src/colmap/retrieval/visual_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ class FaissVisualIndex : public VisualIndex {
#endif
THROW_CHECK_NOTNULL(fin);
fseek(fin, offset, SEEK_SET);
index_ = std::unique_ptr<faiss::IndexIVF>(
dynamic_cast<faiss::IndexIVF*>(faiss::read_index(fin)));
index_ = std::unique_ptr<faiss::IndexIVF>(dynamic_cast<faiss::IndexIVF*>(
THROW_CHECK_NOTNULL(faiss::read_index(fin))));
offset = ftell(fin);
fclose(fin);

Expand Down Expand Up @@ -656,7 +656,19 @@ std::unique_ptr<VisualIndex> VisualIndex::Read(

int file_version = 0;
file.read(reinterpret_cast<char*>(&file_version), sizeof(int));
THROW_CHECK_EQ(file_version, 1);

// For a legacy flann-based index, the first int in the file defined the
// number of visual words. We now encode a file version in the first int.
// We detect legacy indices based on a file version mismatch, which works
// as long as we do not increment the file version beyond the count of
// visual words in a legacy file (which we do not expect to happen).
THROW_CHECK_EQ(file_version, 1)
<< "Failed to read faiss index. This may be caused by reading a legacy "
"flann-based index, because COLMAP switched from flann to faiss in "
"May 2025. If you want to upgrade your existing flann-based index "
"to faiss, you can check out COLMAP commit "
"c7a58462b813e406c304a9dafb475b87036924cf and apply the "
"vocab_tree_upgrader command.";

int desc_dim = 0;
file.read(reinterpret_cast<char*>(&desc_dim), sizeof(int));
Expand Down
Loading
0