Spaces:
Running on Zero
Running on Zero
Download fruc/utils/checkpoint.py from hugging-apps/fruc-collaborative-3d-reconstruction: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/hugging-apps/fruc-collaborative-3d-reconstruction/resolve/main/fruc/utils/checkpoint.py
- Command line
-
hf download hf://spaces/hugging-apps/fruc-collaborative-3d-reconstruction/fruc/utils/checkpoint.py
-
curl -L -o checkpoint.py https://huggingface.co/spaces/hugging-apps/fruc-collaborative-3d-reconstruction/resolve/main/fruc/utils/checkpoint.py
724 Bytes
| """Normalize the checkpoint containers used by the public FRUC entry points.""" | |
| from collections.abc import Mapping | |
| def extract_state_dict(checkpoint): | |
| if not isinstance(checkpoint, Mapping): | |
| raise TypeError("Expected a state dictionary or a checkpoint mapping.") | |
| state = checkpoint | |
| for key in ("model_state_dict", "state_dict", "model"): | |
| if key in checkpoint and isinstance(checkpoint[key], Mapping): | |
| state = checkpoint[key] | |
| break | |
| if not state or any(not isinstance(key, str) for key in state): | |
| raise ValueError("Checkpoint does not contain a non-empty parameter dictionary.") | |
| return {key.removeprefix("module."): value for key, value in state.items()} | |