Skip to content

Commit

Permalink
Fix different input/output conventions for tiny RoMa
Browse files Browse the repository at this point in the history
  • Loading branch information
pautratrmi committed Oct 23, 2024
1 parent 7248ddd commit 1207f5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion limap/line2d/dense/dense_matcher/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_sample_thresh(self):
"""
raise NotImplementedError

def get_warpping_symmetric(self, img1, img2):
def get_warping_symmetric(self, img1, img2):
"""
return warp_1to2 ([-1, 1]), cert_1to2, warp_2to1([-1, 1]), cert_2to1
"""
Expand Down
28 changes: 19 additions & 9 deletions limap/line2d/dense/dense_matcher/roma.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@
class RoMa(BaseDenseMatcher):
def __init__(self, mode="outdoor", device="cuda"):
super(RoMa).__init__()
self.output_res = 864
self.mode = mode
if mode == "outdoor":
self.model = romatch.roma_outdoor(device=device, coarse_res=560)
self.model = romatch.roma_outdoor(
device=device, coarse_res=560, upsample_res=self.output_res
)
elif mode == "indoor":
self.model = romatch.roma_indoor(device=device, coarse_res=560)
self.model = romatch.roma_indoor(
device=device, coarse_res=560, upsample_res=self.output_res
)
elif mode == "tiny_outdoor":
self.model = romatch.tiny_roma_v1_outdoor(device=device)

def get_sample_thresh(self):
return self.model.sample_thresh

def get_warpping_symmetric(self, img1, img2):
def get_warping_symmetric(self, img1, img2):
warp, certainty = self.model.match(
Image.fromarray(img1), Image.fromarray(img2)
Image.fromarray(img1), Image.fromarray(img2), batched=False
)
N = 864
if self.mode.startswith("tiny"):
warp2_to_1, certainty2_to_1 = self.model.match(
Image.fromarray(img2), Image.fromarray(img1), batched=False
)
return warp[:, :, 2:], certainty, warp2_to_1[:, :, 2:], certainty2_to_1
return (
warp[:, :N, 2:],
certainty[:, :N],
warp[:, N:, :2],
certainty[:, N:],
warp[:, : self.output_res, 2:],
certainty[:, : self.output_res],
warp[:, self.output_res :, :2],
certainty[:, self.output_res :],
)
2 changes: 1 addition & 1 deletion limap/line2d/dense/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def match_segs_with_descinfo(self, descinfo1, descinfo2):
cert_1to2,
warp_2to1,
cert_2to1,
) = self.dense_matcher.get_warpping_symmetric(img1, img2)
) = self.dense_matcher.get_warping_symmetric(img1, img2)

# compute distance and overlap
dists_1to2, overlap_1to2 = self.compute_distance_one_direction(
Expand Down

0 comments on commit 1207f5f

Please sign in to comment.