From 1ff3b330b6f4954b7f96e57126d97afef2af6c6b Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 13:54:19 +0100 Subject: [PATCH 01/13] try to disable cuda for colmap --- cmake/FindDependencies.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index 17cef13..bd179dd 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -61,6 +61,8 @@ FetchContent_Declare(COLMAP ) message(STATUS "Configuring COLMAP...") if (FETCH_COLMAP) + # Set the CUDA_ENABLED option to OFF before including COLMAP content + set(CUDA_ENABLED OFF CACHE BOOL "Build COLMAP without CUDA support" FORCE) FetchContent_MakeAvailable(COLMAP) else() find_package(COLMAP REQUIRED) From fa853ec51c0df83069ffbd37a6073c69f2274af6 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 16:43:33 +0100 Subject: [PATCH 02/13] fix binding --- limap/base/bindings.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/limap/base/bindings.cc b/limap/base/bindings.cc index cd0f813..bae1bb8 100644 --- a/limap/base/bindings.cc +++ b/limap/base/bindings.cc @@ -746,6 +746,7 @@ void bind_camera(py::module &m) { .def_readwrite("model", &Camera::model_id, "Camera model.") .def_readwrite("width", &Camera::width, "Width of camera sensor.") .def_readwrite("height", &Camera::height, "Height of camera sensor.") + .def_readwrite("params", &Camera::params, "Camera parameters.") .def("as_dict", &Camera::as_dict, R"( Returns: dict: Python dict representation of this :class:`~limap.base.Camera` From c129c87d99862df06c81b8923460bce5da34808e Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 16:46:24 +0100 Subject: [PATCH 03/13] move CUDA_ENABLED to top level --- CMakeLists.txt | 1 + cmake/FindDependencies.cmake | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23c2b6c..740c1f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ option(OPENMP_ENABLED "Whether to enable OpenMP parallelization" ON) option(INTERPOLATION_ENABLED "Whether to enable interpolation-based pixel-perfect optimization" OFF) option(FETCH_POSELIB "Whether to use PoseLib with FetchContent or with self-installed software" ON) option(FETCH_COLMAP "Whether to use COLMAP with FetchContent or with self-installed software" ON) +option(CUDA_ENABLED "Whether to use CUDA (only for the third-party COLMAP)" OFF) include(cmake/FindDependencies.cmake) include(cmake/InitVariables.cmake) diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index bd179dd..17cef13 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -61,8 +61,6 @@ FetchContent_Declare(COLMAP ) message(STATUS "Configuring COLMAP...") if (FETCH_COLMAP) - # Set the CUDA_ENABLED option to OFF before including COLMAP content - set(CUDA_ENABLED OFF CACHE BOOL "Build COLMAP without CUDA support" FORCE) FetchContent_MakeAvailable(COLMAP) else() find_package(COLMAP REQUIRED) From 6e14755241f2b7822a5844b1f5904bf0457e9350 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 18:26:26 +0100 Subject: [PATCH 04/13] fix copy in pybind --- limap/base/bindings.cc | 4 ++++ limap/base/camera.cc | 14 +++++++++++++- limap/base/camera.h | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/limap/base/bindings.cc b/limap/base/bindings.cc index bae1bb8..bb10f5b 100644 --- a/limap/base/bindings.cc +++ b/limap/base/bindings.cc @@ -734,6 +734,8 @@ void bind_camera(py::module &m) { .def(py::init>(), py::arg("model_name"), py::arg("cam_id") = -1, py::arg("hw") = std::make_pair(-1, -1)) // empty camera + .def("__copy__", [](const Camera& self) { return Camera(self); }) + .def("__deepcopy__", [](const Camera& self, const py::dict&) { return Camera(self); }) .def(py::pickle( [](const Camera &input) { // dump return input.as_dict(); @@ -1053,6 +1055,8 @@ void bind_camera(py::module &m) { .def(py::init &>(), py::arg("camviews")) .def(py::init(), py::arg("dict")) .def(py::init(), py::arg("imagecols")) + .def("__copy__", [](const ImageCollection& self) { return ImageCollection(self); }) + .def("__deepcopy__", [](const ImageCollection& self, const py::dict&) { return ImageCollection(self); }) .def(py::pickle( [](const ImageCollection &input) { // dump return input.as_dict(); diff --git a/limap/base/camera.cc b/limap/base/camera.cc index e579efe..dbe0929 100644 --- a/limap/base/camera.cc +++ b/limap/base/camera.cc @@ -37,7 +37,7 @@ bool Camera::IsInitialized() const { return true; } -Camera::Camera(const colmap::Camera &cam) { +Camera::Camera(const colmap::Camera& cam) { camera_id = cam.camera_id; model_id = cam.model_id; params = cam.params; @@ -185,6 +185,18 @@ Camera::Camera(const Camera &cam) { initialized = cam.initialized; } +Camera& Camera::operator=(const Camera& cam) { + if (this != &cam) { + camera_id = cam.camera_id; + model_id = cam.model_id; + params = cam.params; + height = cam.height; + width = cam.width; + initialized = cam.initialized; + } + return *this; +} + bool Camera::operator==(const Camera &cam) { if (camera_id != cam.camera_id) return false; diff --git a/limap/base/camera.h b/limap/base/camera.h index 651af9e..27df559 100644 --- a/limap/base/camera.h +++ b/limap/base/camera.h @@ -55,7 +55,8 @@ class Camera : public colmap::Camera { Camera(const std::string &model_name, M3D K, int cam_id = -1, std::pair hw = std::make_pair(-1, -1)); Camera(py::dict dict); - Camera(const Camera &cam); + Camera(const Camera& cam); + Camera& operator=(const Camera& cam); Camera(int model, int cam_id = -1, std::pair hw = std::make_pair(-1, -1)); // empty camera From 215aa50d2ec28e2a25abfb15620792127ccc1a17 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 18:30:39 +0100 Subject: [PATCH 05/13] switch to clang-format 19.1.0 and use pip --- .github/workflows/format-ubuntu.yml | 3 +-- limap/base/bindings.cc | 13 +++++++++---- limap/base/camera.cc | 4 ++-- limap/base/camera.h | 4 ++-- limap/base/infinite_line.h | 2 +- limap/evaluation/refline_evaluator.h | 2 +- requirements.txt | 1 + scripts/format/clang_format.sh | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/format-ubuntu.yml b/.github/workflows/format-ubuntu.yml index 1410019..767948e 100644 --- a/.github/workflows/format-ubuntu.yml +++ b/.github/workflows/format-ubuntu.yml @@ -37,8 +37,7 @@ jobs: exit 0 fi set +x -euo pipefail - sudo apt-get update && sudo apt-get install -y clang-format-14 - python -m pip install ruff==0.6.7 + python -m pip install ruff==0.6.7 clang-format==19.1.0 ./scripts/format/clang_format.sh ./scripts/format/python.sh git diff --name-only diff --git a/limap/base/bindings.cc b/limap/base/bindings.cc index bb10f5b..aaa0848 100644 --- a/limap/base/bindings.cc +++ b/limap/base/bindings.cc @@ -734,8 +734,9 @@ void bind_camera(py::module &m) { .def(py::init>(), py::arg("model_name"), py::arg("cam_id") = -1, py::arg("hw") = std::make_pair(-1, -1)) // empty camera - .def("__copy__", [](const Camera& self) { return Camera(self); }) - .def("__deepcopy__", [](const Camera& self, const py::dict&) { return Camera(self); }) + .def("__copy__", [](const Camera &self) { return Camera(self); }) + .def("__deepcopy__", + [](const Camera &self, const py::dict &) { return Camera(self); }) .def(py::pickle( [](const Camera &input) { // dump return input.as_dict(); @@ -1055,8 +1056,12 @@ void bind_camera(py::module &m) { .def(py::init &>(), py::arg("camviews")) .def(py::init(), py::arg("dict")) .def(py::init(), py::arg("imagecols")) - .def("__copy__", [](const ImageCollection& self) { return ImageCollection(self); }) - .def("__deepcopy__", [](const ImageCollection& self, const py::dict&) { return ImageCollection(self); }) + .def("__copy__", + [](const ImageCollection &self) { return ImageCollection(self); }) + .def("__deepcopy__", + [](const ImageCollection &self, const py::dict &) { + return ImageCollection(self); + }) .def(py::pickle( [](const ImageCollection &input) { // dump return input.as_dict(); diff --git a/limap/base/camera.cc b/limap/base/camera.cc index dbe0929..de73f6d 100644 --- a/limap/base/camera.cc +++ b/limap/base/camera.cc @@ -37,7 +37,7 @@ bool Camera::IsInitialized() const { return true; } -Camera::Camera(const colmap::Camera& cam) { +Camera::Camera(const colmap::Camera &cam) { camera_id = cam.camera_id; model_id = cam.model_id; params = cam.params; @@ -185,7 +185,7 @@ Camera::Camera(const Camera &cam) { initialized = cam.initialized; } -Camera& Camera::operator=(const Camera& cam) { +Camera &Camera::operator=(const Camera &cam) { if (this != &cam) { camera_id = cam.camera_id; model_id = cam.model_id; diff --git a/limap/base/camera.h b/limap/base/camera.h index 27df559..1cc8026 100644 --- a/limap/base/camera.h +++ b/limap/base/camera.h @@ -55,8 +55,8 @@ class Camera : public colmap::Camera { Camera(const std::string &model_name, M3D K, int cam_id = -1, std::pair hw = std::make_pair(-1, -1)); Camera(py::dict dict); - Camera(const Camera& cam); - Camera& operator=(const Camera& cam); + Camera(const Camera &cam); + Camera &operator=(const Camera &cam); Camera(int model, int cam_id = -1, std::pair hw = std::make_pair(-1, -1)); // empty camera diff --git a/limap/base/infinite_line.h b/limap/base/infinite_line.h index a98af4d..e5eaba0 100644 --- a/limap/base/infinite_line.h +++ b/limap/base/infinite_line.h @@ -68,7 +68,7 @@ class MinimalInfiniteLine3d { public: MinimalInfiniteLine3d() {} MinimalInfiniteLine3d(const Line3d &line) - : MinimalInfiniteLine3d(InfiniteLine3d(line)){}; + : MinimalInfiniteLine3d(InfiniteLine3d(line)) {}; MinimalInfiniteLine3d(const InfiniteLine3d &inf_line); MinimalInfiniteLine3d(const std::vector &values); InfiniteLine3d GetInfiniteLine() const; diff --git a/limap/evaluation/refline_evaluator.h b/limap/evaluation/refline_evaluator.h index 3737f4b..1fca097 100644 --- a/limap/evaluation/refline_evaluator.h +++ b/limap/evaluation/refline_evaluator.h @@ -14,7 +14,7 @@ class RefLineEvaluator { public: RefLineEvaluator() {} RefLineEvaluator(const std::vector &ref_lines) - : ref_lines_(ref_lines){}; + : ref_lines_(ref_lines) {}; double SumLength() const; double ComputeRecallRef(const std::vector &lines, diff --git a/requirements.txt b/requirements.txt index c776ad8..520afb0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,6 +28,7 @@ ninja yacs python-json-logger ruff==0.6.7 +clang-format==19.1.0 ./third-party/pytlsd ./third-party/hawp diff --git a/scripts/format/clang_format.sh b/scripts/format/clang_format.sh index a70a0c8..d978b65 100755 --- a/scripts/format/clang_format.sh +++ b/scripts/format/clang_format.sh @@ -24,7 +24,7 @@ echo "Found clang-format: $(which ${clang_format})" # Check version version_string=$($clang_format --version | sed -E 's/^.*(\d+\.\d+\.\d+-.*).*$/\1/') -expected_version_string='14.0.0' +expected_version_string='19.1.0' if [[ "$version_string" =~ "$expected_version_string" ]]; then echo "clang-format version '$version_string' matches '$expected_version_string'" else From f0513bc45875838d2ad735ffc7fcb7d35f17d713 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 18:37:22 +0100 Subject: [PATCH 06/13] upgrade deeplsd --- third-party/DeepLSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/DeepLSD b/third-party/DeepLSD index 59006b2..17c7645 160000 --- a/third-party/DeepLSD +++ b/third-party/DeepLSD @@ -1 +1 @@ -Subproject commit 59006b264d05e97856556d3f16ded45bd4dbc286 +Subproject commit 17c764595b17f619e6f78c5f9fc18f1f970ea579 From 39b7c810bd96b6f847912edf7da03e0f187746e2 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:15:13 +0100 Subject: [PATCH 07/13] use logging from pycolmap --- limap/base/unit_test.py | 2 +- limap/features/extractors.py | 2 +- limap/features/models/s2dnet.py | 2 +- limap/line2d/DeepLSD/deeplsd.py | 2 +- limap/line2d/GlueStick/matcher.py | 2 +- limap/line2d/HAWPv3/hawp.py | 2 +- limap/line2d/L2D2/extractor.py | 2 +- limap/line2d/LineTR/line_transformer.py | 2 +- limap/line2d/SOLD2/misc/train_utils.py | 2 +- limap/line2d/SOLD2/model/model_util.py | 2 +- limap/line2d/SOLD2/sold2_wrapper.py | 2 +- limap/line2d/SOLD2/train.py | 2 +- limap/line2d/TP_LSD/tp_lsd.py | 2 +- limap/merging/merging.py | 2 +- limap/optimize/line_refinement/line_refinement.py | 2 +- limap/point2d/superglue/superglue.py | 2 +- limap/point2d/superpoint/main.py | 2 +- limap/point2d/superpoint/superpoint.py | 2 +- limap/pointsfm/bundler_reader.py | 2 +- limap/pointsfm/colmap_reader.py | 2 +- limap/pointsfm/colmap_sfm.py | 2 +- limap/pointsfm/functions.py | 2 +- limap/runners/functions.py | 2 +- limap/runners/functions_structures.py | 2 +- limap/runners/hybrid_localization.py | 2 +- limap/runners/line_fitnmerge.py | 2 +- limap/runners/line_triangulation.py | 2 +- limap/util/evaluation.py | 2 +- limap/util/io.py | 2 +- limap/visualize/trackvis/base.py | 2 +- limap/visualize/vis_utils.py | 2 +- requirements.txt | 1 + 32 files changed, 32 insertions(+), 31 deletions(-) diff --git a/limap/base/unit_test.py b/limap/base/unit_test.py index 6d1811b..ba782fc 100644 --- a/limap/base/unit_test.py +++ b/limap/base/unit_test.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import _limap._base as _base import numpy as np diff --git a/limap/features/extractors.py b/limap/features/extractors.py index 6989f07..57f33ed 100644 --- a/limap/features/extractors.py +++ b/limap/features/extractors.py @@ -1,6 +1,6 @@ # [NOTE] modified from the pixel-perfect-sfm project -import logging +from pycolmap import logging import sys import time diff --git a/limap/features/models/s2dnet.py b/limap/features/models/s2dnet.py index b712a83..9fe1dce 100644 --- a/limap/features/models/s2dnet.py +++ b/limap/features/models/s2dnet.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os from pathlib import Path from typing import List diff --git a/limap/line2d/DeepLSD/deeplsd.py b/limap/line2d/DeepLSD/deeplsd.py index 5bd0963..ba71b39 100644 --- a/limap/line2d/DeepLSD/deeplsd.py +++ b/limap/line2d/DeepLSD/deeplsd.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import numpy as np diff --git a/limap/line2d/GlueStick/matcher.py b/limap/line2d/GlueStick/matcher.py index eac0e9c..fca5c29 100644 --- a/limap/line2d/GlueStick/matcher.py +++ b/limap/line2d/GlueStick/matcher.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import numpy as np diff --git a/limap/line2d/HAWPv3/hawp.py b/limap/line2d/HAWPv3/hawp.py index ea9aefa..26dd9da 100644 --- a/limap/line2d/HAWPv3/hawp.py +++ b/limap/line2d/HAWPv3/hawp.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import cv2 diff --git a/limap/line2d/L2D2/extractor.py b/limap/line2d/L2D2/extractor.py index 8d12235..43a2865 100644 --- a/limap/line2d/L2D2/extractor.py +++ b/limap/line2d/L2D2/extractor.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import cv2 diff --git a/limap/line2d/LineTR/line_transformer.py b/limap/line2d/LineTR/line_transformer.py index e733b24..a94e330 100755 --- a/limap/line2d/LineTR/line_transformer.py +++ b/limap/line2d/LineTR/line_transformer.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging from copy import deepcopy from pathlib import Path diff --git a/limap/line2d/SOLD2/misc/train_utils.py b/limap/line2d/SOLD2/misc/train_utils.py index 470f0a8..3561957 100644 --- a/limap/line2d/SOLD2/misc/train_utils.py +++ b/limap/line2d/SOLD2/misc/train_utils.py @@ -2,7 +2,7 @@ This file contains some useful functions for train / val. """ -import logging +from pycolmap import logging import os import numpy as np diff --git a/limap/line2d/SOLD2/model/model_util.py b/limap/line2d/SOLD2/model/model_util.py index b638219..b514311 100644 --- a/limap/line2d/SOLD2/model/model_util.py +++ b/limap/line2d/SOLD2/model/model_util.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import torch.nn as nn import torch.nn.init as init diff --git a/limap/line2d/SOLD2/sold2_wrapper.py b/limap/line2d/SOLD2/sold2_wrapper.py index 648a673..e917678 100644 --- a/limap/line2d/SOLD2/sold2_wrapper.py +++ b/limap/line2d/SOLD2/sold2_wrapper.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import subprocess diff --git a/limap/line2d/SOLD2/train.py b/limap/line2d/SOLD2/train.py index 522868e..947b1a1 100644 --- a/limap/line2d/SOLD2/train.py +++ b/limap/line2d/SOLD2/train.py @@ -2,7 +2,7 @@ This file implements the training process and all the summaries """ -import logging +from pycolmap import logging import cv2 import numpy as np diff --git a/limap/line2d/TP_LSD/tp_lsd.py b/limap/line2d/TP_LSD/tp_lsd.py index 7311419..b123c6f 100644 --- a/limap/line2d/TP_LSD/tp_lsd.py +++ b/limap/line2d/TP_LSD/tp_lsd.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import cv2 diff --git a/limap/merging/merging.py b/limap/merging/merging.py index a22fbc2..7d81078 100644 --- a/limap/merging/merging.py +++ b/limap/merging/merging.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging from _limap import _base from _limap import _merging as _mrg diff --git a/limap/optimize/line_refinement/line_refinement.py b/limap/optimize/line_refinement/line_refinement.py index 9b54674..bf232d2 100644 --- a/limap/optimize/line_refinement/line_refinement.py +++ b/limap/optimize/line_refinement/line_refinement.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import numpy as np diff --git a/limap/point2d/superglue/superglue.py b/limap/point2d/superglue/superglue.py index 4457bdb..1442607 100644 --- a/limap/point2d/superglue/superglue.py +++ b/limap/point2d/superglue/superglue.py @@ -40,7 +40,7 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -import logging +from pycolmap import logging import os from copy import deepcopy from pathlib import Path diff --git a/limap/point2d/superpoint/main.py b/limap/point2d/superpoint/main.py index e4e6fcb..14746f2 100644 --- a/limap/point2d/superpoint/main.py +++ b/limap/point2d/superpoint/main.py @@ -1,5 +1,5 @@ import collections.abc as collections -import logging +from pycolmap import logging import pprint from pathlib import Path from typing import Dict, List, Optional, Union diff --git a/limap/point2d/superpoint/superpoint.py b/limap/point2d/superpoint/superpoint.py index c164ec0..80020d0 100644 --- a/limap/point2d/superpoint/superpoint.py +++ b/limap/point2d/superpoint/superpoint.py @@ -40,7 +40,7 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -import logging +from pycolmap import logging import os from pathlib import Path diff --git a/limap/pointsfm/bundler_reader.py b/limap/pointsfm/bundler_reader.py index 9e91676..cd2e778 100644 --- a/limap/pointsfm/bundler_reader.py +++ b/limap/pointsfm/bundler_reader.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import imagesize diff --git a/limap/pointsfm/colmap_reader.py b/limap/pointsfm/colmap_reader.py index 60aa335..f9952d0 100644 --- a/limap/pointsfm/colmap_reader.py +++ b/limap/pointsfm/colmap_reader.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import sys diff --git a/limap/pointsfm/colmap_sfm.py b/limap/pointsfm/colmap_sfm.py index 781ebe9..6a3a801 100644 --- a/limap/pointsfm/colmap_sfm.py +++ b/limap/pointsfm/colmap_sfm.py @@ -1,5 +1,5 @@ import copy -import logging +from pycolmap import logging import os import shutil import subprocess diff --git a/limap/pointsfm/functions.py b/limap/pointsfm/functions.py index d504888..85f89cf 100644 --- a/limap/pointsfm/functions.py +++ b/limap/pointsfm/functions.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging from _limap import _pointsfm diff --git a/limap/runners/functions.py b/limap/runners/functions.py index 360cacb..ef7a2f7 100644 --- a/limap/runners/functions.py +++ b/limap/runners/functions.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os from tqdm import tqdm diff --git a/limap/runners/functions_structures.py b/limap/runners/functions_structures.py index a046e41..215c6ae 100644 --- a/limap/runners/functions_structures.py +++ b/limap/runners/functions_structures.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import numpy as np diff --git a/limap/runners/hybrid_localization.py b/limap/runners/hybrid_localization.py index 02c0bae..8369817 100644 --- a/limap/runners/hybrid_localization.py +++ b/limap/runners/hybrid_localization.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os from collections import defaultdict diff --git a/limap/runners/line_fitnmerge.py b/limap/runners/line_fitnmerge.py index df0b6b3..995e9e2 100644 --- a/limap/runners/line_fitnmerge.py +++ b/limap/runners/line_fitnmerge.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import joblib diff --git a/limap/runners/line_triangulation.py b/limap/runners/line_triangulation.py index d865120..683b3da 100644 --- a/limap/runners/line_triangulation.py +++ b/limap/runners/line_triangulation.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os from tqdm import tqdm diff --git a/limap/util/evaluation.py b/limap/util/evaluation.py index 9bbe22e..78c599a 100644 --- a/limap/util/evaluation.py +++ b/limap/util/evaluation.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import cv2 import numpy as np diff --git a/limap/util/io.py b/limap/util/io.py index 75fad64..5078dd5 100644 --- a/limap/util/io.py +++ b/limap/util/io.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import os import shutil diff --git a/limap/visualize/trackvis/base.py b/limap/visualize/trackvis/base.py index 7999c75..068d8ca 100644 --- a/limap/visualize/trackvis/base.py +++ b/limap/visualize/trackvis/base.py @@ -1,4 +1,4 @@ -import logging +from pycolmap import logging import numpy as np diff --git a/limap/visualize/vis_utils.py b/limap/visualize/vis_utils.py index c07e5a6..71f4984 100644 --- a/limap/visualize/vis_utils.py +++ b/limap/visualize/vis_utils.py @@ -1,5 +1,5 @@ import copy -import logging +from pycolmap import logging import os import cv2 diff --git a/requirements.txt b/requirements.txt index 520afb0..b4f44fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,6 +27,7 @@ einops ninja yacs python-json-logger +pycolmap ruff==0.6.7 clang-format==19.1.0 From 2957ebf2d2d340a7a3e09054e8c00ee9f7c0d9f9 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:15:33 +0100 Subject: [PATCH 08/13] disable parallelization in fitnmerge --- cfgs/fitnmerge/default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfgs/fitnmerge/default.yaml b/cfgs/fitnmerge/default.yaml index 3867c3d..c7c7a7e 100644 --- a/cfgs/fitnmerge/default.yaml +++ b/cfgs/fitnmerge/default.yaml @@ -55,7 +55,7 @@ fitting: var2d: -1.0 # depends on the detector ransac_th: 0.75 min_percentage_inliers: 0.9 - n_jobs: 4 + n_jobs: 1 ############################## # merging config From 8d40cd8d26fc85c2af3bd18ce1c3d16cdbd51be5 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:20:44 +0100 Subject: [PATCH 09/13] fix formatting --- limap/visualize/trackvis/base.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/limap/visualize/trackvis/base.py b/limap/visualize/trackvis/base.py index 068d8ca..cf293d4 100644 --- a/limap/visualize/trackvis/base.py +++ b/limap/visualize/trackvis/base.py @@ -26,14 +26,14 @@ def report(self): def report_stats(self): counts = np.array(self.counts) logging.info( - f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) = \ - ({counts[counts >= 2].shape[0]}, \ - {counts[counts >= 4].shape[0]}, \ - {counts[counts >= 6].shape[0]}, \ - {counts[counts >= 8].shape[0]}, \ - {counts[counts >= 10].shape[0]}, \ - {counts[counts >= 20].shape[0]}, \ - {counts[counts >= 50].shape[0]})" + f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) =" \ + f" ({counts[counts >= 2].shape[0]}," \ + f" {counts[counts >= 4].shape[0]}," \ + f" {counts[counts >= 6].shape[0]}," \ + f" {counts[counts >= 8].shape[0]}," \ + f" {counts[counts >= 10].shape[0]}," \ + f" {counts[counts >= 20].shape[0]}," \ + f" {counts[counts >= 50].shape[0]})" ) def report_avg_supports(self, n_visible_views=4): @@ -42,12 +42,12 @@ def report_avg_supports(self, n_visible_views=4): arr = counts[counts >= n_visible_views] arr_lines = counts_lines[counts >= n_visible_views] logging.info( - f"average supporting images (>= {n_visible_views}): \ - {arr.sum()} / {arr.shape[0]} = {arr.mean():.2f}" + f"average supporting images (>= {n_visible_views}):" \ + f" {arr.sum()} / {arr.shape[0]} = {arr.mean():.2f}" ) logging.info( - f"average supporting lines (>= {n_visible_views}): \ - {arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" + f"average supporting lines (>= {n_visible_views}):" \ + f" {arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" ) def get_counts_np(self): From ceb400ac69384b5b7f3e2157887548668795ff2f Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:25:33 +0100 Subject: [PATCH 10/13] fix formatting --- limap/base/unit_test.py | 3 +-- limap/features/extractors.py | 2 +- limap/features/models/s2dnet.py | 2 +- limap/line2d/DeepLSD/deeplsd.py | 2 +- limap/line2d/GlueStick/matcher.py | 2 +- limap/line2d/HAWPv3/hawp.py | 2 +- limap/line2d/L2D2/extractor.py | 2 +- limap/line2d/LineTR/line_transformer.py | 2 +- limap/line2d/SOLD2/misc/train_utils.py | 2 +- limap/line2d/SOLD2/model/model_util.py | 3 +-- limap/line2d/SOLD2/sold2_wrapper.py | 2 +- limap/line2d/SOLD2/train.py | 3 +-- limap/line2d/TP_LSD/tp_lsd.py | 2 +- limap/merging/merging.py | 7 +++--- .../line_refinement/line_refinement.py | 2 +- limap/point2d/superglue/superglue.py | 2 +- limap/point2d/superpoint/main.py | 2 +- limap/point2d/superpoint/superpoint.py | 2 +- limap/pointsfm/bundler_reader.py | 2 +- limap/pointsfm/colmap_reader.py | 2 +- limap/pointsfm/colmap_sfm.py | 2 +- limap/pointsfm/functions.py | 3 +-- limap/runners/functions.py | 22 +++++++++--------- limap/runners/functions_structures.py | 2 +- limap/runners/hybrid_localization.py | 2 +- limap/runners/line_fitnmerge.py | 2 +- limap/runners/line_triangulation.py | 2 +- limap/util/evaluation.py | 3 +-- limap/util/io.py | 2 +- limap/visualize/trackvis/base.py | 23 +++++++++---------- limap/visualize/vis_utils.py | 2 +- 31 files changed, 53 insertions(+), 60 deletions(-) diff --git a/limap/base/unit_test.py b/limap/base/unit_test.py index ba782fc..c93b171 100644 --- a/limap/base/unit_test.py +++ b/limap/base/unit_test.py @@ -1,7 +1,6 @@ -from pycolmap import logging - import _limap._base as _base import numpy as np +from pycolmap import logging def unit_test_add_noise(imagecols): diff --git a/limap/features/extractors.py b/limap/features/extractors.py index 57f33ed..7d30791 100644 --- a/limap/features/extractors.py +++ b/limap/features/extractors.py @@ -1,6 +1,5 @@ # [NOTE] modified from the pixel-perfect-sfm project -from pycolmap import logging import sys import time @@ -9,6 +8,7 @@ import torch import torchvision.transforms.functional as tvf from _limap import _features +from pycolmap import logging from torchvision import transforms from .models.s2dnet import S2DNet diff --git a/limap/features/models/s2dnet.py b/limap/features/models/s2dnet.py index 9fe1dce..2788234 100644 --- a/limap/features/models/s2dnet.py +++ b/limap/features/models/s2dnet.py @@ -1,4 +1,3 @@ -from pycolmap import logging import os from pathlib import Path from typing import List @@ -6,6 +5,7 @@ import numpy as np import torch import torch.nn as nn +from pycolmap import logging from torchvision import models from .base_model import BaseModel diff --git a/limap/line2d/DeepLSD/deeplsd.py b/limap/line2d/DeepLSD/deeplsd.py index ba71b39..2d111eb 100644 --- a/limap/line2d/DeepLSD/deeplsd.py +++ b/limap/line2d/DeepLSD/deeplsd.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os import numpy as np import torch from deeplsd.models.deeplsd_inference import DeepLSD +from pycolmap import logging from ..base_detector import ( BaseDetector, diff --git a/limap/line2d/GlueStick/matcher.py b/limap/line2d/GlueStick/matcher.py index fca5c29..9492f41 100644 --- a/limap/line2d/GlueStick/matcher.py +++ b/limap/line2d/GlueStick/matcher.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os import numpy as np import torch from gluestick.models.gluestick import GlueStick +from pycolmap import logging from ..base_matcher import ( BaseMatcher, diff --git a/limap/line2d/HAWPv3/hawp.py b/limap/line2d/HAWPv3/hawp.py index 26dd9da..f5765d8 100644 --- a/limap/line2d/HAWPv3/hawp.py +++ b/limap/line2d/HAWPv3/hawp.py @@ -1,4 +1,3 @@ -from pycolmap import logging import os import cv2 @@ -6,6 +5,7 @@ import torch from hawp.fsl.config import cfg as model_config from hawp.ssl.models import MODELS +from pycolmap import logging from ..base_detector import ( BaseDetector, diff --git a/limap/line2d/L2D2/extractor.py b/limap/line2d/L2D2/extractor.py index 43a2865..fceac1b 100644 --- a/limap/line2d/L2D2/extractor.py +++ b/limap/line2d/L2D2/extractor.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os import cv2 import numpy as np import torch +from pycolmap import logging import limap.util.io as limapio diff --git a/limap/line2d/LineTR/line_transformer.py b/limap/line2d/LineTR/line_transformer.py index a94e330..0d4dd24 100755 --- a/limap/line2d/LineTR/line_transformer.py +++ b/limap/line2d/LineTR/line_transformer.py @@ -1,9 +1,9 @@ -from pycolmap import logging from copy import deepcopy from pathlib import Path import torch from einops import repeat +from pycolmap import logging from torch import nn from .line_attention import FeedForward, MultiHeadAttention diff --git a/limap/line2d/SOLD2/misc/train_utils.py b/limap/line2d/SOLD2/misc/train_utils.py index 3561957..1a763da 100644 --- a/limap/line2d/SOLD2/misc/train_utils.py +++ b/limap/line2d/SOLD2/misc/train_utils.py @@ -2,11 +2,11 @@ This file contains some useful functions for train / val. """ -from pycolmap import logging import os import numpy as np import torch +from pycolmap import logging ################# diff --git a/limap/line2d/SOLD2/model/model_util.py b/limap/line2d/SOLD2/model/model_util.py index b514311..55fd642 100644 --- a/limap/line2d/SOLD2/model/model_util.py +++ b/limap/line2d/SOLD2/model/model_util.py @@ -1,7 +1,6 @@ -from pycolmap import logging - import torch.nn as nn import torch.nn.init as init +from pycolmap import logging from .nets.backbone import HourglassBackbone, SuperpointBackbone from .nets.descriptor_decoder import SuperpointDescriptor diff --git a/limap/line2d/SOLD2/sold2_wrapper.py b/limap/line2d/SOLD2/sold2_wrapper.py index e917678..6088eb3 100644 --- a/limap/line2d/SOLD2/sold2_wrapper.py +++ b/limap/line2d/SOLD2/sold2_wrapper.py @@ -1,10 +1,10 @@ -from pycolmap import logging import os import subprocess import cv2 import numpy as np import torch +from pycolmap import logging from skimage.draw import line from .experiment import load_config diff --git a/limap/line2d/SOLD2/train.py b/limap/line2d/SOLD2/train.py index 947b1a1..7585bc8 100644 --- a/limap/line2d/SOLD2/train.py +++ b/limap/line2d/SOLD2/train.py @@ -2,12 +2,11 @@ This file implements the training process and all the summaries """ -from pycolmap import logging - import cv2 import numpy as np import torch import torch.utils.data.dataloader as torch_loader +from pycolmap import logging from torch.nn.functional import pixel_shuffle, softmax # from model.lr_scheduler import get_lr_scheduler diff --git a/limap/line2d/TP_LSD/tp_lsd.py b/limap/line2d/TP_LSD/tp_lsd.py index b123c6f..796810f 100644 --- a/limap/line2d/TP_LSD/tp_lsd.py +++ b/limap/line2d/TP_LSD/tp_lsd.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os import cv2 import numpy as np import torch +from pycolmap import logging from tp_lsd.modeling.TP_Net import Res320 from tp_lsd.utils.reconstruct import TPS_line from tp_lsd.utils.utils import load_model diff --git a/limap/merging/merging.py b/limap/merging/merging.py index 7d81078..65286d8 100644 --- a/limap/merging/merging.py +++ b/limap/merging/merging.py @@ -1,7 +1,6 @@ -from pycolmap import logging - from _limap import _base from _limap import _merging as _mrg +from pycolmap import logging def merging(linker, all_2d_segs, imagecols, seg3d_list, neighbors, var2d=5.0): @@ -37,8 +36,8 @@ def remerge(linker3d, linetracks, num_outliers=2): break num_tracks = num_tracks_new logging.info( - f"[LOG] tracks after iterative remerging: \ - {len(new_linetracks)} / {len(linetracks)}" + f"[LOG] tracks after iterative remerging:" + f" {len(new_linetracks)} / {len(linetracks)}" ) return new_linetracks diff --git a/limap/optimize/line_refinement/line_refinement.py b/limap/optimize/line_refinement/line_refinement.py index bf232d2..9c7a854 100644 --- a/limap/optimize/line_refinement/line_refinement.py +++ b/limap/optimize/line_refinement/line_refinement.py @@ -1,7 +1,7 @@ -from pycolmap import logging import os import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/point2d/superglue/superglue.py b/limap/point2d/superglue/superglue.py index 1442607..f4e5942 100644 --- a/limap/point2d/superglue/superglue.py +++ b/limap/point2d/superglue/superglue.py @@ -40,13 +40,13 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -from pycolmap import logging import os from copy import deepcopy from pathlib import Path from typing import List, Tuple import torch +from pycolmap import logging from torch import nn diff --git a/limap/point2d/superpoint/main.py b/limap/point2d/superpoint/main.py index 14746f2..8735f99 100644 --- a/limap/point2d/superpoint/main.py +++ b/limap/point2d/superpoint/main.py @@ -1,5 +1,4 @@ import collections.abc as collections -from pycolmap import logging import pprint from pathlib import Path from typing import Dict, List, Optional, Union @@ -9,6 +8,7 @@ import torch from hloc import extract_features from hloc.utils.io import list_h5_names +from pycolmap import logging from tqdm import tqdm from .superpoint import SuperPoint diff --git a/limap/point2d/superpoint/superpoint.py b/limap/point2d/superpoint/superpoint.py index 80020d0..833a60e 100644 --- a/limap/point2d/superpoint/superpoint.py +++ b/limap/point2d/superpoint/superpoint.py @@ -40,11 +40,11 @@ # --------------------------------------------------------------------*/ # %BANNER_END% -from pycolmap import logging import os from pathlib import Path import torch +from pycolmap import logging from torch import nn diff --git a/limap/pointsfm/bundler_reader.py b/limap/pointsfm/bundler_reader.py index cd2e778..f125326 100644 --- a/limap/pointsfm/bundler_reader.py +++ b/limap/pointsfm/bundler_reader.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os import imagesize import numpy as np from _limap import _base, _pointsfm +from pycolmap import logging from tqdm import tqdm diff --git a/limap/pointsfm/colmap_reader.py b/limap/pointsfm/colmap_reader.py index f9952d0..9f896c4 100644 --- a/limap/pointsfm/colmap_reader.py +++ b/limap/pointsfm/colmap_reader.py @@ -1,8 +1,8 @@ -from pycolmap import logging import os import sys from _limap import _base +from pycolmap import logging sys.path.append(os.path.dirname(os.path.abspath(__file__))) from hloc.utils.read_write_model import ( diff --git a/limap/pointsfm/colmap_sfm.py b/limap/pointsfm/colmap_sfm.py index 6a3a801..01be792 100644 --- a/limap/pointsfm/colmap_sfm.py +++ b/limap/pointsfm/colmap_sfm.py @@ -1,5 +1,4 @@ import copy -from pycolmap import logging import os import shutil import subprocess @@ -7,6 +6,7 @@ from pathlib import Path import cv2 +from pycolmap import logging sys.path.append(os.path.dirname(os.path.abspath(__file__))) import hloc.utils.database as database diff --git a/limap/pointsfm/functions.py b/limap/pointsfm/functions.py index 85f89cf..0561c30 100644 --- a/limap/pointsfm/functions.py +++ b/limap/pointsfm/functions.py @@ -1,6 +1,5 @@ -from pycolmap import logging - from _limap import _pointsfm +from pycolmap import logging def filter_by_cam_id(cam_id, prev_imagecols, prev_neighbors): diff --git a/limap/runners/functions.py b/limap/runners/functions.py index ef7a2f7..d5795ab 100644 --- a/limap/runners/functions.py +++ b/limap/runners/functions.py @@ -1,6 +1,6 @@ -from pycolmap import logging import os +from pycolmap import logging from tqdm import tqdm import limap.line2d @@ -60,8 +60,8 @@ def undistort_images( unload_ids = imagecols.get_img_ids() if skip_exists: logging.info( - f"[LOG] Loading undistorted images \ - (n_images = {imagecols.NumImages()})..." + f"[LOG] Loading undistorted images " + f"(n_images = {imagecols.NumImages()})..." ) fname_in = os.path.join(output_dir, fname) if os.path.isfile(fname_in): @@ -213,8 +213,8 @@ def compute_2d_segs(cfg, imagecols, compute_descinfo=True): weight_path = cfg.get("weight_path", None) if "extractor" in cfg["line2d"]: logging.info( - "[LOG] Start 2D line detection and description \ - (detector = {}, extractor = {}, n_images = {})...".format( + "[LOG] Start 2D line detection and description " + "(detector = {}, extractor = {}, n_images = {})...".format( cfg["line2d"]["detector"]["method"], cfg["line2d"]["extractor"]["method"], imagecols.NumImages(), @@ -222,8 +222,8 @@ def compute_2d_segs(cfg, imagecols, compute_descinfo=True): ) else: logging.info( - "[LOG] Start 2D line detection and description \ - (detector = {}, n_images = {})...".format( + "[LOG] Start 2D line detection and description " + "(detector = {}, n_images = {})...".format( cfg["line2d"]["detector"]["method"], imagecols.NumImages() ) ) @@ -306,8 +306,8 @@ def compute_matches(cfg, descinfo_folder, image_ids, neighbors): """ weight_path = cfg.get("weight_path", None) logging.info( - "[LOG] Start matching 2D lines... (extractor = {}, matcher = {}, \ - n_images = {}, n_neighbors = {})".format( + "[LOG] Start matching 2D lines... (extractor = {}, matcher = {}," + "n_images = {}, n_neighbors = {})".format( cfg["line2d"]["extractor"]["method"], cfg["line2d"]["matcher"]["method"], len(image_ids), @@ -359,8 +359,8 @@ def compute_exhaustive_matches(cfg, descinfo_folder, image_ids): matches_folder (str): path to store the computed matches """ logging.info( - "[LOG] Start exhausive matching 2D lines... \ - (extractor = {}, matcher = {}, n_images = {})".format( + "[LOG] Start exhausive matching 2D lines..." + "(extractor = {}, matcher = {}, n_images = {})".format( cfg["line2d"]["extractor"]["method"], cfg["line2d"]["matcher"]["method"], len(image_ids), diff --git a/limap/runners/functions_structures.py b/limap/runners/functions_structures.py index 215c6ae..669dbeb 100644 --- a/limap/runners/functions_structures.py +++ b/limap/runners/functions_structures.py @@ -1,7 +1,7 @@ -from pycolmap import logging import os import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.pointsfm as pointsfm diff --git a/limap/runners/hybrid_localization.py b/limap/runners/hybrid_localization.py index 8369817..3fd617b 100644 --- a/limap/runners/hybrid_localization.py +++ b/limap/runners/hybrid_localization.py @@ -1,9 +1,9 @@ -from pycolmap import logging import os from collections import defaultdict import numpy as np from hloc.utils.io import get_keypoints, get_matches +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/runners/line_fitnmerge.py b/limap/runners/line_fitnmerge.py index 995e9e2..1905f6e 100644 --- a/limap/runners/line_fitnmerge.py +++ b/limap/runners/line_fitnmerge.py @@ -1,8 +1,8 @@ -from pycolmap import logging import os import joblib import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/runners/line_triangulation.py b/limap/runners/line_triangulation.py index 683b3da..e1a0349 100644 --- a/limap/runners/line_triangulation.py +++ b/limap/runners/line_triangulation.py @@ -1,6 +1,6 @@ -from pycolmap import logging import os +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/util/evaluation.py b/limap/util/evaluation.py index 78c599a..5687a13 100644 --- a/limap/util/evaluation.py +++ b/limap/util/evaluation.py @@ -1,7 +1,6 @@ -from pycolmap import logging - import cv2 import numpy as np +from pycolmap import logging import limap.base as base diff --git a/limap/util/io.py b/limap/util/io.py index 5078dd5..1dad7d5 100644 --- a/limap/util/io.py +++ b/limap/util/io.py @@ -1,8 +1,8 @@ -from pycolmap import logging import os import shutil import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base diff --git a/limap/visualize/trackvis/base.py b/limap/visualize/trackvis/base.py index cf293d4..e7fd644 100644 --- a/limap/visualize/trackvis/base.py +++ b/limap/visualize/trackvis/base.py @@ -1,6 +1,5 @@ -from pycolmap import logging - import numpy as np +from pycolmap import logging from ..vis_utils import test_line_inside_ranges @@ -26,13 +25,13 @@ def report(self): def report_stats(self): counts = np.array(self.counts) logging.info( - f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) =" \ - f" ({counts[counts >= 2].shape[0]}," \ - f" {counts[counts >= 4].shape[0]}," \ - f" {counts[counts >= 6].shape[0]}," \ - f" {counts[counts >= 8].shape[0]}," \ - f" {counts[counts >= 10].shape[0]}," \ - f" {counts[counts >= 20].shape[0]}," \ + f"[Track Report] (N2, N4, N6, N8, N10, N20, N50) =" + f" ({counts[counts >= 2].shape[0]}," + f" {counts[counts >= 4].shape[0]}," + f" {counts[counts >= 6].shape[0]}," + f" {counts[counts >= 8].shape[0]}," + f" {counts[counts >= 10].shape[0]}," + f" {counts[counts >= 20].shape[0]}," f" {counts[counts >= 50].shape[0]})" ) @@ -42,12 +41,12 @@ def report_avg_supports(self, n_visible_views=4): arr = counts[counts >= n_visible_views] arr_lines = counts_lines[counts >= n_visible_views] logging.info( - f"average supporting images (>= {n_visible_views}):" \ + f"average supporting images (>= {n_visible_views}):" f" {arr.sum()} / {arr.shape[0]} = {arr.mean():.2f}" ) logging.info( - f"average supporting lines (>= {n_visible_views}):" \ - f" {arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" + f"average supporting lines (>= {n_visible_views}): " + f"{arr_lines.sum()} / {arr_lines.shape[0]} = {arr_lines.mean():.2f}" ) def get_counts_np(self): diff --git a/limap/visualize/vis_utils.py b/limap/visualize/vis_utils.py index 71f4984..142a495 100644 --- a/limap/visualize/vis_utils.py +++ b/limap/visualize/vis_utils.py @@ -1,11 +1,11 @@ import copy -from pycolmap import logging import os import cv2 import matplotlib.pyplot as plt import numpy as np import seaborn as sns +from pycolmap import logging def random_color(): From c0014a0a1dcbf2ec68d7c68b7c9635d3c71c6a25 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:30:28 +0100 Subject: [PATCH 11/13] E501 --- scripts/eval_hypersim.py | 8 ++++---- scripts/eval_tnt.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/eval_hypersim.py b/scripts/eval_hypersim.py index b584e75..405a011 100644 --- a/scripts/eval_hypersim.py +++ b/scripts/eval_hypersim.py @@ -61,8 +61,8 @@ def report_error_to_GT(evaluator, lines, vis_err_th=None): print("R: recall, P: precision") for idx, threshold in enumerate(thresholds): print( - f"R / P at {int(threshold * 1000)}mm: \ - {list_recall[idx]:.2f} / {list_precision[idx]:.2f}" + f"R / P at {int(threshold * 1000)}mm: " \ + f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -283,8 +283,8 @@ def main(): [track.count_lines() for track in linetracks] ) print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} \ - / {sup_line_counts.mean():.2f})" + f"supporting images / lines: ({sup_image_counts.mean():.2f} " \ + f"/ {sup_line_counts.mean():.2f})" ) diff --git a/scripts/eval_tnt.py b/scripts/eval_tnt.py index b7297a1..d71323e 100644 --- a/scripts/eval_tnt.py +++ b/scripts/eval_tnt.py @@ -32,8 +32,8 @@ def report_error_to_GT(evaluator, lines): list_precision.append(precision) for idx, threshold in enumerate(thresholds): print( - f"R / P at {int(threshold * 1000)}mm: \ - {list_recall[idx]:.2f} / {list_precision[idx]:.2f}" + f"R / P at {int(threshold * 1000)}mm: " \ + f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -52,8 +52,8 @@ def report_pc_recall_for_GT(evaluator, lines): num_inliers = (point_dists < threshold).sum() point_recall = 100 * num_inliers / n_points print( - f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, \ - point recall = {point_recall:.2f}" + f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, " \ + f"point recall = {point_recall:.2f}" ) return evaluator @@ -279,8 +279,8 @@ def main(): [track.count_lines() for track in linetracks] ) print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} \ - / {sup_line_counts.mean():.2f})" + f"supporting images / lines: ({sup_image_counts.mean():.2f} " \ + f"/ {sup_line_counts.mean():.2f})" ) From bb3fcf85968055445bc17fe82d30d750c161a709 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:34:02 +0100 Subject: [PATCH 12/13] fix scripts --- scripts/eval_hypersim.py | 13 +++++++------ scripts/eval_tnt.py | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/eval_hypersim.py b/scripts/eval_hypersim.py index 405a011..d91c0ae 100644 --- a/scripts/eval_hypersim.py +++ b/scripts/eval_hypersim.py @@ -4,6 +4,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import matplotlib.pyplot as plt import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.evaluation as limap_eval @@ -58,10 +59,10 @@ def report_error_to_GT(evaluator, lines, vis_err_th=None): list_recall.append(length_recall) precision = 100 * (ratios > 0).astype(int).sum() / ratios.shape[0] list_precision.append(precision) - print("R: recall, P: precision") + logging.info("R: recall, P: precision") for idx, threshold in enumerate(thresholds): - print( - f"R / P at {int(threshold * 1000)}mm: " \ + logging.info( + f"R / P at {int(threshold * 1000)}mm: " f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -75,7 +76,7 @@ def read_ply(fname): y = np.asarray(plydata.elements[0].data["y"]) z = np.asarray(plydata.elements[0].data["z"]) points = np.stack([x, y, z], axis=1) - print(f"number of points: {points.shape[0]}") + logging.info(f"number of points: {points.shape[0]}") return points @@ -282,8 +283,8 @@ def main(): sup_line_counts = np.array( [track.count_lines() for track in linetracks] ) - print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} " \ + logging.info( + f"supporting images / lines: ({sup_image_counts.mean():.2f} " f"/ {sup_line_counts.mean():.2f})" ) diff --git a/scripts/eval_tnt.py b/scripts/eval_tnt.py index d71323e..5cb7678 100644 --- a/scripts/eval_tnt.py +++ b/scripts/eval_tnt.py @@ -4,6 +4,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import matplotlib.pyplot as plt import numpy as np +from pycolmap import logging from tqdm import tqdm import limap.base as base @@ -31,8 +32,8 @@ def report_error_to_GT(evaluator, lines): precision = 100 * (ratios > 0).astype(int).sum() / ratios.shape[0] list_precision.append(precision) for idx, threshold in enumerate(thresholds): - print( - f"R / P at {int(threshold * 1000)}mm: " \ + logging.info( + f"R / P at {int(threshold * 1000)}mm: " f"{list_recall[idx]:.2f} / {list_precision[idx]:.2f}" ) return evaluator @@ -47,12 +48,12 @@ def report_pc_recall_for_GT(evaluator, lines): # point_dists = evaluator.ComputeDistsforEachPoint_KDTree(lines) point_dists = np.array(point_dists) n_points = point_dists.shape[0] - print("Compute point recall metrics.") + logging.info("Compute point recall metrics.") for threshold in thresholds.tolist(): num_inliers = (point_dists < threshold).sum() point_recall = 100 * num_inliers / n_points - print( - f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, " \ + logging.info( + f"{int(threshold * 1000):.0f}mm, inliers = {num_inliers}, " f"point recall = {point_recall:.2f}" ) return evaluator @@ -66,7 +67,7 @@ def read_ply(fname): y = np.asarray(plydata.elements[0].data["y"]) z = np.asarray(plydata.elements[0].data["z"]) points = np.stack([x, y, z], axis=1) - print(f"number of points: {points.shape[0]}") + logging.info(f"number of points: {points.shape[0]}") return points @@ -118,7 +119,7 @@ def eval_tnt(cfg, lines, ref_lines=None): for line in lines if limapvis.test_line_inside_ranges(line, ranges) ] - print(f"Filtering by range: {len(lines)} / {n_lines}") + logging.info(f"Filtering by range: {len(lines)} / {n_lines}") evaluator = report_error_to_point_cloud( points, lines, kdtree_dir=cfg["kdtree_dir"] ) @@ -215,7 +216,6 @@ def parse_config(): cfg["noeval"] = args.noeval cfg["transform_txt"] = args.transform_txt cfg["use_ranges"] = args.use_ranges - # print(cfg) return cfg @@ -278,8 +278,8 @@ def main(): sup_line_counts = np.array( [track.count_lines() for track in linetracks] ) - print( - f"supporting images / lines: ({sup_image_counts.mean():.2f} " \ + logging.info( + f"supporting images / lines: ({sup_image_counts.mean():.2f} " f"/ {sup_line_counts.mean():.2f})" ) From ae0872fe6c497e4d95adbae9faa5f39679cff522 Mon Sep 17 00:00:00 2001 From: B1ueber2y Date: Tue, 26 Nov 2024 19:36:20 +0100 Subject: [PATCH 13/13] remove python json logger --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b4f44fa..ebd63c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,6 @@ imagesize einops ninja yacs -python-json-logger pycolmap ruff==0.6.7 clang-format==19.1.0