File size: 1,196 Bytes
e8055cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""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)
    )