Skip to content

Commit

Permalink
Add back instances that were not tracked
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys committed May 25, 2023
1 parent d882640 commit 1ea047d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sleap/nn/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,20 +1190,26 @@ def run_tracker(frames: List[LabeledFrame], tracker: BaseTracker) -> List[Labele
inst.track = None

# Prefer user instances over predicted instances
untracked_instances = (
lf.user_instances if lf.has_user_instances else lf.predicted_instances
)
track_args = {"untracked_instances": untracked_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=tracker.track(**track_args),
instances=instances,
)
new_lfs.append(new_lf)

Expand Down

0 comments on commit 1ea047d

Please sign in to comment.