Visitar URL original
Add internal helper for batched modelzoo inference from in-memory arrays (inference runner) by deruyter92 · Pull Request #3222 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change autoresolve device: map default None -> "auto" (+ update tests…
… accordingly)
  • Loading branch information
deruyter92 committed Mar 16, 2026
commit 04c4512726551aabb868819a557c537e0ef2909b
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def create_superanimal_inference_runners(
"FMPose3D is not supported in this helper. Use the FMPose3D inference API."
)

if device in (None, "auto"):
device = "cuda:0" if torch.cuda.is_available() else "cpu"
if device is None:
device = "auto"

if customized_model_config is not None:
if isinstance(customized_model_config, (str, Path)):
Expand Down
13 changes: 5 additions & 8 deletions tests/pose_estimation_pytorch/modelzoo/test_inference_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ def fake_update_config(config, max_individuals, device):
assert model_cfg["metadata"]["bodyparts"] == ["nose", "tail"]


@pytest.mark.parametrize(
"cuda_available, expected_device",
[(True, "cuda:0"), (False, "cpu")],
)
@pytest.mark.parametrize("input_device", ["auto", None])
def test_create_superanimal_inference_runners_auto_device_selection(
monkeypatch, cuda_available, expected_device
monkeypatch, input_device
):
cfg = _dummy_cfg("TD")
captured = {}

monkeypatch.setattr(helpers.torch.cuda, "is_available", lambda: cuda_available)
monkeypatch.setattr(helpers, "read_config_as_dict", lambda path: cfg)

def fake_update_config(config, max_individuals, device):
captured["device"] = device
return config
Expand Down Expand Up @@ -146,9 +143,9 @@ def fake_update_config(config, max_individuals, device):
model_name="hrnet_w32",
detector_name="fasterrcnn_resnet50_fpn_v2",
customized_model_config="/tmp/custom_model_cfg.yaml",
device="auto",
device=input_device,
)
assert captured["device"] == expected_device
assert captured["device"] == "auto"


def test_create_superanimal_inference_runners_raises_for_fmpose3d():
Expand Down