File size: 953 Bytes
0b85f7c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | """
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"]
|