Skip to content

Commit

Permalink
merge and fix linting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ueber2y committed Nov 24, 2024
1 parent d355819 commit 9141712
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion limap/line2d/dense/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .extractor import DenseNaiveExtractor
from .matcher import BaseDenseLineMatcherOptions, RoMaLineMatcher
from .matcher import RoMaLineMatcher

__all__ = ["DenseNaiveExtractor", "RoMaLineMatcher"]
2 changes: 2 additions & 0 deletions limap/line2d/dense/dense_matcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .base import BaseDenseMatcher
from .roma import RoMa

__all__ = ["BaseDenseMatcher", "RoMa"]
2 changes: 0 additions & 2 deletions limap/line2d/dense/dense_matcher/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

import torch


Expand Down
2 changes: 0 additions & 2 deletions limap/line2d/dense/dense_matcher/roma.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

import romatch
from PIL import Image

Expand Down
4 changes: 2 additions & 2 deletions limap/line2d/dense/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import limap.util.io as limapio

from ..base_detector import BaseDetector, BaseDetectorOptions
from ..base_detector import BaseDetector, DefaultDetectorOptions


class DenseNaiveExtractor(BaseDetector):
def __init__(self, options=BaseDetectorOptions(), device=None):
def __init__(self, options=DefaultDetectorOptions, device=None):
super().__init__(options)

def get_module_name(self):
Expand Down
19 changes: 12 additions & 7 deletions limap/line2d/dense/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
import torch.nn.functional as F

from ..base_matcher import BaseMatcher, BaseMatcherOptions
from ..base_matcher import BaseMatcher, DefaultMatcherOptions
from .dense_matcher import BaseDenseMatcher


Expand All @@ -16,13 +16,16 @@ class BaseDenseLineMatcherOptions(NamedTuple):
one_to_many: bool = False


DefaultDenseLineMatcherOptions = BaseDenseLineMatcherOptions()


class BaseDenseLineMatcher(BaseMatcher):
def __init__(
self,
extractor,
dense_matcher,
dense_options=BaseDenseLineMatcherOptions(),
options=BaseMatcherOptions(),
dense_options=DefaultDenseLineMatcherOptions,
options=DefaultMatcherOptions,
):
super().__init__(extractor, options)
assert self.extractor.get_module_name() == "dense_naive"
Expand Down Expand Up @@ -169,7 +172,8 @@ def match_segs_with_descinfo(self, descinfo1, descinfo2):
dists = torch.where(
overlap_1to2 > overlap_2to1.T, dists_1to2, dists_2to1.T
)
# Both warps must have a minimum overlap and close distance (= equivalent of mutual nearest neighbor)
# Both warps must have a minimum overlap and close distance
# (= equivalent of mutual nearest neighbor)
overlap = torch.minimum(overlap_1to2, overlap_2to1.T)
dists[overlap < self.dense_options.segment_percentage_th] = 10000
dists[
Expand Down Expand Up @@ -213,7 +217,8 @@ def match_segs_with_descinfo_topk(self, descinfo1, descinfo2, topk=10):
dists = torch.where(
overlap_1to2 > overlap_2to1.T, dists_1to2, dists_2to1.T
)
# Both warps must have a minimum overlap and close distance (= equivalent of mutual nearest neighbor)
# Both warps must have a minimum overlap and close distance
# (= equivalent of mutual nearest neighbor)
overlap = torch.minimum(overlap_1to2, overlap_2to1.T)
dists[overlap < self.dense_options.segment_percentage_th] = 10000
dists[
Expand All @@ -238,8 +243,8 @@ def __init__(
self,
extractor,
mode="outdoor",
dense_options=BaseDenseLineMatcherOptions(),
options=BaseMatcherOptions(),
dense_options=DefaultDenseLineMatcherOptions,
options=DefaultMatcherOptions,
):
from .dense_matcher import RoMa

Expand Down

0 comments on commit 9141712

Please sign in to comment.