Skip to content

Commit d112fc8

Browse files
committed
add documentation for limb_regularization and quadruped dataset
1 parent 2b1026c commit d112fc8

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

fmpose3d/fmpose3d.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def predict(
215215

216216
@staticmethod
217217
def _map_keypoints(xy: np.ndarray) -> np.ndarray:
218-
"""Map quadruped80K keypoints to Animal3D 26-joint layout.
218+
"""Map keypoints from the quadruped80K dataset format (see: DeepLabCut model zoo:
219+
https://huggingface.co/mwmathis/DeepLabCutModelZoo-SuperAnimal-Quadruped)
220+
to the FMPose3D 3d animal 26-joint layout.
219221
220222
Parameters
221223
----------
@@ -266,6 +268,22 @@ def compute_limb_regularization_matrix(
266268
and averaged. A Rodrigues rotation is computed to map the result
267269
onto ``(0, 0, 1)``.
268270
271+
This is primarily intended for visualization and canonicalization of
272+
upright poses.
273+
274+
.. note:: **Limitations**
275+
276+
* The function assumes a stable "up" limb direction and may produce
277+
poor results for poses where this assumption does not hold (e.g.
278+
lying down, jumping, or other non-upright orientations).
279+
* The rotation is computed independently per frame with no temporal
280+
smoothing or prior, so it can be unstable across frames and may
281+
cause flickering in video sequences.
282+
283+
If these assumptions do not match your data, consider using the raw
284+
predicted pose and implementing custom regularization logic suited
285+
to your use-case.
286+
269287
Parameters
270288
----------
271289
pose_3d : ndarray
@@ -375,6 +393,7 @@ def __call__(
375393
raw_output: torch.Tensor,
376394
*,
377395
camera_rotation: np.ndarray | None,
396+
limb_regularization: bool = True,
378397
) -> tuple[np.ndarray, np.ndarray]:
379398
"""Return ``(pose_3d, pose_world)`` each of shape ``(J, 3)``.
380399
@@ -386,7 +405,10 @@ def __call__(
386405
Ignored (accepted for interface compatibility).
387406
"""
388407
pose_3d = raw_output[0, 0].cpu().detach().numpy()
389-
R_reg = compute_limb_regularization_matrix(pose_3d)
408+
R_reg = (
409+
compute_limb_regularization_matrix(pose_3d) if limb_regularization
410+
else np.eye(3)
411+
)
390412
pose_world = apply_limb_regularization(pose_3d, R_reg)
391413
return pose_3d, pose_world
392414

0 commit comments

Comments
 (0)