Skip to content

SKEL

SKEL is a body model with anatomical articulation, available in male and female variants.

Setup

SKEL requires registration at skel.is.tue.mpg.de.

body-models download skel

Or configure files by gender:

body-models set skel-male /path/to/skel_male.pkl
body-models set skel-female /path/to/skel_female.pkl

API

body_models.skel.numpy.SKEL

SKEL(*, model_path=None, gender='male', simplify=1.0)

Bases: body_models.skel._model.SKEL

Skinned body model with anatomical articulation.

METHOD DESCRIPTION
apply_pose_correctives

Apply prepared pose correctives to identity-dependent rest vertices.

forward_points

Compute positions defined by a prepared vertex mapping.

forward_skeleton

Compute posed SKEL joint transforms.

forward_vertices

Compute posed SKEL vertices.

get_rest_pose

Construct canonical parameter defaults from :attr:parameter_spec.

joint_index

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

prepare_point_regressor

Preproject a vertex mapping for repeated point forwards.

forward_links

Alias the SKEL joint transforms as anatomical link transforms.

get_apose

Return the SKEL A-pose.

get_tpose

Return the SKEL T-pose.

prepare_identity

Precompute shape-dependent state for repeated forward passes.

prepare_pose

Precompute pose-dependent state for repeated forward passes.

ATTRIBUTE DESCRIPTION
common_joints

Common anatomical joints mapped to this model's native joint names.

has_face

bool(x) -> bool

has_hands

bool(x) -> bool

num_joints

Number of joints in the skeleton.

pose_joint_indices

Canonical joints whose local transforms are driven by each pose parameter.

runtime

Array runtime used by this model.

skinning_spec

Static topology, render-rig weights, and optional pose correctives.

symmetric_joints

Left/right joint pairs as (left_index, right_index), in joint order.

NUM_BODY_POSE_COEFFS

int([x]) -> integer

NUM_HEAD_POSE_COEFFS

int([x]) -> integer

NUM_JOINTS

int([x]) -> integer

NUM_POSE_COEFFS

int([x]) -> integer

NUM_SHAPE_COEFFS

int([x]) -> integer

common_joints property

common_joints

Common anatomical joints mapped to this model's native joint names.

has_face class-attribute

has_face = False

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

has_hands class-attribute

has_hands = False

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

num_joints property

num_joints

Number of joints in the skeleton.

pose_joint_indices property

pose_joint_indices

Canonical joints whose local transforms are driven by each pose parameter.

runtime property

runtime

Array runtime used by this model.

skinning_spec property

skinning_spec

Static topology, render-rig weights, and optional pose correctives.

symmetric_joints property

symmetric_joints

Left/right joint pairs as (left_index, right_index), in joint order.

Indices address the J axis of :meth:forward_skeleton outputs and cover the whole native skeleton, including joints outside the :class:Joint vocabulary. Unpaired joints lie on the midline. Pairs describe index correspondence only, not how to mirror a pose.

RAISES DESCRIPTION
ValueError

If a sided joint name has no counterpart.

NUM_BODY_POSE_COEFFS class-attribute

NUM_BODY_POSE_COEFFS = 43

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

NUM_HEAD_POSE_COEFFS class-attribute

NUM_HEAD_POSE_COEFFS = 3

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

NUM_JOINTS class-attribute

NUM_JOINTS = 24

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

NUM_POSE_COEFFS class-attribute

NUM_POSE_COEFFS = 46

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

NUM_SHAPE_COEFFS class-attribute

NUM_SHAPE_COEFFS = 10

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

apply_pose_correctives

apply_pose_correctives(*, identity, pose)

Apply prepared pose correctives to identity-dependent rest vertices.

Source code in src/body_models/_base.py
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
def apply_pose_correctives(
    self,
    *,
    identity: SkinningIdentity,
    pose: SkinningPose,
) -> Float[Array, "*batch V 3"]:
    """Apply prepared pose correctives to identity-dependent rest vertices."""
    vertices = identity["rest_vertices"]
    coefficients = pose.get("pose_coefficients")
    if coefficients is None:
        return vertices
    basis = self._corrective_basis
    if basis is None:
        raise RuntimeError("Prepared pose has corrective coefficients, but the model has no corrective basis.")
    return vertices + basis.apply(coefficients)

forward_points

forward_points(
    body_pose,
    head_pose,
    *,
    point_regressor,
    shape=None,
    identity=None,
    global_rotation=None,
    global_translation=None,
)

Compute positions defined by a prepared vertex mapping.

Source code in src/body_models/skel/_model.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def forward_points(
    self,
    body_pose: Float[Array, "*batch 43"],
    head_pose: Float[Array, "*batch 3"],
    *,
    point_regressor: PointRegressor,
    shape: Float[Array, "*batch 10"] | None = None,
    identity: SkelIdentity | None = None,
    global_rotation: Float[Array, "*batch 3"] | None = None,
    global_translation: Float[Array, "*batch 3"] | None = None,
) -> Float[Array, "*batch K 3"]:
    """Compute positions defined by a prepared vertex mapping."""
    self._validate_identity_arguments(identity, shape=shape)
    if identity is None:
        identity = self.prepare_identity(*self._resolve_identity_coefficients(body_pose.shape[:-1], shape=shape))

    pose = self.prepare_pose(body_pose, head_pose, identity=identity)
    return self._deform_points(point_regressor, identity, pose, global_rotation, global_translation)

forward_skeleton

forward_skeleton(
    body_pose,
    head_pose,
    *,
    shape=None,
    identity=None,
    global_rotation=None,
    global_translation=None,
    joint_indices=None,
)

Compute posed SKEL joint transforms.

Source code in src/body_models/skel/_model.py
145
146
147
148
149
150
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,
    body_pose: Float[Array, "*batch 43"],
    head_pose: Float[Array, "*batch 3"],
    *,
    shape: Float[Array, "*batch 10"] | None = None,
    identity: SkelIdentity | None = None,
    global_rotation: Float[Array, "*batch 3"] | None = None,
    global_translation: Float[Array, "*batch 3"] | None = None,
    joint_indices: Sequence[int] | None = None,
) -> Float[Array, "*batch 24 4 4"]:
    """Compute posed SKEL joint transforms."""
    xp = self._runtime.xp
    self._validate_identity_arguments(identity, shape=shape)
    if identity is None:
        resolved = self._resolve_identity_coefficients(body_pose.shape[:-1], shape=shape)
        skeleton_identity = self._prepare_skeleton_identity(*resolved)
    else:
        skeleton_identity = identity

    packed_pose = pose_utils.pack_pose(xp, body_pose, head_pose)
    skeleton = core.prepare_skeleton(
        runtime=self._runtime,
        all_axes=self._assets.all_axes,
        rotation_indices=self._assets.rotation_indices,
        apose_R=self._assets.apose_R,
        apose_t=self._assets.apose_t,
        per_joint_rot=self._assets.per_joint_rot,
        child=self._assets.child,
        fixed_orientation_joints=self._assets.fixed_orientation_joints,
        scapula_r_axes=self._assets.scapula_r_axes,
        scapula_l_axes=self._assets.scapula_l_axes,
        spine_axes=self._assets.spine_axes,
        tree=self._assets.kinematic_tree,
        pose=packed_pose,
        local_joint_offsets=skeleton_identity["local_joint_offsets"],
        rest_joints=skeleton_identity["rest_joints"],
        joint_indices=joint_indices,
    )
    return skinning.transform_skeleton(
        skeleton,
        global_rotation,
        global_translation,
        xp=xp,
    )

forward_vertices

forward_vertices(
    body_pose,
    head_pose,
    *,
    shape=None,
    identity=None,
    global_rotation=None,
    global_translation=None,
    vertex_indices=None,
)

Compute posed SKEL vertices.

Source code in src/body_models/skel/_model.py
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
def forward_vertices(
    self,
    body_pose: Float[Array, "*batch 43"],
    head_pose: Float[Array, "*batch 3"],
    *,
    shape: Float[Array, "*batch 10"] | None = None,
    identity: SkelIdentity | None = None,
    global_rotation: Float[Array, "*batch 3"] | None = None,
    global_translation: Float[Array, "*batch 3"] | None = None,
    vertex_indices: Sequence[int] | None = None,
) -> Float[Array, "*batch V 3"]:
    """Compute posed SKEL vertices."""
    xp = self._runtime.xp
    self._validate_identity_arguments(identity, shape=shape)
    if identity is None:
        identity = self.prepare_identity(*self._resolve_identity_coefficients(body_pose.shape[:-1], shape=shape))

    pose = self.prepare_pose(body_pose, head_pose, identity=identity)
    vertices = self._runtime._skin_vertices(
        self.apply_pose_correctives(identity=identity, pose=pose),
        pose["skinning_transforms"],
        skinning=self._assets.compact_skinning,
        vertex_indices=vertex_indices,
    )
    return skinning.apply_global_transform(
        vertices,
        global_rotation,
        global_translation,
        xp=xp,
    )

get_rest_pose

get_rest_pose(*, batch_dims=(), dtype=None)

Construct canonical parameter defaults from :attr:parameter_spec.

PARAMETER DESCRIPTION
batch_dims

Leading batch dimensions.

TYPE: tuple[int, ...] DEFAULT: ()

dtype

Optional floating-point dtype.

TYPE: Any | None DEFAULT: None

RETURNS DESCRIPTION
dict[str, Float[Any, ...]]

Complete model parameters at rest.

Source code in src/body_models/_base.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def get_rest_pose(
    self,
    *,
    batch_dims: tuple[int, ...] = (),
    dtype: Any | None = None,
) -> dict[str, Float[Array, "..."]]:
    """
    Construct canonical parameter defaults from :attr:`parameter_spec`.

    Args:
        batch_dims: Leading batch dimensions.
        dtype: Optional floating-point dtype.

    Returns:
        Complete model parameters at rest.
    """
    return {name: self._parameter_default(spec, batch_dims, dtype) for name, spec in self.parameter_spec.items()}

joint_index

joint_index(joint)

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

Source code in src/body_models/_base.py
173
174
175
176
177
178
179
180
181
def joint_index(self, joint: Joint) -> int:
    """Resolve a common 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 common joint {joint.value!r}") from exc
    return self.joint_names.index(native_name)

prepare_point_regressor

prepare_point_regressor(mapping)

Preproject a vertex mapping for repeated point forwards.

For Torch, call this after moving the model to its target device.

Source code in src/body_models/_base.py
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
def prepare_point_regressor(
    self,
    mapping: Float[Array, "K V"],
) -> PointRegressor:
    """Preproject a vertex mapping for repeated point forwards.

    For Torch, call this after moving the model to its target device.
    """
    if mapping.ndim != 2 or mapping.shape[0] < 1 or mapping.shape[1] != self.num_vertices:
        raise ValueError(
            f"mapping must have shape [K, {self.num_vertices}] with K >= 1, got {tuple(mapping.shape)}"
        )
    mapping = self._runtime.asarray(mapping, like=self.rest_vertices)
    return point_regression.prepare_point_regressor(
        mapping,
        self._skinning_weights,
        self._corrective_basis,
        runtime=self._runtime,
    )
forward_links(
    body_pose,
    head_pose,
    *,
    shape=None,
    identity=None,
    global_rotation=None,
    global_translation=None,
)

Alias the SKEL joint transforms as anatomical link transforms.

Source code in src/body_models/skel/_model.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def forward_links(
    self,
    body_pose: Float[Array, "*batch 43"],
    head_pose: Float[Array, "*batch 3"],
    *,
    shape: Float[Array, "*batch 10"] | None = None,
    identity: SkelIdentity | None = None,
    global_rotation: Float[Array, "*batch 3"] | None = None,
    global_translation: Float[Array, "*batch 3"] | None = None,
) -> Float[Array, "*batch 24 4 4"]:
    """Alias the SKEL joint transforms as anatomical link transforms."""
    return self.forward_skeleton(
        body_pose,
        head_pose,
        global_rotation=global_rotation,
        global_translation=global_translation,
        shape=shape,
        identity=identity,
    )

get_apose

get_apose(*, batch_dims=(), dtype=None)

Return the SKEL A-pose.

Source code in src/body_models/skel/_model.py
294
295
296
297
298
299
300
301
302
303
304
305
def get_apose(
    self,
    *,
    batch_dims: tuple[int, ...] = (),
    dtype: Any | None = None,
) -> dict[str, Float[Array, "..."]]:
    """Return the SKEL A-pose."""
    params = self.get_rest_pose(batch_dims=batch_dims, dtype=dtype)
    pose = self._runtime.asarray(SKEL_BODY_PRESETS["a_pose"], like=params["body_pose"])
    pose = self._runtime.xp.broadcast_to(pose, (*batch_dims, *pose.shape))
    params["body_pose"], params["head_pose"] = pose_utils.unpack_pose(self._runtime.xp, pose)
    return params

get_tpose

get_tpose(*, batch_dims=(), dtype=None)

Return the SKEL T-pose.

Source code in src/body_models/skel/_model.py
285
286
287
288
289
290
291
292
def get_tpose(
    self,
    *,
    batch_dims: tuple[int, ...] = (),
    dtype: Any | None = None,
) -> dict[str, Float[Array, "..."]]:
    """Return the SKEL T-pose."""
    return self.get_rest_pose(batch_dims=batch_dims, dtype=dtype)

prepare_identity

prepare_identity(shape)

Precompute shape-dependent state for repeated forward passes.

Source code in src/body_models/skel/_model.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
def prepare_identity(
    self,
    shape: Float[Array, "*batch 10"],
) -> SkelIdentity:
    """Precompute shape-dependent state for repeated forward passes."""
    return core.prepare_identity(
        self._assets.v_template,
        self._assets.shapedirs,
        self._assets.j_template,
        self._assets.j_shapedirs,
        self._assets.parent,
        shape,
        xp=self._runtime.xp,
    )

prepare_pose

prepare_pose(body_pose, head_pose, *, identity)

Precompute pose-dependent state for repeated forward passes.

Source code in src/body_models/skel/_model.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
def prepare_pose(
    self,
    body_pose: Float[Array, "*batch 43"],
    head_pose: Float[Array, "*batch 3"],
    *,
    identity: SkelIdentity,
) -> SkinningPose:
    """Precompute pose-dependent state for repeated forward passes."""
    packed_pose = pose_utils.pack_pose(self._runtime.xp, body_pose, head_pose)
    return core.prepare_pose(
        runtime=self._runtime,
        all_axes=self._assets.all_axes,
        rotation_indices=self._assets.rotation_indices,
        apose_R=self._assets.apose_R,
        apose_t=self._assets.apose_t,
        per_joint_rot=self._assets.per_joint_rot,
        child=self._assets.child,
        fixed_orientation_joints=self._assets.fixed_orientation_joints,
        scapula_r_axes=self._assets.scapula_r_axes,
        scapula_l_axes=self._assets.scapula_l_axes,
        spine_axes=self._assets.spine_axes,
        tree=self._assets.kinematic_tree,
        num_joints_smpl=self._assets.num_joints_smpl,
        pose=packed_pose,
        local_joint_offsets=identity["local_joint_offsets"],
        rest_joints=identity["rest_joints"],
    )