Skip to content

Commit

Permalink
remove threading to avoid trying reading features before they are suc…
Browse files Browse the repository at this point in the history
…cessfully stored on disk
  • Loading branch information
franioli committed Mar 15, 2024
1 parent 8e7ce68 commit 7e9a9e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 28 deletions.
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
try:
# To be sure, check if pycolmap is available, otherwise skip reconstruction
pycolmap = import_module("pycolmap")
logger.info(f"Using pycolmap version {pycolmap.__version__}")
except ImportError:
logger.error("Pycomlap is not available.")
use_pycolmap = False
Expand Down
15 changes: 5 additions & 10 deletions src/deep_image_matching/extractors/extractor_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import inspect
import threading
from abc import ABCMeta, abstractmethod
from pathlib import Path
from typing import Optional, Tuple, TypedDict, Union
Expand Down Expand Up @@ -221,18 +220,14 @@ def extract(self, img: Union[Image, Path, str]) -> np.ndarray:
features["image_size"] = np.array(image.shape[:2])

# Save features to disk in h5 format
h5_thread = threading.Thread(
target=lambda: save_features_h5(
feature_path,
features,
im_path.name,
as_half=self.features_as_half,
)
save_features_h5(
feature_path,
features,
im_path.name,
as_half=self.features_as_half,
)
h5_thread.start()

# For debug: visualize keypoints and save to disk
# Do everything in a separate thread not to block the main thread
if self._config["general"]["verbose"]:
viz_dir = output_dir / "debug" / "keypoints"
viz_dir.mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 0 additions & 2 deletions src/deep_image_matching/image_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ def match_pairs(self, feature_path: Path, try_full_image: bool = False) -> Path:
timer.update("Match pair")

# NOTE: Geometric verif. has been moved to the end of the matching process
# if matches is None:
# continue

# TODO: Clean up features with no matches

Expand Down
27 changes: 11 additions & 16 deletions src/deep_image_matching/matchers/matcher_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import inspect
import threading
from abc import ABCMeta, abstractmethod
from itertools import product
from pathlib import Path
Expand Down Expand Up @@ -364,21 +363,17 @@ def match(

# For debugging
if self._config["general"]["verbose"]:

def debug_viz():
viz_dir = self._output_dir / "debug" / "matches"
viz_dir.mkdir(parents=True, exist_ok=True)
self.viz_matches(
feature_path,
matches_path,
img0,
img1,
save_path=viz_dir / f"{img0_name}_{img1_name}.jpg",
img_format="jpg",
jpg_quality=70,
)

threading.Thread(target=debug_viz()).start()
viz_dir = self._output_dir / "debug" / "matches"
viz_dir.mkdir(parents=True, exist_ok=True)
self.viz_matches(
feature_path,
matches_path,
img0,
img1,
save_path=viz_dir / f"{img0_name}_{img1_name}.jpg",
img_format="jpg",
jpg_quality=70,
)

return matches

Expand Down

0 comments on commit 7e9a9e9

Please sign in to comment.