Vincentqyw commited on
Commit
62cd4d6
1 Parent(s): e0f1139

update: wrapper functions

Browse files
app.py CHANGED
@@ -298,7 +298,7 @@ def run(config):
298
  outputs=[output_wrapped, geometry_result],
299
  )
300
 
301
- app.launch(share=False)
302
 
303
 
304
  if __name__ == "__main__":
 
298
  outputs=[output_wrapped, geometry_result],
299
  )
300
 
301
+ app.queue().launch(share=False)
302
 
303
 
304
  if __name__ == "__main__":
common/utils.py CHANGED
@@ -458,11 +458,11 @@ matcher_zoo = {
458
  "config_feature": extract_features.confs["d2net-ss"],
459
  "dense": False,
460
  },
461
- "d2net-ms": {
462
- "config": match_features.confs["NN-mutual"],
463
- "config_feature": extract_features.confs["d2net-ms"],
464
- "dense": False,
465
- },
466
  "alike": {
467
  "config": match_features.confs["NN-mutual"],
468
  "config_feature": extract_features.confs["alike"],
 
458
  "config_feature": extract_features.confs["d2net-ss"],
459
  "dense": False,
460
  },
461
+ # "d2net-ms": {
462
+ # "config": match_features.confs["NN-mutual"],
463
+ # "config_feature": extract_features.confs["d2net-ms"],
464
+ # "dense": False,
465
+ # },
466
  "alike": {
467
  "config": match_features.confs["NN-mutual"],
468
  "config_feature": extract_features.confs["alike"],
hloc/extractors/disk.py CHANGED
@@ -26,7 +26,7 @@ class DISK(BaseModel):
26
  pad_if_not_divisible=self.conf["pad_if_not_divisible"],
27
  )
28
  return {
29
- "keypoints": [f.keypoints for f in features],
30
- "scores": [f.detection_scores for f in features],
31
- "descriptors": [f.descriptors.t() for f in features],
32
  }
 
26
  pad_if_not_divisible=self.conf["pad_if_not_divisible"],
27
  )
28
  return {
29
+ "keypoints": [f.keypoints for f in features][0][None],
30
+ "scores": [f.detection_scores for f in features][0][None],
31
+ "descriptors": [f.descriptors.t() for f in features][0][None],
32
  }
hloc/match_features.py CHANGED
@@ -330,14 +330,20 @@ def match_images(model, feat0, feat1):
330
  desc0 = desc0.unsqueeze(0)
331
  if len(desc1.shape) == 2:
332
  desc1 = desc1.unsqueeze(0)
 
 
 
 
 
 
333
  pred = model(
334
  {
335
  "image0": feat0["image"],
336
- "keypoints0": feat0["keypoints"][0],
337
  "scores0": feat0["scores"][0].unsqueeze(0),
338
  "descriptors0": desc0,
339
  "image1": feat1["image"],
340
- "keypoints1": feat1["keypoints"][0],
341
  "scores1": feat1["scores"][0].unsqueeze(0),
342
  "descriptors1": desc1,
343
  }
 
330
  desc0 = desc0.unsqueeze(0)
331
  if len(desc1.shape) == 2:
332
  desc1 = desc1.unsqueeze(0)
333
+
334
+ if isinstance(feat0["keypoints"], list):
335
+ feat0["keypoints"] = feat0["keypoints"][0][None]
336
+ if isinstance(feat1["keypoints"], list):
337
+ feat1["keypoints"] = feat1["keypoints"][0][None]
338
+
339
  pred = model(
340
  {
341
  "image0": feat0["image"],
342
+ "keypoints0": feat0["keypoints"],
343
  "scores0": feat0["scores"][0].unsqueeze(0),
344
  "descriptors0": desc0,
345
  "image1": feat1["image"],
346
+ "keypoints1": feat1["keypoints"],
347
  "scores1": feat1["scores"][0].unsqueeze(0),
348
  "descriptors1": desc1,
349
  }
hloc/matchers/lightglue.py CHANGED
@@ -42,12 +42,12 @@ class LightGlue(BaseModel):
42
  input = {}
43
  input["image0"] = {
44
  "image": data["image0"],
45
- "keypoints": data["keypoints0"][None],
46
  "descriptors": data["descriptors0"].permute(0, 2, 1),
47
  }
48
  input["image1"] = {
49
  "image": data["image1"],
50
- "keypoints": data["keypoints1"][None],
51
  "descriptors": data["descriptors1"].permute(0, 2, 1),
52
  }
53
  return self.net(input)
 
42
  input = {}
43
  input["image0"] = {
44
  "image": data["image0"],
45
+ "keypoints": data["keypoints0"],
46
  "descriptors": data["descriptors0"].permute(0, 2, 1),
47
  }
48
  input["image1"] = {
49
  "image": data["image1"],
50
+ "keypoints": data["keypoints1"],
51
  "descriptors": data["descriptors1"].permute(0, 2, 1),
52
  }
53
  return self.net(input)
hloc/matchers/sgmnet.py CHANGED
@@ -82,8 +82,8 @@ class SGMNet(BaseModel):
82
  logger.info(f"Load SGMNet model done.")
83
 
84
  def _forward(self, data):
85
- x1 = data["keypoints0"] # N x 2
86
- x2 = data["keypoints1"]
87
  score1 = data["scores0"].reshape(-1, 1) # N x 1
88
  score2 = data["scores1"].reshape(-1, 1)
89
  desc1 = data["descriptors0"].permute(0, 2, 1) # 1 x N x 128
 
82
  logger.info(f"Load SGMNet model done.")
83
 
84
  def _forward(self, data):
85
+ x1 = data["keypoints0"].squeeze() # N x 2
86
+ x2 = data["keypoints1"].squeeze()
87
  score1 = data["scores0"].reshape(-1, 1) # N x 1
88
  score2 = data["scores1"].reshape(-1, 1)
89
  desc1 = data["descriptors0"].permute(0, 2, 1) # 1 x N x 128