microsoft / lamar-benchmark

Source code for the ECCV 2022 paper "Benchmarking Localization and Mapping for Augmented Reality".

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RecursionError: maximum recursion depth exceeded while calling a Python object

air158 opened this issue · comments

commented

Hi there, I encountered a RecursionError while trying to localize a single image using the superpoint features in the session query_val_phone. The error occurred at [2023/02/22 14:44:51 lamar.tasks.pose_estimation INFO] during the localization process. The full error message is: "RecursionError: maximum recursion depth exceeded while calling a Python object". I'm not sure what's causing the error, and I would appreciate any help you could provide in resolving it

(lamar) root@ba188978fb0b:/home/public/lamar-benchmark# python -m lamar.run --scene CAB --ref_id map --query_id query_val_phone --retrieval fusion --feature superpoint --matcher superglue
[2023/02/22 07:20:48 scantools.utils.io INFO] Optional dependency not installed: open3d
[2023/02/22 07:20:48 scantools.utils.io INFO] Optional dependency not installed: plyfile
[2023/02/22 07:20:51 scantools INFO] Loading Capture from /home/public/lamar-benchmark/data/CAB.
[2023/02/22 07:21:59 lamar.tasks.feature_extraction INFO] Extraction local features superpoint for session map.
[2023/02/22 07:22:00 hloc INFO] Extracting local features with configuration:
{'model': {'max_keypoints': 2048, 'name': 'superpoint', 'nms_radius': 3},
'preprocessing': {'grayscale': True, 'resize_max': 1024}}
[2023/02/22 07:22:35 hloc INFO] Skipping the extraction.
[2023/02/22 07:22:35 lamar.tasks.pair_selection INFO] Selecting image pairs with fusion-netvlad-ap-gem-10_frustum_pose-120-20-250 for sessions (map, map).
[2023/02/22 07:23:12 lamar.tasks.pair_selection INFO] Filtering pairs by frustums.
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 49/49 [07:32<00:00, 9.23s/it]
[2023/02/22 07:30:54 lamar.tasks.pair_selection INFO] Filtering pairs by poses.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [01:12<00:00, 8.06s/it]
[2023/02/22 07:32:09 lamar.tasks.pair_selection INFO] Computing pairs from visual similarity.
[2023/02/22 07:32:09 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/02/22 07:32:09 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
[2023/02/22 07:32:27 hloc INFO] Skipping the extraction.
[2023/02/22 07:32:27 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/02/22 07:32:27 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
[2023/02/22 07:32:45 hloc INFO] Skipping the extraction.
[2023/02/22 07:33:11 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/02/22 07:33:11 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
/opt/conda/envs/lamar/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator PCA from version 0.20.2 when using version 1.1.3. 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 '/root/.cache/torch/hub/dirtorch/Resnet-101-AP-GeM.pt' (current_iter 296)
100%|████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [1:16:44<00:00, 7.29it/s]
[2023/02/22 08:50:07 hloc INFO] Finished exporting features.
[2023/02/22 08:50:07 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/02/22 08:50:07 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
[2023/02/22 08:50:24 hloc INFO] Skipping the extraction.
[2023/02/22 08:51:40 lamar.tasks.feature_matching INFO] Matching local features with superglue for sessions (map, map).
[2023/02/22 08:51:40 lamar.tasks.feature_matching WARNING] Existing matches will be overwritten.
[2023/02/22 08:51:40 hloc INFO] Matching local features with configuration:
{'model': {'name': 'superglue', 'sinkhorn_iterations': 5, 'weights': 'outdoor'}}
Loaded SuperGlue model ("outdoor" weights)
100%|██████████████████████████████████████████████████████████████████████████████████████| 220311/220311 [4:48:09<00:00, 12.74it/s]
[2023/02/22 13:39:53 hloc INFO] Finished exporting matches.
[2023/02/22 13:39:53 lamar.tasks.mapping INFO] Mapping session map via triangulation of features superpoint.
[2023/02/22 13:39:57 scantools INFO] Writing COLMAP empty .bin reconstruction to /home/public/lamar-benchmark/outputs/CAB/mapping/map/triangulation/superpoint/fusion-netvlad-ap-gem-10_frustum_pose-120-20-250/superglue/sfm_empty.
[2023/02/22 13:40:01 hloc INFO] Importing features into the database...
100%|█████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [00:34<00:00, 968.04it/s]
[2023/02/22 13:40:36 hloc INFO] Importing matches into the database...
100%|██████████████████████████████████████████████████████████████████████████████████████| 335870/335870 [05:06<00:00, 1094.61it/s]
[2023/02/22 13:45:46 hloc INFO] Performing geometric verification of the matches...
100%|██████████████████████████████████████████████████████████████████████████████████████████| 33587/33587 [29:50<00:00, 18.75it/s]
[2023/02/22 14:15:37 hloc INFO] mean/med/min/max valid matches 77.72/93.44/0.00/100.00%.
[2023/02/22 14:15:37 hloc INFO] Running 3D triangulation...
[2023/02/22 14:35:16 hloc INFO] Finished the triangulation with statistics:
Reconstruction:
num_reg_images = 33587
num_cameras = 6799
num_points3D = 1931868
num_observations = 10034627
mean_track_length = 5.19426
mean_observations_per_image = 298.765
mean_reprojection_error = 1.52068
[2023/02/22 14:35:23 lamar.tasks.feature_extraction INFO] Extraction local features superpoint for session query_val_phone.
[2023/02/22 14:35:23 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:18<00:00, 21.11it/s]
[2023/02/22 14:35:42 hloc INFO] Finished exporting features.
[2023/02/22 14:35:42 lamar.tasks.pair_selection INFO] Selecting image pairs with fusion-netvlad-ap-gem-10 for sessions (query_val_phone, map).
[2023/02/22 14:35:42 lamar.tasks.pair_selection INFO] Computing pairs from visual similarity.
[2023/02/22 14:35:42 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session query_val_phone.
[2023/02/22 14:35:42 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 396/396 [00:37<00:00, 10.44it/s]
[2023/02/22 14:36:33 hloc INFO] Finished exporting features.
[2023/02/22 14:36:33 lamar.tasks.feature_extraction INFO] Extraction local features netvlad for session map.
[2023/02/22 14:36:33 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'}, 'preprocessing': {'resize_max': 640}}
[2023/02/22 14:36:50 hloc INFO] Skipping the extraction.
[2023/02/22 14:37:04 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session query_val_phone.
[2023/02/22 14:37:04 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
=> loading checkpoint '/root/.cache/torch/hub/dirtorch/Resnet-101-AP-GeM.pt' (current_iter 296)
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 396/396 [01:18<00:00, 5.05it/s]
[2023/02/22 14:38:25 hloc INFO] Finished exporting features.
[2023/02/22 14:38:25 lamar.tasks.feature_extraction INFO] Extraction local features ap-gem for session map.
[2023/02/22 14:38:26 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dir'}, 'preprocessing': {'resize_max': 640}}
[2023/02/22 14:38:43 hloc INFO] Skipping the extraction.
[2023/02/22 14:38:57 lamar.tasks.feature_matching INFO] Matching local features with superglue for sessions (query_val_phone, map).
[2023/02/22 14:38:57 lamar.tasks.feature_matching WARNING] Existing matches will be overwritten.
[2023/02/22 14:38:57 hloc INFO] Matching local features with configuration:
{'model': {'name': 'superglue', 'sinkhorn_iterations': 5, 'weights': 'outdoor'}}
Loaded SuperGlue model ("outdoor" weights)
100%|████████████████████████████████████████████████████████████████████████████████████████████| 3960/3960 [05:53<00:00, 11.21it/s]
[2023/02/22 14:44:51 hloc INFO] Finished exporting matches.
[2023/02/22 14:44:51 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 "/opt/conda/envs/lamar/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "/opt/conda/envs/lamar/lib/python3.8/runpy.py", line 87, in run_code
exec(code, run_globals)
File "/home/public/lamar-benchmark/lamar/run.py", line 154, in
results
= run(**args)
File "/home/public/lamar-benchmark/lamar/run.py", line 120, in run
pose_estimation = PoseEstimation(
File "/home/public/lamar-benchmark/lamar/tasks/pose_estimation.py", line 109, in init
self.poses = self.run(capture)
File "/home/public/lamar-benchmark/lamar/tasks/pose_estimation.py", line 177, in run
map
(_worker_fn, range(len(keys)))
File "/opt/conda/envs/lamar/lib/python3.8/site-packages/tqdm/contrib/concurrent.py", line 94, in thread_map
return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)
File "/opt/conda/envs/lamar/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 "/opt/conda/envs/lamar/lib/python3.8/site-packages/tqdm/std.py", line 1195, in iter
for obj in iterable:
File "/opt/conda/envs/lamar/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
yield fs.pop().result()
File "/opt/conda/envs/lamar/lib/python3.8/concurrent/futures/_base.py", line 444, in result
return self.__get_result()
File "/opt/conda/envs/lamar/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/opt/conda/envs/lamar/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/public/lamar-benchmark/lamar/tasks/pose_estimation.py", line 165, in _worker_fn
pose, _ = estimate_camera_pose(
File "/home/public/lamar-benchmark/lamar/utils/localization.py", line 69, in estimate_camera_pose
matches_2d3d = recover_matches(query, ref_key_names)
File "/home/public/lamar-benchmark/lamar/tasks/pose_estimation.py", line 119, in recover_matches_2d3d
return recover_matches_2d3d(
File "/home/public/lamar-benchmark/lamar/utils/localization.py", line 35, in recover_matches_2d3d
valid, p3ds, p3d_ids = mapping.get_points3D(ref_key, matches[:, 1])
File "/home/public/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

Thanks for reporting this bug. This happens within pycolmap, can you try PR colmap/pycolmap#95 and let us know if it solves your issue? Thanks!

commented

I encountered this error too, and this is how I fixed it.

  1. Install colmap with commit d812bcb, and reinstall pycolmap.
  2. Update deprecated numpy attribute. See #28
    hope this is helpful :)

#28 has now been merged, could you try with the latest pycolmap release v0.4, which was just published today?

commented

I did this with pycolmap 0.4.0, it works well.