Spaces:
Sleeping
Sleeping
Download s2f/model_state.py from ProgramComputer/Speech2Face: direct link, hf CLI and curl.
- Browser
- Download file 681 Bytes
-
https://huggingface.co/spaces/ProgramComputer/Speech2Face/resolve/main/s2f/model_state.py
- Command line
-
hf download hf://spaces/ProgramComputer/Speech2Face/s2f/model_state.py
-
curl -L -o model_state.py https://huggingface.co/spaces/ProgramComputer/Speech2Face/resolve/main/s2f/model_state.py
681 Bytes
| from __future__ import annotations | |
| import hashlib | |
| from typing import Any | |
| def need(ok: Any, message: str) -> None: | |
| if not ok: | |
| raise ValueError(message) | |
| def reloaded_variables_hash(model: Any) -> str: | |
| h = hashlib.sha256() | |
| scope = model.name + "/" | |
| for v in model.variables: | |
| path = str(getattr(v, "path", v.name)) | |
| need( | |
| path and not path.startswith(scope), | |
| "Reloaded model variable path must be nonempty and omit the model scope", | |
| ) | |
| a = v.numpy() | |
| h.update((scope + path).encode()) | |
| h.update(str((a.shape, str(a.dtype))).encode()) | |
| h.update(a.tobytes()) | |
| return h.hexdigest() | |