Skip to content
Python

fix: added coreml onnx execution provider. Added a note about needing CUDA 12.8 kernels for Nvidia blackwell (RTX 50-series).

mohamdevbff672c7c50a
diff --git a/README.md b/README.md
index 9d3125c..eebe5b9 100644
--- a/README.md
+++ b/README.md
@@ -16,8 +16,22 @@ you always know where the latency is going.
- **Outputs:** `mhr_params (204)`, `shape_params (45)`, `cam_trans (3)`,
`joints_2d (70, 2)` (normalised crop coords),
`joints_3d (70, 3)` (body-centred metres, Y-down).
-- **Speed:** ~5 ms / frame (~200 FPS) on a single RTX 4070 with the fp16
- ONNX (CUDA EP); CPU works too (~25 FPS, depending on hardware).
+- **Speed (InstantHMR ONNX alone):** ~5 ms / frame (~200 FPS) on a single
+ RTX 4070 with the fp16 ONNX (CUDA EP); CPU works too (~25 FPS, depending
+ on hardware). On Apple Silicon, pass `--device coreml` to use
+ `CoreMLExecutionProvider`.
+- **Speed (full demo, end-to-end):** the demo also runs **RF-DETR** for
+ person detection on every frame, and on most hardware the detector —
+ not InstantHMR — is the bottleneck. Expect roughly 30–60 FPS on a
+ recent NVIDIA GPU with `--detector-variant medium`, and notably less
+ on CPU / Apple Silicon. If you're CPU-bound or on a Mac, use
+ `--detector-variant nano` for a large speed-up at a small accuracy
+ cost.
+- **Note for RTX 50-series (Blackwell, sm_120):** the CUDA wheels pinned
+ in `requirements.txt` (CUDA 12 / cuDNN 9) and a stock Torch install
+ may not ship sm_120 kernels and will fall back to slower paths,
+ particularly for RF-DETR. Install Torch built for CUDA 12.8+ and a
+ matching `onnxruntime-gpu` to get the expected throughput.
> **Note on the body mesh.** InstantHMR does **not** run the MHR mesh
> decoder — rendering the full body mesh is expensive and we want the
diff --git a/demo.py b/demo.py
index 6b91441..47dad9e 100755
--- a/demo.py
+++ b/demo.py
@@ -55,7 +55,7 @@ def parse_args() -> argparse.Namespace:
)
p.add_argument(
"--device", type=str, default="cuda",
- help="Inference device for InstantHMR: 'cuda' or 'cpu' (default: cuda).",
+ help="Inference device for InstantHMR: 'cuda', 'coreml', or 'cpu' (default: cuda).",
)
p.add_argument(
"--detector-variant", type=str, default="medium",
diff --git a/instanthmr/inference.py b/instanthmr/inference.py
index 13e21a5..8459e7d 100644
--- a/instanthmr/inference.py
+++ b/instanthmr/inference.py
@@ -250,6 +250,14 @@ class InstantHMR:
def _default_providers(device: str) -> list[str]:
"""Pick ORT execution providers based on the requested *device*.
+ Recognised values:
+ ``"cuda"`` → ``CUDAExecutionProvider`` (NVIDIA).
+ ``"coreml"`` → ``CoreMLExecutionProvider`` (Apple Silicon / macOS).
+ ``"cpu"`` / anything else → CPU only.
+
+ ``CPUExecutionProvider`` is always appended as a fallback so a
+ partially-supported model still loads.
+
TensorRT is intentionally **not** requested by default: the wheel
distinction between ``onnxruntime-gpu`` and the ``tensorrt`` system
libraries is fiddly, and asking for an EP whose runtime libraries
@@ -260,8 +268,10 @@ class InstantHMR:
available = set(ort.get_available_providers())
wanted: list[str] = []
- if "cuda" in device.lower():
- if "CUDAExecutionProvider" in available:
- wanted.append("CUDAExecutionProvider")
+ device_l = device.lower()
+ if "cuda" in device_l and "CUDAExecutionProvider" in available:
+ wanted.append("CUDAExecutionProvider")
+ elif "coreml" in device_l and "CoreMLExecutionProvider" in available:
+ wanted.append("CoreMLExecutionProvider")
wanted.append("CPUExecutionProvider")
return wanted