MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / lbs

Function lbs

util/smplx/smplx/lbs.py:142–239  ·  view source on GitHub ↗

Performs Linear Blend Skinning with the given shape and pose parameters. Parameters ---------- betas : torch.tensor BxNB The tensor of shape parameters pose : torch.tensor Bx(J + 1) * 3 The pose parameters in axis-angle format v_template torch.tensor BxVx3

(
    betas: Tensor,
    pose: Tensor,
    v_template: Tensor,
    shapedirs: Tensor,
    posedirs: Tensor,
    J_regressor: Tensor,
    parents: Tensor,
    lbs_weights: Tensor,
    pose2rot: bool = True,
)

Source from the content-addressed store, hash-verified

140
141
142def lbs(
143 betas: Tensor,
144 pose: Tensor,
145 v_template: Tensor,
146 shapedirs: Tensor,
147 posedirs: Tensor,
148 J_regressor: Tensor,
149 parents: Tensor,
150 lbs_weights: Tensor,
151 pose2rot: bool = True,
152) -> Tuple[Tensor, Tensor]:
153 """Performs Linear Blend Skinning with the given shape and pose parameters.
154
155 Parameters
156 ----------
157 betas : torch.tensor BxNB
158 The tensor of shape parameters
159 pose : torch.tensor Bx(J + 1) * 3
160 The pose parameters in axis-angle format
161 v_template torch.tensor BxVx3
162 The template mesh that will be deformed
163 shapedirs : torch.tensor 1xNB
164 The tensor of PCA shape displacements
165 posedirs : torch.tensor Px(V * 3)
166 The pose PCA coefficients
167 J_regressor : torch.tensor JxV
168 The regressor array that is used to calculate the joints from
169 the position of the vertices
170 parents: torch.tensor J
171 The array that describes the kinematic tree for the model
172 lbs_weights: torch.tensor N x V x (J + 1)
173 The linear blend skinning weights that represent how much the
174 rotation matrix of each part affects each vertex
175 pose2rot: bool, optional
176 Flag on whether to convert the input pose tensor to rotation
177 matrices. The default value is True. If False, then the pose tensor
178 should already contain rotation matrices and have a size of
179 Bx(J + 1)x9
180 dtype: torch.dtype, optional
181
182 Returns
183 -------
184 verts: torch.tensor BxVx3
185 The vertices of the mesh after applying the shape and pose
186 displacements.
187 joints: torch.tensor BxJx3
188 The joints of the model
189 """
190
191 batch_size = max(betas.shape[0], pose.shape[0])
192 device, dtype = betas.device, betas.dtype
193
194 # Add shape contribution
195 v_shaped = v_template + blend_shapes(betas, shapedirs)
196
197 # Get the joints
198 # NxJx3 array
199 J = vertices2joints(J_regressor, v_shaped)

Callers 10

forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90

Calls 4

blend_shapesFunction · 0.85
vertices2jointsFunction · 0.85
batch_rigid_transformFunction · 0.85
batch_rodriguesFunction · 0.70

Tested by

no test coverage detected