move_detect/tests/hardware/test_movenet_smoke.py

28 lines
1.1 KiB
Python

"""Gated end-to-end smoke test for the real MoveNet ONNX model.
Skipped unless the model is bundled AND onnxruntime is installed, so the default
CI/dev suite (no model, no onnxruntime) stays green. On a build/pilot machine that
ran ``python -m edge.tools.fetch_movenet``, this exercises the full adapter path:
frame -> onnxruntime inference -> COCO-17 remap -> list[Person].
"""
import os
import numpy as np
import pytest
MODEL = os.path.join(os.path.dirname(__file__), "..", "..", "models", "movenet_lightning.onnx")
@pytest.mark.skipif(not os.path.exists(MODEL), reason="MoveNet model not bundled")
def test_real_movenet_runs():
pytest.importorskip("onnxruntime")
from edge.adapters.movenet_pose import MoveNetPoseAdapter
adapter = MoveNetPoseAdapter(MODEL)
persons = adapter.infer(np.full((480, 640, 3), 128, np.uint8))
# Runs end-to-end; a flat gray frame may yield 0 persons — the contract is
# only that it returns a list and, when non-empty, each Person has 17 keypoints.
assert isinstance(persons, list)
for person in persons:
assert len(person.keypoints) == 17