| """ | |
| Minimal chumpy compatibility shim for unpickling legacy SMAL model configs. | |
| The official SMAL pickle files reference ``chumpy`` objects. On constrained | |
| build environments (e.g. Hugging Face Spaces) installing the real ``chumpy`` | |
| package from source can fail. For inference we only need enough structure for | |
| ``pickle.load`` to succeed; downstream code converts arrays to NumPy/Torch. | |
| """ | |
| from __future__ import annotations | |
| import numpy as np | |
| class Ch: | |
| """Tiny stand-in for ``chumpy.ch.Ch`` used only during unpickling.""" | |
| def __init__(self, *args, **kwargs): | |
| self._data = None | |
| if args: | |
| self._data = np.asarray(args[0]) | |
| def r(self): | |
| if self._data is None: | |
| return np.zeros((), dtype=np.float32) | |
| return np.asarray(self._data) | |
| class ChArray(np.ndarray): | |
| """Stand-in for ``chumpy.ch.ChArray`` (subclass of ndarray in real chumpy).""" | |
| pass | |
| __all__ = ["Ch", "ChArray"] | |