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

lamar.tasks.pose_estimation | RecursionError: maximum recursion depth exceeded while calling a Python object #18

Closed
sohee-zoe opened this issue Jan 19, 2023 · 2 comments

Comments

@sohee-zoe
Copy link

sohee-zoe commented Jan 19, 2023

Run the single-frame evaluation

python -m lamar.run \
	--scene CAB --ref_id map --query_id query_val_phone \
	--retrieval fusion --feature superpoint --matcher superglue
[2023/01/18 19:50:03 scantools INFO] Loading Capture from /data/project/lamar-benchmark/data/CAB.
[2023/01/18 19:50:29 lamar.tasks.feature_extraction INFO] Extraction local features superpoint for session map.
[2023/01/18 19:50:29 hloc INFO] Extracting local features with configuration:
{'model': {'max_keypoints': 2048, 'name': 'superpoint', 'nms_radius': 3},
 'preprocessing': {'grayscale': True, 'resize_max': 1024}}
Loaded SuperPoint model
100%|████████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [06:18<00:00, 88.79it/s]
[2023/01/18 19:56:49 hloc INFO] Finished exporting features.
[2023/01/18 19:56:49 lamar.tasks.pair_selection INFO] Selecting image pairs with fusion-netvlad-ap-gem-10_frustum_pose-120-20-250 for sessions (map, map).
[2023/01/18 19:57:02 lamar.tasks.pair_selection INFO] Filtering pairs by frustums.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 49/49 [02:08<00:00,  2.61s/it]
[2023/01/18 19:59:13 lamar.tasks.pair_selection INFO] Filtering pairs by poses.
100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:40<00:00,  4.55s/it]
[2023/01/18 19:59:56 lamar.tasks.pair_selection INFO] Computing pairs from visual similarity.
[2023/01/18 19:59:56 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/01/18 19:59:56 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
100%|████████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [09:24<00:00, 59.46it/s]
[2023/01/18 20:09:26 hloc INFO] Finished exporting features.
[2023/01/18 20:09:26 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/01/18 20:09:26 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
[2023/01/18 20:09:37 hloc INFO] Skipping the extraction.
[2023/01/18 20:09:49 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/01/18 20:09:49 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
/.virtualenvs/lamar-benchmark-ScoJAjWC/lib/python3.8/site-packages/sklearn/base.py:288: UserWarning: Trying to unpickle estimator PCA from version 0.20.2 when using version 1.2.0. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/model_persistence.html#security-maintainability-limitations
  warnings.warn(
=> loading checkpoint '/.cache/torch/hub/dirtorch/Resnet-101-AP-GeM.pt' (current_iter 296)
100%|████████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [20:00<00:00, 27.97it/s]
[2023/01/18 20:29:53 hloc INFO] Finished exporting features.
[2023/01/18 20:29:53 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/01/18 20:29:53 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
[2023/01/18 20:30:03 hloc INFO] Skipping the extraction.
[2023/01/18 20:30:40 lamar.tasks.feature_matching INFO] Matching local features with superglue for sessions (map, map).
[2023/01/18 20:30:40 lamar.tasks.feature_matching WARNING] Existing matches will be overwritten.
[2023/01/18 20:30:40 hloc INFO] Matching local features with configuration:
{'model': {'name': 'superglue', 'sinkhorn_iterations': 5, 'weights': 'outdoor'}}
Loaded SuperGlue model ("outdoor" weights)
100%|████████████████████████████████████████████████████████████████████████████████████████| 220298/220298 [1:45:55<00:00, 34.67it/s]
[2023/01/18 22:16:35 hloc INFO] Finished exporting matches.
[2023/01/18 22:16:35 lamar.tasks.mapping INFO] Mapping session map via triangulation of features superpoint.
[2023/01/18 22:16:38 scantools INFO] Writing COLMAP empty .bin reconstruction to /data/project/lamar-benchmark/outputs/CAB/mapping/map/triangulation/superpoint/fusion-netvlad-ap-gem-10_frustum_pose-120-20-250/superglue/sfm_empty.
[2023/01/18 22:16:42 hloc INFO] Importing features into the database...
100%|██████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [00:16<00:00, 2042.11it/s]
[2023/01/18 22:17:00 hloc INFO] Importing matches into the database...
100%|████████████████████████████████████████████████████████████████████████████████████████| 335870/335870 [02:19<00:00, 2408.33it/s]
[2023/01/18 22:19:22 hloc INFO] Performing geometric verification of the matches...
100%|████████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [12:07<00:00, 46.19it/s]
[2023/01/18 22:31:30 hloc INFO] mean/med/min/max valid matches 77.72/93.44/0.00/100.00%.
[2023/01/18 22:31:31 hloc INFO] Running 3D triangulation...
[2023/01/18 22:42:35 hloc INFO] Finished the triangulation with statistics:
Reconstruction:
        num_reg_images = 33587
        num_cameras = 6799
        num_points3D = 1931307
        num_observations = 10029980
        mean_track_length = 5.19336
        mean_observations_per_image = 298.627
        mean_reprojection_error = 1.52069
[2023/01/18 22:42:37 lamar.tasks.feature_extraction INFO] Extraction local features superpoint for session query_val_phone.
[2023/01/18 22:42:37 hloc INFO] Extracting local features with configuration:
{'model': {'max_keypoints': 2048, 'name': 'superpoint', 'nms_radius': 3},
 'preprocessing': {'grayscale': True, 'resize_max': 1024}}
Loaded SuperPoint model
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 396/396 [00:14<00:00, 27.14it/s]
[2023/01/18 22:42:52 hloc INFO] Finished exporting features.
[2023/01/18 22:42:52 lamar.tasks.pair_selection INFO] Selecting image pairs with fusion-netvlad-ap-gem-10 for sessions (query_val_phone, map).
[2023/01/18 22:42:52 lamar.tasks.pair_selection INFO] Computing pairs from visual similarity.
[2023/01/18 22:42:52 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session query_val_phone.
[2023/01/18 22:42:52 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 396/396 [00:13<00:00, 30.41it/s]
[2023/01/18 22:43:09 hloc INFO] Finished exporting features.
[2023/01/18 22:43:09 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/01/18 22:43:09 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
[2023/01/18 22:43:20 hloc INFO] Skipping the extraction.
[2023/01/18 22:43:27 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session query_val_phone.
[2023/01/18 22:43:27 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
=> loading checkpoint '/.cache/torch/hub/dirtorch/Resnet-101-AP-GeM.pt' (current_iter 296)
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 396/396 [00:26<00:00, 14.98it/s]
[2023/01/18 22:43:54 hloc INFO] Finished exporting features.
[2023/01/18 22:43:54 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/01/18 22:43:54 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
[2023/01/18 22:44:05 hloc INFO] Skipping the extraction.
[2023/01/18 22:44:11 lamar.tasks.feature_matching INFO] Matching local features with superglue for sessions (query_val_phone, map).
[2023/01/18 22:44:11 lamar.tasks.feature_matching WARNING] Existing matches will be overwritten.
[2023/01/18 22:44:11 hloc INFO] Matching local features with configuration:
{'model': {'name': 'superglue', 'sinkhorn_iterations': 5, 'weights': 'outdoor'}}
Loaded SuperGlue model ("outdoor" weights)
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 3960/3960 [01:53<00:00, 34.99it/s]
[2023/01/18 22:46:05 hloc INFO] Finished exporting matches.
[2023/01/18 22:46:05 lamar.tasks.pose_estimation INFO] Localizing (single_image) session query_val_phone with features superpoint.
  0%|                                                                                                          | 0/396 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/data/project/lamar-benchmark/lamar/run.py", line 154, in <module>
    results_ = run(**args)
  File "/data/project/lamar-benchmark/lamar/run.py", line 120, in run
    pose_estimation = PoseEstimation(
  File "/data/project/lamar-benchmark/lamar/tasks/pose_estimation.py", line 109, in __init__
    self.poses = self.run(capture)
  File "/data/project/lamar-benchmark/lamar/tasks/pose_estimation.py", line 177, in run
    map_(_worker_fn, range(len(keys)))
  File "/.virtualenvs/lamar-benchmark-ScoJAjWC/lib/python3.8/site-packages/tqdm/contrib/concurrent.py", line 94, in thread_map
    return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
  File "/.virtualenvs/lamar-benchmark-ScoJAjWC/lib/python3.8/site-packages/tqdm/contrib/concurrent.py", line 76, in _executor_map
    return list(tqdm_class(ex.map(fn, *iterables, **map_args), **kwargs))
  File "/.virtualenvs/lamar-benchmark-ScoJAjWC/lib/python3.8/site-packages/tqdm/std.py", line 1195, in __iter__
    for obj in iterable:
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/project/lamar-benchmark/lamar/tasks/pose_estimation.py", line 165, in _worker_fn
    pose, _ = estimate_camera_pose(
  File "/data/project/lamar-benchmark/lamar/utils/localization.py", line 69, in estimate_camera_pose
    matches_2d3d = recover_matches(query, ref_key_names)
  File "/data/project/lamar-benchmark/lamar/tasks/pose_estimation.py", line 119, in recover_matches_2d3d
    return recover_matches_2d3d(
  File "/data/project/lamar-benchmark/lamar/utils/localization.py", line 35, in recover_matches_2d3d
    valid, p3ds, p3d_ids = mapping.get_points3D(ref_key, matches[:, 1])
  File "/data/project/lamar-benchmark/lamar/tasks/mapping.py", line 114, in get_points3D
    if len(image.points2D) > 0:
RecursionError: maximum recursion depth exceeded while calling a Python object

i added bellow code, but segmentation fault (core dumped) occurs.

import sys
sys.setrecursionlimit(10**6)

pip list

Package                  Version     Editable project location
------------------------ ----------- ------------------------------------------------
addict                   2.4.0
astroid                  2.5
asttokens                2.2.1
attrs                    22.2.0
autopep8                 2.0.1
backcall                 0.2.0
beautifulsoup4           4.11.1
certifi                  2022.12.7
charset-normalizer       3.0.1
click                    8.1.3
comm                     0.1.2
ConfigArgParse           1.5.3
contourpy                1.0.7
coverage                 7.0.5
cycler                   0.11.0
dash                     2.7.1
dash-core-components     2.0.0
dash-html-components     2.0.0
dash-table               5.0.0
debugpy                  1.6.5
decorator                5.1.1
entrypoints              0.4
exceptiongroup           1.1.0
executing                1.2.0
fastjsonschema           2.16.2
filelock                 3.9.0
Flask                    2.2.2
fonttools                4.38.0
gdown                    4.6.0
h5py                     3.7.0
hloc                     1.3         /data/project/Hierarchical-Localization
idna                     3.4
importlib-metadata       6.0.0
importlib-resources      5.10.2
iniconfig                2.0.0
ipykernel                6.20.2
ipython                  8.8.0
ipywidgets               8.0.4
isort                    4.3.21
itsdangerous             2.1.2
jedi                     0.18.2
Jinja2                   3.1.2
joblib                   1.2.0
jsonschema               4.17.3
jupyter_client           7.4.9
jupyter_core             5.1.3
jupyterlab-widgets       3.0.5
kiwisolver               1.4.4
kornia                   0.6.9
lazy-object-proxy        1.9.0
MarkupSafe               2.1.2
matplotlib               3.6.3
matplotlib-inline        0.1.6
mccabe                   0.6.1
nbformat                 5.5.0
nest-asyncio             1.5.6
numpy                    1.24.1
nvidia-cublas-cu11       11.10.3.66
nvidia-cuda-nvrtc-cu11   11.7.99
nvidia-cuda-runtime-cu11 11.7.99
nvidia-cudnn-cu11        8.5.0.96
open3d                   0.16.0
opencv-python            4.7.0.68
packaging                23.0
pandas                   1.5.2
parso                    0.8.3
pexpect                  4.8.0
pickleshare              0.7.5
Pillow                   9.4.0
pip                      22.3.1
pkgutil_resolve_name     1.3.10
platformdirs             2.6.2
plotly                   5.12.0
pluggy                   1.0.0
plyfile                  0.7.4
prompt-toolkit           3.0.36
psutil                   5.9.4
ptyprocess               0.7.0
pure-eval                0.2.2
pyceres                  0.0.0
pycodestyle              2.10.0
pycolmap                 0.3.0
Pygments                 2.14.0
pylint                   2.5.0
pyparsing                3.0.9
pyquaternion             0.9.9
pyrsistent               0.19.3
PySocks                  1.7.1
pytest                   7.2.1
pytest-cov               4.0.0
python-dateutil          2.8.2
pytz                     2022.7.1
PyYAML                   6.0
pyzmq                    25.0.0
requests                 2.28.2
scikit-learn             1.2.0
scipy                    1.10.0
setuptools               66.0.0
six                      1.16.0
soupsieve                2.3.2.post1
stack-data               0.6.2
tenacity                 8.1.0
threadpoolctl            3.1.0
toml                     0.10.2
tomli                    2.0.1
torch                    1.13.1
torchvision              0.14.1
tornado                  6.2
tqdm                     4.64.1
traitlets                5.8.1
typing_extensions        4.4.0
urllib3                  1.26.14
wcwidth                  0.2.6
Werkzeug                 2.2.2
wheel                    0.38.4
widgetsnbextension       4.0.5
wrapt                    1.12.1
zipp                     3.11.0
@mihaidusmanu
Copy link
Collaborator

Hello. This is related to some strange pybind behavior related to the PyCOLMAP bindings. Increasing the recursion length does not fix it. Are you using the pip PyCOLMAP package or are you compiling from sources?

I would suggest compiling the latest version of PyCOLMAP from sources.

@sohee-zoe
Copy link
Author

Hello. Thank you for your reply.
I used pip PyCOLMAP, but I fixed it after compiling from sources.

I leave the code for setting up the dependencies.

hloc

git clone --recursive https://github.com/cvg/Hierarchical-Localization/
cd Hierarchical-Localization
python -m pip install -e .

COMAP

git clone https://github.com/colmap/colmap.git
cd colmap
git checkout dev
mkdir build
cd build
cmake ..
make -j
sudo make install

PyCOLMAP

git clone --recursive https://github.com/colmap/pycolmap.git
cd pycolmap
python -m pip install -e .

Ceres

PyCeres

pip install git+https://github.com/cvg/pyceres.git

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