test_superglue_handler.py 981 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import numpy as np
  2. import pytest
  3. from superpoint_superglue_deployment import SuperGlueHandler, SuperPointHandler
  4. def test_initialization_success():
  5. SuperGlueHandler()
  6. def test_initialization_failure():
  7. with pytest.raises(AssertionError):
  8. SuperGlueHandler({"weights": "unknown"})
  9. def test_inference():
  10. superpoint_handler = SuperPointHandler(
  11. {
  12. "use_gpu": True,
  13. "input_shape": (-1, -1),
  14. "keypoint_threshold": 0.001,
  15. }
  16. )
  17. query_image = np.random.rand(300, 300) * 255
  18. query_image = query_image.astype(np.uint8)
  19. ref_image = query_image.astype(np.uint8)
  20. ref_image = ref_image.astype(np.uint8)
  21. query_pred = superpoint_handler.run(query_image)
  22. ref_pred = superpoint_handler.run(ref_image)
  23. superglue_handler = SuperGlueHandler(
  24. {
  25. "use_gpu": False,
  26. }
  27. )
  28. superglue_handler.match(query_pred, ref_pred, query_image.shape[:2], ref_image.shape[:2])