Spaces:
Build error
Build error
fix: warnings
Browse files- common/utils.py +13 -9
common/utils.py
CHANGED
|
@@ -21,12 +21,7 @@ from .viz import (
|
|
| 21 |
import time
|
| 22 |
import matplotlib.pyplot as plt
|
| 23 |
import warnings
|
| 24 |
-
|
| 25 |
-
warnings.filterwarnings("ignore", category=UserWarning)
|
| 26 |
-
warnings.filterwarnings(
|
| 27 |
-
"ignore", category=gr.deprecation.GradioDeprecationWarning
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 31 |
|
| 32 |
ROOT = Path(__file__).parent.parent
|
|
@@ -478,8 +473,11 @@ def run_matching(
|
|
| 478 |
# update match config
|
| 479 |
match_conf["model"]["match_threshold"] = match_threshold
|
| 480 |
match_conf["model"]["max_keypoints"] = extract_max_keypoints
|
| 481 |
-
|
| 482 |
matcher = get_model(match_conf)
|
|
|
|
|
|
|
|
|
|
| 483 |
if model["dense"]:
|
| 484 |
pred = match_dense.match_images(
|
| 485 |
matcher, image0, image1, match_conf["preprocessing"], device=device
|
|
@@ -500,7 +498,8 @@ def run_matching(
|
|
| 500 |
)
|
| 501 |
pred = match_features.match_images(matcher, pred0, pred1)
|
| 502 |
del extractor
|
| 503 |
-
|
|
|
|
| 504 |
# plot images with keypoints
|
| 505 |
titles = [
|
| 506 |
"Image 0 - Keypoints",
|
|
@@ -532,6 +531,7 @@ def run_matching(
|
|
| 532 |
ransac_confidence=ransac_confidence,
|
| 533 |
ransac_max_iter=ransac_max_iter,
|
| 534 |
)
|
|
|
|
| 535 |
|
| 536 |
# plot images with ransac matches
|
| 537 |
titles = [
|
|
@@ -542,6 +542,7 @@ def run_matching(
|
|
| 542 |
pred, titles=titles
|
| 543 |
)
|
| 544 |
|
|
|
|
| 545 |
# plot wrapped images
|
| 546 |
geom_info = compute_geom(pred)
|
| 547 |
output_wrapped, _ = change_estimate_geom(
|
|
@@ -550,9 +551,12 @@ def run_matching(
|
|
| 550 |
{"geom_info": geom_info},
|
| 551 |
choice_estimate_geom,
|
| 552 |
)
|
|
|
|
| 553 |
plt.close("all")
|
| 554 |
del pred
|
| 555 |
-
logger.info(f"TOTAL time: {time.time()-
|
|
|
|
|
|
|
| 556 |
return (
|
| 557 |
output_keypoints,
|
| 558 |
output_matches_raw,
|
|
|
|
| 21 |
import time
|
| 22 |
import matplotlib.pyplot as plt
|
| 23 |
import warnings
|
| 24 |
+
warnings.simplefilter("ignore")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 26 |
|
| 27 |
ROOT = Path(__file__).parent.parent
|
|
|
|
| 473 |
# update match config
|
| 474 |
match_conf["model"]["match_threshold"] = match_threshold
|
| 475 |
match_conf["model"]["max_keypoints"] = extract_max_keypoints
|
| 476 |
+
t0 = time.time()
|
| 477 |
matcher = get_model(match_conf)
|
| 478 |
+
gr.Info(f"Loading model using: {time.time()-t0:.3f}s")
|
| 479 |
+
t1 = time.time()
|
| 480 |
+
|
| 481 |
if model["dense"]:
|
| 482 |
pred = match_dense.match_images(
|
| 483 |
matcher, image0, image1, match_conf["preprocessing"], device=device
|
|
|
|
| 498 |
)
|
| 499 |
pred = match_features.match_images(matcher, pred0, pred1)
|
| 500 |
del extractor
|
| 501 |
+
gr.Info(f"Matching images done using: {time.time()-t1:.3f}s")
|
| 502 |
+
t1 = time.time()
|
| 503 |
# plot images with keypoints
|
| 504 |
titles = [
|
| 505 |
"Image 0 - Keypoints",
|
|
|
|
| 531 |
ransac_confidence=ransac_confidence,
|
| 532 |
ransac_max_iter=ransac_max_iter,
|
| 533 |
)
|
| 534 |
+
gr.Info(f"RANSAC matches done using: {time.time()-t1:.3f}s")
|
| 535 |
|
| 536 |
# plot images with ransac matches
|
| 537 |
titles = [
|
|
|
|
| 542 |
pred, titles=titles
|
| 543 |
)
|
| 544 |
|
| 545 |
+
t1 = time.time()
|
| 546 |
# plot wrapped images
|
| 547 |
geom_info = compute_geom(pred)
|
| 548 |
output_wrapped, _ = change_estimate_geom(
|
|
|
|
| 551 |
{"geom_info": geom_info},
|
| 552 |
choice_estimate_geom,
|
| 553 |
)
|
| 554 |
+
gr.Info(f"Compute geometry done using: {time.time()-t1:.3f}s")
|
| 555 |
plt.close("all")
|
| 556 |
del pred
|
| 557 |
+
logger.info(f"TOTAL time: {time.time()-t0:.3f}s")
|
| 558 |
+
gr.Info(f"In summary, total time: {time.time()-t0:.3f}s")
|
| 559 |
+
|
| 560 |
return (
|
| 561 |
output_keypoints,
|
| 562 |
output_matches_raw,
|