Skip to content

Native Windows video motion capture with ExMR, FlowHMR and GVHMR, contact correction, humanoid retargeting, and FBX/VMD export.

Python

Load model weights on CPU for better memory management

smthemexc07566b22f20
diff --git a/third_party/ExMR/exmr/preprocessing/keypoints/sapiens2.py b/third_party/ExMR/exmr/preprocessing/keypoints/sapiens2.py
index df9eee5..50dc957 100644
--- a/third_party/ExMR/exmr/preprocessing/keypoints/sapiens2.py
+++ b/third_party/ExMR/exmr/preprocessing/keypoints/sapiens2.py
@@ -75,9 +75,10 @@ class Sapiens2Keypoints:
# built on the GPU: initializing the weights on the CPU takes ~8 s, and the checkpoint
# replaces them anyway
- with torch.device(device):
+ # Building and deserializing models can result in double usage of f32 VRam, which is not user-friendly for low memory users.
+ with torch.device("cpu"):
model = MODELS.build(copy.deepcopy(MODEL_CFG))
- model.load_state_dict(load_file(str(checkpoint), device=device))
+ model.load_state_dict(load_file(str(checkpoint), device="cpu"))
model.data_preprocessor = MODELS.build(copy.deepcopy(DATA_PREPROCESSOR_CFG))
model.to(device).eval()
model.backbone.half()