Skip to content

MANO

MANO is a skinned hand model with shape and articulated finger pose parameters.

Setup

MANO requires registration at https://mano.is.tue.mpg.de/.

# Download MANO after configuring credentials for the upstream site.
body-models download mano

Manual paths can also be configured per side:

# Configure local MANO files when you do not want the downloader to manage them.
body-models set mano-right /path/to/MANO_RIGHT.pkl
body-models set mano-left /path/to/MANO_LEFT.pkl

API

body_models.parts.mano.numpy.MANO

MANO(
    model_path=None,
    side=None,
    flat_hand_mean=False,
    simplify=1.0,
    rotation_type="axis_angle",
    kernel="numpy",
)

Bases: BodyModel

MANO hand model with NumPy backend.

Initialize the MANO model.

PARAMETER DESCRIPTION
model_path

Path to model assets, or the default assets when omitted.

TYPE: Path | str | None DEFAULT: None

side

Hand side to load.

TYPE: Literal['right', 'left'] | None DEFAULT: None

flat_hand_mean

Whether to use a flat hand as the pose mean.

TYPE: bool DEFAULT: False

simplify

Mesh simplification factor to apply while loading.

TYPE: float DEFAULT: 1.0

rotation_type

Rotation representation expected by pose inputs.

TYPE: RotationType DEFAULT: 'axis_angle'

kernel

Backend kernel used for forward evaluation.

TYPE: Literal['numpy', 'scipy', 'numba'] DEFAULT: 'numpy'

METHOD DESCRIPTION
forward_vertices

Compute posed mesh vertices.

forward_skeleton

Compute posed joint transforms.

prepare_identity

Precompute shape-dependent state for repeated forward passes.

prepare_pose

Precompute pose-dependent state for repeated forward passes.

joint_index

Resolve a standard joint to this model's native joint index.

get_tpose

Get parameters for the SMPL-style T-pose.

get_apose

Get parameters for the MHR-style A-pose.

prepare_skinning

Pack prepared model state into renderer-ready skinning inputs.

Source code in src/body_models/parts/mano/numpy.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def __init__(
    self,
    model_path: Path | str | None = None,
    side: Literal["right", "left"] | None = None,
    flat_hand_mean: bool = False,
    simplify: float = 1.0,
    rotation_type: RotationType = "axis_angle",
    kernel: Literal["numpy", "scipy", "numba"] = "numpy",
):
    """Initialize the MANO model.

    Args:
        model_path: Path to model assets, or the default assets when omitted.
        side: Hand side to load.
        flat_hand_mean: Whether to use a flat hand as the pose mean.
        simplify: Mesh simplification factor to apply while loading.
        rotation_type: Rotation representation expected by pose inputs.
        kernel: Backend kernel used for forward evaluation.
    """
    if side is not None and side not in ("right", "left"):
        raise ValueError(f"Invalid side: {side}. Must be 'right' or 'left'.")
    if rotation_type not in VALID_ROTATION_TYPES:
        raise ValueError(f"Invalid rotation_type: {rotation_type}")
    if simplify < 1.0:
        raise ValueError("simplify must be >= 1.0")
    if kernel not in self.kernels:
        raise ValueError(f"Invalid kernel: {kernel}")

    self.side = side if side is not None else "right"
    self.rotation_type = rotation_type
    self.num_rot_dims = 2 if rotation_type in ("matrix", "rotmat") else 1
    self._kernel = _get_kernel(kernel)

    resolved_path = get_model_path(model_path, side)
    self.weights = load_model_data(resolved_path, flat_hand_mean=flat_hand_mean, simplify=simplify)

forward_vertices

forward_vertices(
    hand_pose,
    wrist_rotation=None,
    global_rotation=None,
    global_translation=None,
    vertex_indices=None,
    *,
    shape=None,
    identity=None,
)

Compute posed mesh vertices.

PARAMETER DESCRIPTION
hand_pose

Local hand joint rotations.

TYPE: Float[ndarray, 'B 15 N'] | Float[ndarray, 'B 15 3 3']

wrist_rotation

Root wrist rotation.

TYPE: Float[ndarray, 'B N'] | Float[ndarray, 'B 3 3'] | None DEFAULT: None

global_rotation

Global model rotation.

TYPE: Float[ndarray, 'B N'] | Float[ndarray, 'B 3 3'] | None DEFAULT: None

global_translation

Global model translation.

TYPE: Float[ndarray, 'B 3'] | None DEFAULT: None

vertex_indices

Optional subset of vertices to return.

TYPE: Any | None DEFAULT: None

shape

Shape coefficients.

TYPE: Float[ndarray, '*batch 10'] | None DEFAULT: None

identity

Optional output from :meth:prepare_identity.

TYPE: ManoIdentity | None DEFAULT: None

RETURNS DESCRIPTION
Float[ndarray, 'B V 3']

Posed vertex positions.

Source code in src/body_models/parts/mano/numpy.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
def forward_vertices(
    self,
    hand_pose: Float[np.ndarray, "B 15 N"] | Float[np.ndarray, "B 15 3 3"],
    wrist_rotation: Float[np.ndarray, "B N"] | Float[np.ndarray, "B 3 3"] | None = None,
    global_rotation: Float[np.ndarray, "B N"] | Float[np.ndarray, "B 3 3"] | None = None,
    global_translation: Float[np.ndarray, "B 3"] | None = None,
    vertex_indices: Any | None = None,
    *,
    shape: Float[np.ndarray, "*batch 10"] | None = None,
    identity: ManoIdentity | None = None,
) -> Float[np.ndarray, "B V 3"]:
    """Compute posed mesh vertices.

    Args:
        hand_pose: Local hand joint rotations.
        wrist_rotation: Root wrist rotation.
        global_rotation: Global model rotation.
        global_translation: Global model translation.
        vertex_indices: Optional subset of vertices to return.
        shape: Shape coefficients.
        identity: Optional output from :meth:`prepare_identity`.

    Returns:
        Posed vertex positions.
    """
    if identity is None:
        assert shape is not None
        batch_shape = tuple(hand_pose.shape[: -(self.num_rot_dims + 1)])
        identity = self.prepare_identity(np.broadcast_to(shape, (*batch_shape, shape.shape[-1])))
    pose = self.prepare_pose(hand_pose, wrist_rotation, identity=identity)
    return self._kernel.forward_vertices(
        self.weights,
        identity["rest_vertices"],
        pose["skinning_transforms"],
        pose["pose_offsets"],
        global_rotation=global_rotation,
        global_translation=global_translation,
        vertex_indices=vertex_indices,
        rotation_type=self.rotation_type,
    )

forward_skeleton

forward_skeleton(
    hand_pose,
    wrist_rotation=None,
    global_rotation=None,
    global_translation=None,
    joint_indices=None,
    *,
    shape=None,
    identity=None,
)

Compute posed joint transforms.

PARAMETER DESCRIPTION
hand_pose

Local hand joint rotations.

TYPE: Float[ndarray, 'B 15 N'] | Float[ndarray, 'B 15 3 3']

wrist_rotation

Root wrist rotation.

TYPE: Float[ndarray, 'B N'] | Float[ndarray, 'B 3 3'] | None DEFAULT: None

global_rotation

Global model rotation.

TYPE: Float[ndarray, 'B N'] | Float[ndarray, 'B 3 3'] | None DEFAULT: None

global_translation

Global model translation.

TYPE: Float[ndarray, 'B 3'] | None DEFAULT: None

joint_indices

Optional subset of joints to return.

TYPE: Any | None DEFAULT: None

shape

Shape coefficients.

TYPE: Float[ndarray, '*batch 10'] | None DEFAULT: None

identity

Optional output from :meth:prepare_identity.

TYPE: ManoIdentity | None DEFAULT: None

RETURNS DESCRIPTION
Float[ndarray, 'B 16 4 4']

Joint transforms in the model hierarchy.

Source code in src/body_models/parts/mano/numpy.py
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def forward_skeleton(
    self,
    hand_pose: Float[np.ndarray, "B 15 N"] | Float[np.ndarray, "B 15 3 3"],
    wrist_rotation: Float[np.ndarray, "B N"] | Float[np.ndarray, "B 3 3"] | None = None,
    global_rotation: Float[np.ndarray, "B N"] | Float[np.ndarray, "B 3 3"] | None = None,
    global_translation: Float[np.ndarray, "B 3"] | None = None,
    joint_indices: Any | None = None,
    *,
    shape: Float[np.ndarray, "*batch 10"] | None = None,
    identity: ManoIdentity | None = None,
) -> Float[np.ndarray, "B 16 4 4"]:
    """Compute posed joint transforms.

    Args:
        hand_pose: Local hand joint rotations.
        wrist_rotation: Root wrist rotation.
        global_rotation: Global model rotation.
        global_translation: Global model translation.
        joint_indices: Optional subset of joints to return.
        shape: Shape coefficients.
        identity: Optional output from :meth:`prepare_identity`.

    Returns:
        Joint transforms in the model hierarchy.
    """
    if identity is None:
        assert shape is not None
        batch_shape = tuple(hand_pose.shape[: -(self.num_rot_dims + 1)])
        shape = np.broadcast_to(shape, (*batch_shape, shape.shape[-1]))
        identity = self.prepare_identity(shape, skip_vertices=True)
    pose = self.prepare_pose(hand_pose, wrist_rotation, identity=identity, skip_vertices=True)
    return self._kernel.forward_skeleton(
        self.weights,
        pose["skeleton_transforms"],
        global_rotation=global_rotation,
        global_translation=global_translation,
        joint_indices=joint_indices,
        rotation_type=self.rotation_type,
    )

prepare_identity

prepare_identity(shape, skip_vertices=False)

Precompute shape-dependent state for repeated forward passes.

Source code in src/body_models/parts/mano/numpy.py
191
192
193
194
195
196
197
def prepare_identity(
    self,
    shape: Float[np.ndarray, "*batch 10"],
    skip_vertices: bool = False,
) -> ManoIdentity:
    """Precompute shape-dependent state for repeated forward passes."""
    return self._kernel.prepare_identity(self.weights, shape, skip_vertices=skip_vertices)

prepare_pose

prepare_pose(
    hand_pose, wrist_rotation=None, *, identity, skip_vertices=False
)

Precompute pose-dependent state for repeated forward passes.

Source code in src/body_models/parts/mano/numpy.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def prepare_pose(
    self,
    hand_pose: Float[np.ndarray, "B 15 N"] | Float[np.ndarray, "B 15 3 3"],
    wrist_rotation: Float[np.ndarray, "B N"] | Float[np.ndarray, "B 3 3"] | None = None,
    *,
    identity: ManoIdentity,
    skip_vertices: bool = False,
) -> ManoPreparedPose:
    """Precompute pose-dependent state for repeated forward passes."""
    return self._kernel.prepare_pose(
        self.weights,
        hand_pose,
        wrist_rotation,
        rotation_type=self.rotation_type,
        local_joint_offsets=identity["local_joint_offsets"],
        rest_joints=identity["rest_joints"],
        skip_vertices=skip_vertices,
    )

joint_index

joint_index(joint)

Resolve a standard joint to this model's native joint index.

Source code in src/body_models/base.py
77
78
79
80
81
82
83
84
85
def joint_index(self, joint: Joint) -> int:
    """Resolve a standard joint to this model's native joint index."""
    if not isinstance(joint, Joint):
        raise TypeError("joint_index() expects a body_models.Joint; use joint_names.index(...) for native names.")
    try:
        native_name = self.common_joints[joint]
    except KeyError as exc:
        raise KeyError(f"{self.__class__.__name__} has no standard joint {joint.value!r}") from exc
    return self.joint_names.index(native_name)

get_tpose

get_tpose(batch_dims=(), **kwargs)

Get parameters for the SMPL-style T-pose.

Source code in src/body_models/base.py
134
135
136
137
138
139
140
def get_tpose(
    self,
    batch_dims: tuple[int, ...] = (),
    **kwargs: Any,
) -> dict[str, Any]:
    """Get parameters for the SMPL-style T-pose."""
    raise NotImplementedError("Canonical body poses are not defined for this model.")

get_apose

get_apose(batch_dims=(), **kwargs)

Get parameters for the MHR-style A-pose.

Source code in src/body_models/base.py
142
143
144
145
146
147
148
def get_apose(
    self,
    batch_dims: tuple[int, ...] = (),
    **kwargs: Any,
) -> dict[str, Any]:
    """Get parameters for the MHR-style A-pose."""
    raise NotImplementedError("Canonical body poses are not defined for this model.")

prepare_skinning

prepare_skinning(*, identity, pose)

Pack prepared model state into renderer-ready skinning inputs.

Source code in src/body_models/base.py
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def prepare_skinning(self, *, identity: Mapping[str, Any], pose: Mapping[str, Any]) -> SkinningPayload:
    """Pack prepared model state into renderer-ready skinning inputs."""
    if self.is_rigid_body:
        raise NotImplementedError(f"{self.__class__.__name__} is rigid and does not support skinning.")

    skinning: SkinningPayload = {
        "rest_vertices": identity["rest_vertices"],
        "skinning_transforms": pose["skinning_transforms"],
        "skin_weights": self.skin_weights,
        "faces": self.faces,
    }
    if "pose_offsets" in pose:
        skinning["pose_offsets"] = pose["pose_offsets"]
    return skinning