Skip to content

Conversation

@jeylau
Copy link
Contributor

@jeylau jeylau commented Nov 7, 2022

In #1946, np.full(..., np.nan) is required in order for FlipLR to work when keypoints are hidden. Occasionally though, a NaN point can be sampled as crop center

kpts = batch.keypoints[n].to_xy_array()
n_kpts = kpts.shape[0]
inds = np.arange(n_kpts)
if sampling == "density":
# Points located close to one another are sampled preferentially
# in order to augment crowded regions.
radius = 0.1 * min(h, w)
n_neighbors = self.calc_n_neighbors(kpts, radius)
# Include keypoints in the count to avoid null probabilities
n_neighbors += 1
p = n_neighbors / n_neighbors.sum()
else:
p = np.ones_like(inds) / n_kpts
center = kpts[random_state.choice(inds, p=p)]
causing imgaug errors.
This one-liner addresses this bug.

@jeylau jeylau added the bug fix! fix for a real buggy one... label Nov 7, 2022
@jeylau jeylau requested review from AlexEMG and MMathisLab November 7, 2022 12:39
@MMathisLab MMathisLab merged commit 81244bd into master Nov 7, 2022
@jeylau jeylau deleted the finite_crop_center branch November 8, 2022 08:44
biol-jsh added a commit to biol-jsh/DeepLabCut that referenced this pull request Nov 10, 2022
The current implementation of fliplr breaks when keypoints are hidden since only labels for visible points are forwarded to the pipeline. This is the second attempt at fixing this as an earlier attempt failed due to the error fixed in PR DeepLabCut#2037.
jonahpearl pushed a commit to jonahpearl/DeepLabCut that referenced this pull request Nov 27, 2022
MMathisLab pushed a commit that referenced this pull request Oct 27, 2023
* Fix fliplr augmentation for multi animal 2

The current implementation of fliplr breaks when keypoints are hidden since only labels for visible points are forwarded to the pipeline. This is the second attempt at fixing this as an earlier attempt failed due to the error fixed in PR #2037.

* added missing batch_joints append from DLC PR 1946

* made same changes to get_batch_from_video as get_batch. style fixes.

* Fix indices when training with identity

* Fix and expand unit tests

---------

Co-authored-by: Niels Poulsen <[email protected]>
Co-authored-by: Jessy Lauer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix! fix for a real buggy one...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants