Skip to content

Fix NaN handling in PredictKeypointIdentities postprocessor#3378

Draft
deruyter92 wants to merge 1 commit into
mainfrom
jaap/fix_postprocessor_nan_pafs
Draft

Fix NaN handling in PredictKeypointIdentities postprocessor#3378
deruyter92 wants to merge 1 commit into
mainfrom
jaap/fix_postprocessor_nan_pafs

Conversation

@deruyter92

Copy link
Copy Markdown
Collaborator

Summary
Fixes #3376 - RuntimeWarning: invalid value encountered in cast during analyze_videos on multi-animal models with identity enabled. PAF assembly leaves missing bodyparts as NaN; PredictKeypointIdentities now indexes the identity heatmap using only finite x/y coordinates and skips invalid keypoints.

Added a new test that reproduces the original issue, which is now fixed: tests/pose_estimation_pytorch/data/test_postprocessor.py::test_predict_keypoint_identities_handles_nan_keypoints

@C-Achard C-Achard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, clean fix!

Comment on lines +510 to +512
heatmap_indices = np.zeros((num_keypoints, 2), dtype=int)
if np.any(valid):
heatmap_indices[valid] = np.rint(xy[valid]).astype(int)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we shorten this by directly using the valid mask on heatmap_indices ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RuntimeWarning: invalid value encountered in cast in pose_estimation_pytorch/data/postprocessor.py

2 participants