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

WIP : support for hloc toolbox (superpoint, superglue, netvlad,...) #1026

Merged
merged 25 commits into from
Dec 4, 2022

Conversation

RandomPrototypes
Copy link
Contributor

This adds support for hloc which brings support for more recent features and matches such as superpoint and superglue.

I added command-line options to select the sfm toolbox (colmap, hloc), feature (sift, superpoint,...), and matcher (NN, superglue,...).

It requires hloc as dependency.

Copy link
Contributor

@tancik tancik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding support for hloc. My main comment atm is around notifying users how to install hloc if it is not included. We should also add documentation for these alternative matches in the web docs.

@RandomPrototypes
Copy link
Contributor Author

ok, I'll prepare a new version with these try/except for dependency, notification, and documentation update

@RandomPrototypes
Copy link
Contributor Author

I updated the PR :
hloc is now an optional dependency. If it is not installed, it will not cause any error except if we try to use a feature from it (superpoint, superglue,...), it will output a red error message : "Error: To use this set of parameters (superpoint_aachen/superglue/hloc), you must install hloc toolbox!!"

The documentation of ns-process-data has a new line "You may also want to install hloc for more feature detector and matcher options." with a link to the github page. The new cli arguments (sfm_tool, feature_type, matcher_type) have a description in the doc too.

Copy link
Contributor

@tancik tancik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Almost ready, just a few small additional comments.

scripts/process_data.py Outdated Show resolved Hide resolved
scripts/process_data.py Outdated Show resolved Hide resolved
scripts/process_data.py Outdated Show resolved Hide resolved
@@ -127,7 +103,7 @@ def main(self) -> None:
if not self.skip_colmap:
colmap_dir.mkdir(parents=True, exist_ok=True)

(sfm_tool, feature_type, matcher_type) = find_tool_feature_matcher_combination(
(sfm_tool, feature_type, matcher_type) = process_data_utils.find_tool_feature_matcher_combination(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you raise an error if no valid tool is found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_tool_feature_matcher_combination returns (None,None,None) when no valid tool is found, which brings to the message CONSOLE.log("[bold yellow]Warning: Invalid combination of sfm_tool, feature_type, and matcher_type ").

I'll add a sys.exit(1) after the message is printed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the message to "[bold red]Invalid combination of sfm_tool, feature_type, and matcher_type, exiting" and added sys.exit(1)

@@ -251,7 +227,7 @@ def main(self) -> None:
if not self.skip_colmap:
colmap_dir.mkdir(parents=True, exist_ok=True)

(sfm_tool, feature_type, matcher_type) = find_tool_feature_matcher_combination(
(sfm_tool, feature_type, matcher_type) = process_data_utils.find_tool_feature_matcher_combination(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as other message

Copy link
Contributor

@tancik tancik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks for adding this functionality! Sorry for the delayed reviews.

@tancik tancik merged commit 740cdeb into nerfstudio-project:main Dec 4, 2022
tancik pushed a commit to dozeri83/nerfstudio that referenced this pull request Jan 20, 2023
…erfstudio-project#1026)

* basic support for hloc (includes netvlad, super point, superglue in colmap), just a first test, not ready yet

* add exhaustive match option for hloc

* add command line option to choose the type of feature, matcher,...

* make hloc an optional dependency, update doc, and small bug fixes

* fix missing imports

* fix warnings, pylint,...

* fix overwrite previous commits

* fix import order from isort

* move find_tool_feature_matcher_combination to process_data_utils, add type hints and Args/Returns doc

* error message when no valid combination of sfm tool, feature type, and matcher

Co-authored-by: RandomPrototypes <delmotte_ar@yahoo.fr>
@Diana-Zeng
Copy link

When I use the command:
ns-process-data images --data /media/diana/001/c
--output /home/diana/NeRF/nerfstudio/selfdata/20230404/cc
--camera perspective
--matching vocab_tree
--sfm-tool hloc
--feature-type superpoint_aachen
--matcher-type superglue
--colmap-cmd /home/diana/COLMAP/colmap/build/src/exe/colmap

This error occurred:
scipy.io.matlab._miobase.MatReadError: Mat file appears to be empty.

These are complete information:
process_data_utils.py:363
[2023/04/10 18:58:47 hloc INFO] Extracting local features with configuration:
{'model': {'max_keypoints': 4096, 'name': 'superpoint', 'nms_radius': 3},
'output': 'feats-superpoint-n4096-r1024',
'preprocessing': {'grayscale': True, 'resize_max': 1024}}
[2023/04/10 18:58:47 hloc INFO] Skipping the extraction.
[2023/04/10 18:58:47 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'},
'output': 'global-feats-netvlad',
'preprocessing': {'resize_max': 1024}}
[2023/04/10 18:58:47 hloc INFO] Found 1440 images in root /home/diana/NeRF/nerfstudio/selfdata/20230404/cc/images.
Traceback (most recent call last):
File "/home/diana/anaconda3/envs/nerfstudio/bin/ns-process-data", line 8, in
sys.exit(entrypoint())
File "/home/diana/NeRF/nerfstudio/scripts/process_data.py", line 833, in entrypoint
tyro.cli(Commands).main()
File "/home/diana/NeRF/nerfstudio/scripts/process_data.py", line 165, in main
self._run_colmap(image_dir, colmap_dir)
File "/home/diana/NeRF/nerfstudio/scripts/process_data.py", line 231, in _run_colmap
hloc_utils.run_hloc(
File "/home/diana/NeRF/nerfstudio/nerfstudio/process_data/hloc_utils.py", line 110, in run_hloc
retrieval_path = extract_features.main(retrieval_conf, image_dir, outputs)
File "/home/diana/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/diana/Tools/Hierarchical-Localization/hloc/extract_features.py", line 251, in main
model = Model(conf['model']).eval().to(device)
File "/home/diana/Tools/Hierarchical-Localization/hloc/utils/base_model.py", line 17, in init
self._init(conf)
File "/home/diana/Tools/Hierarchical-Localization/hloc/extractors/netvlad.py", line 82, in _init
mat = loadmat(checkpoint, struct_as_record=False, squeeze_me=True)
File "/home/diana/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/scipy/io/matlab/_mio.py", line 225, in loadmat
MR, _ = mat_reader_factory(f, **kwargs)
File "/home/diana/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/scipy/io/matlab/_mio.py", line 74, in mat_reader_factory
mjv, mnv = _get_matfile_version(byte_stream)
File "/home/diana/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/scipy/io/matlab/_miobase.py", line 234, in _get_matfile_version
raise MatReadError("Mat file appears to be empty")
scipy.io.matlab._miobase.MatReadError: Mat file appears to be empty

Does anybody meet the same problem? Know the reason or know how to solve this? ? It is important and urgent for me!!! Thanks a lot!!!

chris838 pushed a commit to chris838/nerfstudio that referenced this pull request Apr 22, 2023
…erfstudio-project#1026)

* basic support for hloc (includes netvlad, super point, superglue in colmap), just a first test, not ready yet

* add exhaustive match option for hloc

* add command line option to choose the type of feature, matcher,...

* make hloc an optional dependency, update doc, and small bug fixes

* fix missing imports

* fix warnings, pylint,...

* fix overwrite previous commits

* fix import order from isort

* move find_tool_feature_matcher_combination to process_data_utils, add type hints and Args/Returns doc

* error message when no valid combination of sfm tool, feature type, and matcher

Co-authored-by: RandomPrototypes <delmotte_ar@yahoo.fr>
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

Successfully merging this pull request may close these issues.

None yet

4 participants