xuelunshen commited on
Commit
0b88271
1 Parent(s): 9a4378d

Print timestamp for debug

Browse files
Files changed (3) hide show
  1. app.py +2 -0
  2. common/utils.py +15 -0
  3. hloc/matchers/gim.py +6 -1
app.py CHANGED
@@ -328,6 +328,8 @@ def run(config):
328
  )
329
 
330
  app.queue().launch(share=False)
 
 
331
 
332
 
333
  if __name__ == "__main__":
 
328
  )
329
 
330
  app.queue().launch(share=False)
331
+ import datetime
332
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'app.queue().launch start')
333
 
334
 
335
  if __name__ == "__main__":
common/utils.py CHANGED
@@ -327,6 +327,8 @@ def run_matching(
327
  ransac_max_iter=DEFAULT_RANSAC_MAX_ITER,
328
  choice_estimate_geom=DEFAULT_SETTING_GEOMETRY,
329
  ):
 
 
330
  # image0 and image1 is RGB mode
331
  if image0 is None or image1 is None:
332
  raise gr.Error("Error: No images found! Please upload two images.")
@@ -368,7 +370,11 @@ def run_matching(
368
  "Image 0 - Keypoints",
369
  "Image 1 - Keypoints",
370
  ]
 
 
371
  output_keypoints = plot_images([image0, image1], titles=titles, dpi=300)
 
 
372
  if "keypoints0" in pred.keys() and "keypoints1" in pred.keys():
373
  plot_keypoints([pred["keypoints0"], pred["keypoints1"]])
374
  text = (
@@ -377,6 +383,7 @@ def run_matching(
377
  )
378
  add_text(0, text, fs=15)
379
  output_keypoints = fig2im(output_keypoints)
 
380
 
381
  # plot images with raw matches
382
  titles = [
@@ -384,9 +391,12 @@ def run_matching(
384
  "Image 1 - Raw matched keypoints",
385
  ]
386
 
 
387
  output_matches_raw, num_matches_raw = display_matches(pred, titles=titles)
 
388
 
389
  # if enable_ransac:
 
390
  filter_matches(
391
  pred,
392
  ransac_method=ransac_method,
@@ -394,17 +404,21 @@ def run_matching(
394
  ransac_confidence=ransac_confidence,
395
  ransac_max_iter=ransac_max_iter,
396
  )
 
397
 
398
  # plot images with ransac matches
399
  titles = [
400
  "Image 0 - Ransac matched keypoints",
401
  "Image 1 - Ransac matched keypoints",
402
  ]
 
403
  output_matches_ransac, num_matches_ransac = display_matches(
404
  pred, titles=titles
405
  )
 
406
 
407
  # plot wrapped images
 
408
  geom_info = compute_geom(pred)
409
  output_wrapped, _ = change_estimate_geom(
410
  pred["image0_orig"],
@@ -412,6 +426,7 @@ def run_matching(
412
  {"geom_info": geom_info},
413
  choice_estimate_geom,
414
  )
 
415
 
416
  del pred
417
 
 
327
  ransac_max_iter=DEFAULT_RANSAC_MAX_ITER,
328
  choice_estimate_geom=DEFAULT_SETTING_GEOMETRY,
329
  ):
330
+ import datetime
331
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'run_matching start')
332
  # image0 and image1 is RGB mode
333
  if image0 is None or image1 is None:
334
  raise gr.Error("Error: No images found! Please upload two images.")
 
370
  "Image 0 - Keypoints",
371
  "Image 1 - Keypoints",
372
  ]
373
+ import datetime
374
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot_images start')
375
  output_keypoints = plot_images([image0, image1], titles=titles, dpi=300)
376
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot_images end')
377
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot_keypoints start')
378
  if "keypoints0" in pred.keys() and "keypoints1" in pred.keys():
379
  plot_keypoints([pred["keypoints0"], pred["keypoints1"]])
380
  text = (
 
383
  )
384
  add_text(0, text, fs=15)
385
  output_keypoints = fig2im(output_keypoints)
386
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot_keypoints end')
387
 
388
  # plot images with raw matches
389
  titles = [
 
391
  "Image 1 - Raw matched keypoints",
392
  ]
393
 
394
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot images with raw matches start')
395
  output_matches_raw, num_matches_raw = display_matches(pred, titles=titles)
396
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot images with raw matches end')
397
 
398
  # if enable_ransac:
399
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'filter_matches start')
400
  filter_matches(
401
  pred,
402
  ransac_method=ransac_method,
 
404
  ransac_confidence=ransac_confidence,
405
  ransac_max_iter=ransac_max_iter,
406
  )
407
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'filter_matches end')
408
 
409
  # plot images with ransac matches
410
  titles = [
411
  "Image 0 - Ransac matched keypoints",
412
  "Image 1 - Ransac matched keypoints",
413
  ]
414
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot images with raw matches start')
415
  output_matches_ransac, num_matches_ransac = display_matches(
416
  pred, titles=titles
417
  )
418
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot images with raw matches end')
419
 
420
  # plot wrapped images
421
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot wrapped images start')
422
  geom_info = compute_geom(pred)
423
  output_wrapped, _ = change_estimate_geom(
424
  pred["image0_orig"],
 
426
  {"geom_info": geom_info},
427
  choice_estimate_geom,
428
  )
429
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'plot wrapped images end')
430
 
431
  del pred
432
 
hloc/matchers/gim.py CHANGED
@@ -38,7 +38,7 @@ class GIM(BaseModel):
38
  cmd = ["wget", link, "-O", str(model_path)]
39
  logger.info(f"Downloading the DKMv3 model with `{cmd}`.")
40
  subprocess.run(cmd, check=True)
41
- logger.info(f"Loading GIM model...")
42
  # self.net = DKMv3(path_to_weights=str(model_path), device=device)
43
 
44
  model = DKMv3(None, 672, 896, upsample_preds=True)
@@ -97,8 +97,13 @@ class GIM(BaseModel):
97
  pad_right1 = pad_width1 - pad_left1
98
  image0 = torch.nn.functional.pad(image0, (pad_left0, pad_right0, pad_top0, pad_bottom0))
99
  image1 = torch.nn.functional.pad(image1, (pad_left1, pad_right1, pad_top1, pad_bottom1))
 
 
100
  dense_matches, dense_certainty = self.net.match(image0, image1)
 
 
101
  sparse_matches, mconf = self.net.sample(dense_matches, dense_certainty, self.conf["max_keypoints"])
 
102
  height0, width0 = image0.shape[-2:]
103
  height1, width1 = image1.shape[-2:]
104
  kpts0 = sparse_matches[:, :2]
 
38
  cmd = ["wget", link, "-O", str(model_path)]
39
  logger.info(f"Downloading the DKMv3 model with `{cmd}`.")
40
  subprocess.run(cmd, check=True)
41
+ # logger.info(f"Loading GIM model...")
42
  # self.net = DKMv3(path_to_weights=str(model_path), device=device)
43
 
44
  model = DKMv3(None, 672, 896, upsample_preds=True)
 
97
  pad_right1 = pad_width1 - pad_left1
98
  image0 = torch.nn.functional.pad(image0, (pad_left0, pad_right0, pad_top0, pad_bottom0))
99
  image1 = torch.nn.functional.pad(image1, (pad_left1, pad_right1, pad_top1, pad_bottom1))
100
+ import datetime
101
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'self.net.match start')
102
  dense_matches, dense_certainty = self.net.match(image0, image1)
103
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'self.net.match end')
104
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'self.net.sample start')
105
  sparse_matches, mconf = self.net.sample(dense_matches, dense_certainty, self.conf["max_keypoints"])
106
+ print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'self.net.sample end')
107
  height0, width0 = image0.shape[-2:]
108
  height1, width1 = image1.shape[-2:]
109
  kpts0 = sparse_matches[:, :2]