make CTD GenerativeSampler visibility-aware - #3305
Merged
Merged
Conversation
C-Achard
approved these changes
May 11, 2026
AlexEMG
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A regression analysis revealed that performance for ctd_coam drops since rc12, and more specifically since #2995. This PR applied some improvements to the PyTorch
DLCLoader, and amongs other changes it introduces a method_remove_nans()that sanitizes the ground truth keypoints.Cause:
The CTD
GenerativeSamplerat deeplabcut/pose_estimation_pytorch/data/generative_sampling.py relied on NaN propagation as an implicit safety net: invisible/unlabeled GT joints carried (NaN, NaN, vis=0) and NaN-based math made every synth path (good/jitter/miss/inv/swap) produce vis=0, and a final nan_mask zero’d visibility. Net effect: invisible joints stayed invisible in the conditional input. Since this implicit assumption is now not met anymore, we should explicitly make theGenerativeSamplervisibility aware.Changes:
This PR introduces a simple fix, where for invisible keypoints the generative sampling logic is skipped and a visibility of 0 is always propagated:
Note that this fix restores the observed regression.