MCPcopy Create free account
hub / github.com/AdaptiveMotorControlLab/FMPose3D / resolve_weights_path

Function resolve_weights_path

fmpose3d/utils/weights.py:15–49  ·  view source on GitHub ↗

Return a local weights path, downloading from Hugging Face Hub if needed. Parameters ---------- model_weights_path : str User-supplied local path. If falsy the weights are fetched from the Hugging Face Hub automatically. model_type : str Model variant name u

(model_weights_path: str, model_type: str)

Source from the content-addressed store, hash-verified

13
14
15def resolve_weights_path(model_weights_path: str, model_type: str) -> str:
16 """Return a local weights path, downloading from Hugging Face Hub if needed.
17
18 Parameters
19 ----------
20 model_weights_path : str
21 User-supplied local path. If falsy the weights are fetched from the
22 Hugging Face Hub automatically.
23 model_type : str
24 Model variant name used to derive the remote filename
25 (e.g. ``"fmpose3d_humans"`` -> ``fmpose3d_humans.pth``).
26
27 Returns
28 -------
29 str
30 Absolute path to the weight file on disk.
31 """
32 if model_weights_path:
33 return model_weights_path
34
35 try:
36 from huggingface_hub import hf_hub_download
37 except ImportError:
38 raise ImportError(
39 "huggingface_hub is required to download model weights. "
40 "Install it with: pip install huggingface_hub\n"
41 "Or download the weights manually and pass the local path."
42 ) from None
43
44 filename = f"{model_type}.pth"
45 print(
46 f"No local weights path specified. "
47 f"Downloading '{filename}' from Hugging Face ({HF_REPO_ID})..."
48 )
49 return hf_hub_download(repo_id=HF_REPO_ID, filename=filename)

Callers 2

FMPose3D_main.pyFile · 0.90
get_pose3DFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected