workspace / tests /test_inference /test_run.py
AntonioJun's picture
Replace tests with local workspace contents
e8055cf verified
Raw
History Blame Contribute Delete
1.2 kB
"""Optional real-model validation; enable with VSI_RUN_GPU_TESTS=1."""
import json
import os
import pytest
from inference import adapters
from inference import run
@pytest.mark.skipif(
os.environ.get("VSI_RUN_GPU_TESTS") != "1",
reason="set VSI_RUN_GPU_TESTS=1 to run real SegVGGT inference",
)
def test_real_segvggt_scene_preserves_native_prediction_dictionary(tmp_path):
torch = pytest.importorskip("torch")
with open(run.inference_config.JSONL) as manifest:
scene = str(json.loads(next(manifest))["scene_name"])
adapter = adapters.get_adapter("segvggt")
adapter.load_model("cuda:0")
output = tmp_path / f"{scene}.pt"
adapter.run_scene(
run.inference_config.video_path(scene),
str(output),
run.inference_config.FRAMES_PER_VIDEO,
)
cache = torch.load(output, map_location="cpu", weights_only=False)
assert isinstance(cache, dict)
assert {
"pose_enc",
"depth",
"world_points",
"instance_maps",
"instance_labels",
}.issubset(cache)
assert all(
value.device.type == "cpu"
for value in cache.values()
if isinstance(value, torch.Tensor)
)