Visitar URL original
RTMpose_x superanimal_humanbody by MMathisLab · Pull Request #3043 · DeepLabCut/DeepLabCut · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
062e07e
edge case fix
MMathisLab Jul 1, 2025
be335f3
fix
MMathisLab Jul 1, 2025
8698d86
best
MMathisLab Jul 1, 2025
240584b
rc10
MMathisLab Jul 1, 2025
83f34b8
humanbody model zoo
MMathisLab Jul 5, 2025
165ff4c
Merge branch 'main' into mwm/humanbody
MMathisLab Jul 5, 2025
277fb22
Update video_inference.py
MMathisLab Jul 5, 2025
1fecece
onwards
MMathisLab Jul 5, 2025
618483a
working
MMathisLab Jul 5, 2025
8e46f4e
simpler
MMathisLab Jul 5, 2025
3e6ec52
working
MMathisLab Jul 5, 2025
7fab6fc
import depth
MMathisLab Jul 5, 2025
dbd0fd4
better warning message
MMathisLab Jul 5, 2025
ed4f786
less brittle check for torchvision model
MMathisLab Jul 5, 2025
65d00f1
all files
MMathisLab Jul 5, 2025
501f142
video fix
MMathisLab Jul 5, 2025
6b464b3
adapt other API
MMathisLab Jul 5, 2025
7600167
fix
MMathisLab Jul 5, 2025
8ce206b
cleaning up my mistakes
MMathisLab Jul 5, 2025
3515ba5
superanimals working
MMathisLab Jul 5, 2025
63929e8
likely fix for failing test
MMathisLab Jul 5, 2025
9286699
Fix hard-coded identity_scores dimensions in identity accuracy tests …
Copilot Jul 5, 2025
2dbeea6
Fix visualization reshape error with descriptive error messages and v…
Copilot Jul 5, 2025
dda7254
revert to main behavior in # of indv
MMathisLab Jul 6, 2025
74f420f
fix utils for logic
MMathisLab Jul 6, 2025
aff5703
remove my local test file
MMathisLab Jul 6, 2025
59a46cb
Update fasterRCNN.py
MMathisLab Jul 6, 2025
bd32b30
cleaning
MMathisLab Jul 6, 2025
cb3ec0c
testing
MMathisLab Jul 6, 2025
3536746
Update superanimal_inference.py
MMathisLab Jul 6, 2025
91d43c1
longer test back to main status
MMathisLab Jul 6, 2025
fee2e2f
Leave comment in unittests on what should be done
AlexEMG Jul 6, 2025
02cbf93
Update TF docstring
AlexEMG Jul 6, 2025
9a9b2f8
small fix for 2x run for pose
MMathisLab Jul 6, 2025
686bd4a
Update version to rc11
AlexEMG Jul 6, 2025
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
fix utils for logic
  • Loading branch information
MMathisLab committed Jul 6, 2025
commit 74f420f3e778aff7e39f470f7e416473f199b625
82 changes: 36 additions & 46 deletions deeplabcut/pose_estimation_pytorch/apis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,66 +390,56 @@ def build_predictions_dataframe(
Args:
scorer: The name of the scorer used to generate the predictions.
predictions: A dictionary where each key is an image name and its value is
another dictionary. The inner dictionary contains prediction arrays for
bodyparts and optionally unique_bodyparts.
parameters: Dataset parameters containing information about bodyparts,
individuals, and other configuration.
image_name_to_index: Optional function to convert image names to index tuples.
If None, image names are used directly as indices.
another dictionary. The inner dictionary contains prediction data for
"bodyparts" and optionally "unique_bodyparts". The "bodyparts" and
"unique_bodyparts" data arrays are expected to be 3-dimensional, containing
pose predictions in format (num_predicted_individuals, num_bodyparts, 3).
parameters: Dataset-specific parameters required for constructing DataFrame
columns.
image_name_to_index: A callable function that takes an image name and returns
a tuple representing the DataFrame index. If None, indices will be
generated without transformation.

Returns:
A pandas DataFrame with multi-level columns and properly formatted indices.
A pandas DataFrame containing the processed prediction data for all provided
images. The DataFrame index corresponds to the image names or their
transformed values (if `image_name_to_index` is provided). The DataFrame
columns are constructed using the provided scorer and parameters.
"""
image_names = []
prediction_data = []

# Always use the number of individuals from the config
expected_num_individuals = len(parameters.individuals)
expected_num_bodyparts = len(parameters.bodyparts)
# Check if this is a humanbody model by looking at the first prediction
if predictions:
first_pred = next(iter(predictions.values()))
if "bodyparts" in first_pred:
actual_num_individuals = first_pred["bodyparts"].shape[0]
expected_num_individuals = len(parameters.individuals)

# For humanbody models, if the actual number of individuals differs from expected,
# we need to adjust the parameters to match the actual predictions
if actual_num_individuals != expected_num_individuals:
# Create adjusted parameters with the actual number of individuals
adjusted_individuals = [f"individual_{i}" for i in range(actual_num_individuals)]
parameters = PoseDatasetParameters(
bodyparts=parameters.bodyparts,
unique_bpts=parameters.unique_bpts,
individuals=adjusted_individuals,
)

for image_name, image_predictions in predictions.items():
# Get the actual predictions for this image
if "bodyparts" in image_predictions:
actual_predictions = image_predictions["bodyparts"] # Shape: (num_detected, num_bodyparts, 3)
actual_num_detected = actual_predictions.shape[0]

# Pad or truncate to match expected number of individuals
if actual_num_detected < expected_num_individuals:
# Pad with NaN rows
padded_predictions = np.full((expected_num_individuals, expected_num_bodyparts, 3), np.nan)
padded_predictions[:actual_num_detected] = actual_predictions
image_data = padded_predictions.reshape(-1)
elif actual_num_detected > expected_num_individuals:
# Truncate to expected number
image_data = actual_predictions[:expected_num_individuals].reshape(-1)
else:
# Perfect match
image_data = actual_predictions.reshape(-1)
else:
# No bodypart predictions, fill with NaNs
image_data = np.full(expected_num_individuals * expected_num_bodyparts * 3, np.nan)

# Handle unique bodyparts if present
image_data = image_predictions["bodyparts"][..., :3].reshape(-1)
if "unique_bodyparts" in image_predictions:
unique_predictions = image_predictions["unique_bodyparts"]
unique_data = unique_predictions.reshape(-1)
image_data = np.concatenate([image_data, unique_data])
else:
# No unique bodyparts, add empty array
unique_data = np.array([])
image_data = np.concatenate([image_data, unique_data])

image_data = np.concatenate(
[image_data, image_predictions["unique_bodyparts"][..., :3].reshape(-1)]
)
image_names.append(image_name)
prediction_data.append(image_data)

# Build the index
if image_name_to_index is not None:
index = [image_name_to_index(name) for name in image_names]
else:
index = image_names
index = _image_names_to_df_index(image_names, image_name_to_index)

return pd.DataFrame(
data=prediction_data,
prediction_data,
index=index,
columns=build_dlc_dataframe_columns(
scorer=scorer,
Expand Down