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

Allow tracking on Instances (by adding Instance.tracking_score) #1302

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

roomrys
Copy link
Collaborator

@roomrys roomrys commented May 5, 2023

Description

Prior to Allow Retracking, we did not allow any tracking on user instances. Since re-tracking enables users to run tracking on user instances, we now need to either add a tracking_score attribute to user-instances, or refrain from assigning the tracking score if the matched instance is a user instance (see #1301). This PR adds an Instance.tracking_score attribute and updates spots where the tracking_score is written (including a FORMAT_ID bump in LabelsV1Adaptor).

Types of changes

  • Bugfix (Should have done this in Allow retracking #867)
  • New feature (Allow tracking on instances)
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

@codecov
Copy link

codecov bot commented May 5, 2023

Codecov Report

Merging #1302 (1ea047d) into develop (b5aab0e) will decrease coverage by 0.01%.
The diff coverage is 86.36%.

@@             Coverage Diff             @@
##           develop    #1302      +/-   ##
===========================================
- Coverage    72.36%   72.36%   -0.01%     
===========================================
  Files          133      133              
  Lines        23662    23675      +13     
===========================================
+ Hits         17123    17132       +9     
- Misses        6539     6543       +4     
Impacted Files Coverage Δ
sleap/nn/tracking.py 72.87% <62.50%> (-0.23%) ⬇️
sleap/gui/app.py 74.80% <100.00%> (ø)
sleap/gui/widgets/docks.py 94.69% <100.00%> (+0.37%) ⬆️
sleap/info/write_tracking_h5.py 90.90% <100.00%> (ø)
sleap/instance.py 89.07% <100.00%> (ø)
sleap/io/format/hdf5.py 94.17% <100.00%> (-0.03%) ⬇️
sleap/io/format/nix.py 95.53% <100.00%> (-0.02%) ⬇️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roomrys roomrys added the Re-tracking Spread This PR is part of the re-tracking spread of PRs label May 5, 2023
@roomrys roomrys marked this pull request as ready for review May 5, 2023 18:08
@talmo
Copy link
Collaborator

talmo commented May 5, 2023

Quick question: what happens when there is a user Instance that was created from a PredictedInstance on a frame? Will the user Instance be used preferentially and the PredictedInstance ignored? If not, this may lead to issues where extraneous tracks are generated right?

@roomrys
Copy link
Collaborator Author

roomrys commented May 25, 2023

All instances in the labeled frame were being considered individually. I've added the following to prefer user labeled instances in the frame if any:

sleap/sleap/nn/tracking.py

Lines 1192 to 1213 in 1ea047d

# Prefer user instances over predicted instances
instances = []
if lf.has_user_instances:
instances_to_track = lf.user_instances
if lf.has_predicted_instances:
instances = lf.predicted_instances
else:
instances_to_track = lf.predicted_instances
track_args = {"untracked_instances": instances_to_track}
if tracker.uses_image:
track_args["img"] = lf.video[lf.frame_idx]
else:
track_args["img"] = None
instances.extend(tracker.track(**track_args))
new_lf = LabeledFrame(
frame_idx=lf.frame_idx,
video=lf.video,
instances=instances,
)

@roomrys
Copy link
Collaborator Author

roomrys commented May 25, 2023

Holding off on this PR since it would require a file format update... best to be worn in on the develop branch for a bit before tacking onto the release. This mean that retracking can only be done on prediction-only projects until this PR is merged (i.e. users need to remove their user-labeled instances before retracking to avoid error).

@roomrys roomrys self-assigned this Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Re-tracking Spread This PR is part of the re-tracking spread of PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants