Visitar URL original
Update FMPose3D modelzoo integration by deruyter92 · Pull Request #3221 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8d8795c
Route FMPose3D through modelzoo video inference
deruyter92 Feb 25, 2026
c03fb2f
Move fmpose 3d module to pose_estimation_pytorch/modelzoo
deruyter92 Feb 25, 2026
34909b9
add dedicated FMPose3D video inference function
deruyter92 Feb 25, 2026
6d2eb0d
skip 3d predictions for invalid/empty 2d poses
deruyter92 Feb 25, 2026
785b55f
update tests
deruyter92 Feb 25, 2026
75f160c
Include 3d outputs in return
deruyter92 Feb 25, 2026
afc64a7
Clamp and warn: set max_individuals to 1
deruyter92 Feb 25, 2026
1f4cd90
change 3d data to dataframe
deruyter92 Feb 25, 2026
79306d6
add tests
deruyter92 Feb 25, 2026
04518bd
Update documentation
deruyter92 Feb 25, 2026
de1c573
Update modelzoo documentation fmpose3d
deruyter92 Feb 26, 2026
45f91b2
add commment legenda to __init__ for keypoint refactoring
deruyter92 Feb 26, 2026
a541c84
Add future note for keypoint refactoring
deruyter92 Feb 26, 2026
a96b8ca
fmpose3d: Add pytest markers for fmpose3d, unittest and functional
deruyter92 Feb 26, 2026
dd042b4
Apply formatting
deruyter92 Feb 26, 2026
1b3d94c
fix parameter name change in docs
deruyter92 Feb 26, 2026
8412c73
adjust parameter name -> fmpose_return_3d
deruyter92 Feb 26, 2026
ae8af5a
Update parameter naming superanimal_name
deruyter92 Feb 26, 2026
c0de52e
change recommended superanimal name for fmpose_3d
deruyter92 Feb 28, 2026
b771f33
Merge branch 'main' into jaap/fmpose_modelzoo_integration
deruyter92 Mar 12, 2026
8923015
Merge branch 'main' into jaap/fmpose_modelzoo_integration
deruyter92 Mar 19, 2026
f2c14c5
bump required version extra fmpose3d >= 0.0.8
deruyter92 Mar 19, 2026
9c78ddc
Merge branch 'main' into jaap/fmpose_modelzoo_integration
MMathisLab Mar 19, 2026
18203b9
apply linting
deruyter92 Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
skip 3d predictions for invalid/empty 2d poses
  • Loading branch information
deruyter92 committed Feb 25, 2026
commit 6d2eb0d614e4a1716da8fa4a9cd8b361ccadd331
29 changes: 18 additions & 11 deletions deeplabcut/pose_estimation_pytorch/modelzoo/fmpose_3d/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Licensed under GNU Lesser General Public License v3.0
#
import json
import logging
from pathlib import Path

import numpy as np
Expand All @@ -22,11 +23,10 @@
VideoIterator,
create_df_from_prediction,
)
from deeplabcut.pose_estimation_pytorch.modelzoo.utils import (
raise_warning_if_called_directly,
)
from deeplabcut.utils.make_labeled_video import create_video

logger = logging.getLogger(__name__)


class NumpyEncoder(json.JSONEncoder):
"""Special json encoder for numpy types."""
Expand Down Expand Up @@ -70,14 +70,16 @@ def _video_inference_fmpose3d(
pcutoff: float = 0.1,
batch_size: int = 1,
dest_folder: str | Path | None = None,
device: str | None = "auto",
device: str | None = None,
create_labeled_video: bool = True,
cropping: list[int] | None = None,
) -> dict:
"""Perform FMPose3D video inference with a lightweight DLC loop."""
raise_warning_if_called_directly()

from tqdm import tqdm
import torch

if device is None or device == 'auto':
Comment thread
deruyter92 marked this conversation as resolved.
Resolved
device = "cuda:0" if torch.cuda.is_available() else "cpu"

if isinstance(video_paths, (str, Path)):
video_paths = [video_paths]
Expand Down Expand Up @@ -124,11 +126,16 @@ def _process_batch(frames: list[np.ndarray]) -> None:
num_bodyparts=num_bodyparts,
)
)
pose_3d = api.pose_3d(
keypoints_2d=pose_2d.keypoints,
image_size=pose_2d.image_size,
)
all_poses_3d.extend(np.asarray(pose_3d.poses_3d))
try:
pose_3d = api.pose_3d(
keypoints_2d=pose_2d.keypoints,
image_size=pose_2d.image_size,
)
all_poses_3d.extend(np.asarray(pose_3d.poses_3d))
except ValueError as e:
logger.info("Skipping 3D lifting for batch due to invalid 2D result: %s", e)
all_poses_3d.extend([np.zeros((0, num_bodyparts, 3)) for _ in frames])


batch: list[np.ndarray] = []
for frame in tqdm(video, desc="FMPose3D inference"):
Expand Down