Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
getzze committed Aug 2, 2024
1 parent 1375963 commit 7d293c9
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions sleap/nn/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def from_instance(
shift_score: float = 0.0,
with_skeleton: bool = False,
):

points_array = new_points_array
if points_array is None:
points_array = ref_instance.points_array
Expand Down Expand Up @@ -517,6 +516,7 @@ def get_candidates(
@attr.s(auto_attribs=True)
class BaseTracker(abc.ABC):
"""Abstract base class for tracker."""

verbosity: str
report_rate: float

Expand Down Expand Up @@ -547,10 +547,10 @@ def run_step(self, lf: LabeledFrame) -> LabeledFrame:
)

def run_tracker(
self,
frames: List[LabeledFrame],
*,
verbosity: Optional[str] = None,
self,
frames: List[LabeledFrame],
*,
verbosity: Optional[str] = None,
final_pass: bool = True,
) -> List[LabeledFrame]:
"""Run the tracker on a set of labeled frames.
Expand Down Expand Up @@ -745,7 +745,6 @@ class Tracker(BaseTracker):
)
report_rate: float = 2.0


@property
def is_valid(self):
return self.similarity_function is not None
Expand Down Expand Up @@ -813,7 +812,6 @@ def track(
if t is None:
if self.has_max_tracking:
if len(self.track_matching_queue_dict) > 0:

# Default to last timestep + 1 if available.
# Here we find the track that has the most instances.
track_with_max_instances = max(
Expand All @@ -829,7 +827,6 @@ def track(
t = 0
else:
if len(self.track_matching_queue) > 0:

# Default to last timestep + 1 if available.
t = self.track_matching_queue[-1].t + 1

Expand All @@ -844,7 +841,6 @@ def track(

# Process untracked instances.
if untracked_instances:

if self.pre_cull_function:
self.pre_cull_function(untracked_instances)

Expand Down Expand Up @@ -934,7 +930,6 @@ def spawn_for_untracked_instances(
) -> List[InstanceType]:
results = []
for inst in unmatched_instances:

# Skip if this instance is too small to spawn a new track with.
if inst.n_visible_points < self.min_new_track_points:
continue
Expand Down Expand Up @@ -1108,7 +1103,6 @@ def pre_cull_function(inst_list):

@classmethod
def get_by_name_factory_options(cls):

options = []

option = dict(name="tracker", default="None")
Expand Down Expand Up @@ -1212,9 +1206,9 @@ def get_by_name_factory_options(cls):

option = dict(name="of_window_size", default=21)
option["type"] = int
option[
"help"
] = "For optical-flow: Optical flow window size to consider at each pyramid "
option["help"] = (
"For optical-flow: Optical flow window size to consider at each pyramid "
)
"scale level"
options.append(option)

Expand Down Expand Up @@ -1390,7 +1384,6 @@ def add_frame_instances(
# "usuable" instances—i.e., instances with the nodes that we'll track
# using Kalman filters.
elif frame_match.has_only_first_choice_matches:

good_instances = [
inst for inst in instances if self.is_usable_instance(inst)
]
Expand Down Expand Up @@ -1610,7 +1603,6 @@ def track(
# Check whether we've been getting good results from the Kalman filters.
# First, has it been a while since the filters were initialized?
if self.init_done and (t - self.last_init_t) > self.re_init_cooldown:

# If it's been a while, then see if it's also been a while since
# the filters successfully matched tracks to the instances.
if self.kalman_tracker.last_frame_with_tracks < t - self.re_init_after:
Expand Down

0 comments on commit 7d293c9

Please sign in to comment.