Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out low-scoring skeletons spawned during inference #717

Open
olinesn opened this issue Apr 30, 2022 · 5 comments
Open

Filter out low-scoring skeletons spawned during inference #717

olinesn opened this issue Apr 30, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@olinesn
Copy link

olinesn commented Apr 30, 2022

Problem: We only allow for filtering based on instance score during tracking. We should have options for filtering even without tracking (e.g., during the HITL labeling process).

Solution: Add Predictor options and associated CLI flags and GUI fields to allow for filtering by score during inference independently of tracking.

This should also allow for filtering based on number of animals in addition to an absolute score threshold. This would cover the use case of doing single-animal tracking using multi-animal models.

See #640 for the first point related to including background frames.


Original issue:

As far as I understand, only labelled frames with skeletons are included in the training set. I have a prep where I occasionally have to reach my hand into the cage while the camera is on, and SLEAP inference ends up spawning lots of tracks that are low-scoring skeletons on my glove/arm.

What's the best way to deal with this? Options I can think of include:

1: Is there a way to include frames in the training set that do NOT have any animals in them, to teach the model what's NOT an animal?

2: Can I set a threshold for skeleton score when running inference on a video, and remove all skeletons below a threshold BEFORE they get stitched into tracks?

Thanks!

Arm

@roomrys roomrys added the enhancement New feature or request label Apr 30, 2022
@olinesn
Copy link
Author

olinesn commented May 1, 2022

This could potentially merged with #640

@talmo
Copy link
Collaborator

talmo commented May 2, 2022

Hi @olinesn,

  1. I don't remember if we tested this, but one workaround could be to have a skeleton with all nodes marked as not visible. I think this might be sufficient to have the frame included as a "negative" example. (This will not work, see comment below)

  2. Not quite the same, but using the sleap-track options --tracking.target_instance_count 3 --tracking.pre_cull_to_target 1 without setting the IOU will filter instances by score before tracking them. Not ideal though as it can still include spurious instances as long as it's less than the target count.

We'll work on these as enhancements. Thanks!!

Talmo

@talmo talmo changed the title Low-scoring skeletons spawned during inference Filter out low-scoring skeletons spawned during inference May 12, 2022
@davidasamy davidasamy assigned davidasamy and unassigned davidasamy Jun 13, 2022
@roomrys
Copy link
Collaborator

roomrys commented Feb 7, 2023

Since we seem to have gotten a lot of cases where people are marking all nodes as not visible, wanted to state here (at the root) that SLEAP will filter out all empty instances (with all non visible points). Labeling an instance as entirely occluded will not do anything (other than use-up your time):

@classmethod
def from_user_instances(
cls, labels: sleap.Labels, with_track_only: bool = False
) -> "LabelsReader":
"""Create a `LabelsReader` using the user instances in a `Labels` set.
Args:
labels: A `sleap.Labels` instance containing user instances.
with_track_only: If `True`, load only instances that have a track assigned.
Useful when training supervised ID models.
Returns:
A `LabelsReader` instance that can create a dataset for pipelining.
Notes:
This will remove "empty" instances, i.e., instances with no visible points,
in the original labels. Make a copy of the original labels if needed as they
will be modified in place.
"""
labels.remove_empty_instances(keep_empty_frames=False)
obj = cls.from_user_labeled_frames(labels)
obj.user_instances_only = True
obj.with_track_only = with_track_only
return obj

@olinesn
Copy link
Author

olinesn commented Feb 10, 2023

Since we seem to have gotten a lot of cases where people are marking all nodes as not visible, wanted to state here (at the root) that SLEAP will filter out all empty instances (with all non visible points). Labeling an instance as entirely occluded will not do anything (other than use-up your time):

@classmethod
def from_user_instances(
cls, labels: sleap.Labels, with_track_only: bool = False
) -> "LabelsReader":
"""Create a `LabelsReader` using the user instances in a `Labels` set.
Args:
labels: A `sleap.Labels` instance containing user instances.
with_track_only: If `True`, load only instances that have a track assigned.
Useful when training supervised ID models.
Returns:
A `LabelsReader` instance that can create a dataset for pipelining.
Notes:
This will remove "empty" instances, i.e., instances with no visible points,
in the original labels. Make a copy of the original labels if needed as they
will be modified in place.
"""
labels.remove_empty_instances(keep_empty_frames=False)
obj = cls.from_user_labeled_frames(labels)
obj.user_instances_only = True
obj.with_track_only = with_track_only
return obj

Thanks for the heads up!

@roomrys
Copy link
Collaborator

roomrys commented Sep 11, 2023

#1070 implemented this for top-down models, but this still needs to be applied for other models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants