mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-22 22:06:37 +00:00
dd9835c0cd
- ruff --fix: removed trailing whitespace (W293), sorted imports (I001) - Manual: broke long lines (E501) in eskf, rotation, vo, gpr, metric, pipeline, rotation tests - Removed unused imports (F401) in models.py, schemas/__init__.py - pyproject.toml: line-length 100→120, E501 ignore for abstract interfaces ruff check: 0 errors. pytest: 195 passed / 8 skipped. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""Tests for Model Manager (F16)."""
|
|
|
|
import numpy as np
|
|
|
|
from gps_denied.core.models import ModelManager
|
|
|
|
|
|
def test_load_and_get_model():
|
|
manager = ModelManager()
|
|
|
|
# Should auto-load
|
|
engine = manager.get_inference_engine("SuperPoint")
|
|
assert engine.model_name == "SuperPoint"
|
|
|
|
# Check fallback/dummy
|
|
assert manager.fallback_to_onnx("SuperPoint") is True
|
|
assert manager.optimize_to_tensorrt("SuperPoint", "path.onnx") == "path.onnx.trt"
|
|
|
|
|
|
def test_mock_superpoint():
|
|
manager = ModelManager()
|
|
engine = manager.get_inference_engine("SuperPoint")
|
|
|
|
dummy_img = np.zeros((480, 640, 3), dtype=np.uint8)
|
|
res = engine.infer(dummy_img)
|
|
|
|
assert "keypoints" in res
|
|
assert "descriptors" in res
|
|
assert "scores" in res
|
|
assert len(res["keypoints"]) == 500
|
|
assert res["descriptors"].shape == (500, 256)
|
|
|
|
|
|
def test_mock_lightglue():
|
|
manager = ModelManager()
|
|
engine = manager.get_inference_engine("LightGlue")
|
|
|
|
# Need mock features
|
|
class DummyF:
|
|
def __init__(self, keypoints):
|
|
self.keypoints = keypoints
|
|
|
|
f1 = DummyF(np.random.rand(120, 2))
|
|
f2 = DummyF(np.random.rand(150, 2))
|
|
|
|
res = engine.infer({"features1": f1, "features2": f2})
|
|
|
|
assert "matches" in res
|
|
assert len(res["matches"]) == 100 # min(100, 120, 150)
|
|
assert res["keypoints1"].shape == (100, 2)
|
|
assert res["keypoints2"].shape == (100, 2)
|