SMPL¶
SMPL is a skinned human body model with shape coefficients and 24 articulated joints.
Setup¶
SMPL requires registration at smpl.is.tue.mpg.de.
body-models download smpl
Or configure files by gender:
body-models set smpl-neutral /path/to/SMPL_NEUTRAL.pkl
body-models set smpl-male /path/to/SMPL_MALE.pkl
body-models set smpl-female /path/to/SMPL_FEMALE.pkl
API¶
body_models.smpl.numpy.SMPL
¶
SMPL(
*,
model_path=None,
gender=None,
rotation_type="axis_angle",
simplify=1.0,
)
Bases: body_models.smpl._model.SMPL
Skinned human body model with shape and pose controls.
| 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 joint transforms. |
forward_vertices |
Compute posed mesh vertices. |
get_rest_pose |
Construct canonical parameter defaults from :attr: |
joint_index |
Resolve a common joint to this model's native joint index. |
prepare_point_regressor |
Preproject a vertex mapping and the model's linear identity bases. |
get_apose |
Return the SMPL A-pose. |
get_tpose |
Return the SMPL 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
|
NUM_EXPR_COEFFS |
int([x]) -> integer
|
NUM_BODY_CONTROLS |
int([x]) -> integer
|
NUM_JOINTS |
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.
pose_joint_indices
property
¶
pose_joint_indices
Canonical joints whose local transforms are driven by each pose parameter.
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_EXPR_COEFFS
class-attribute
¶
NUM_EXPR_COEFFS = 0
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_BODY_CONTROLS
class-attribute
¶
NUM_BODY_CONTROLS = 23
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_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 | |
forward_points
¶
forward_points(
body_pose,
*,
point_regressor,
pelvis_rotation=None,
shape=None,
identity=None,
global_rotation=None,
global_translation=None,
)
Compute positions defined by a prepared vertex mapping.
Source code in src/body_models/smpl/_model.py
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 | |
forward_skeleton
¶
forward_skeleton(
body_pose,
*,
pelvis_rotation=None,
shape=None,
identity=None,
global_rotation=None,
global_translation=None,
joint_indices=None,
)
Compute posed joint transforms.
Source code in src/body_models/smpl/_model.py
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 150 | |
forward_vertices
¶
forward_vertices(
body_pose,
*,
pelvis_rotation=None,
shape=None,
identity=None,
global_rotation=None,
global_translation=None,
vertex_indices=None,
)
Compute posed mesh vertices.
Source code in src/body_models/smpl/_model.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
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:
|
dtype
|
Optional floating-point dtype.
TYPE:
|
| 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 | |
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 | |
prepare_point_regressor
¶
prepare_point_regressor(mapping)
Preproject a vertex mapping and the model's linear identity bases.
Source code in src/body_models/_linear_blendshape.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
get_apose
¶
get_apose(*, batch_dims=(), dtype=None)
Return the SMPL A-pose.
Source code in src/body_models/smpl/_model.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_tpose
¶
get_tpose(*, batch_dims=(), dtype=None)
Return the SMPL T-pose.
Source code in src/body_models/smpl/_model.py
226 227 228 229 230 231 232 233 | |
prepare_identity
¶
prepare_identity(shape)
Precompute shape-dependent state for repeated forward passes.
Source code in src/body_models/smpl/_model.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
prepare_pose
¶
prepare_pose(body_pose, *, pelvis_rotation=None, identity)
Precompute pose-dependent state for repeated forward passes.
Source code in src/body_models/smpl/_model.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |