Skip to content

Commit 5f6eb12

Browse files
authored
Fix prediction deletion to prevent removing labeled instances (#2478)
Fix deleting predictions in GUI
1 parent fee86ae commit 5f6eb12

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sleap/sleap_io_adaptors/lf_labels_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,16 @@ def remove_frames(labels: Labels, frames: List[LabeledFrame]):
114114

115115
def remove_instance(labels: Labels, instance: Instance, lf: LabeledFrame):
116116
"""Remove an instance from a labeled frame and update all related instances."""
117-
import numpy as np
118-
119117
lf_inst_to_remove = labels.find(video=lf.video, frame_idx=lf.frame_idx)[0]
120118
if lf_inst_to_remove:
121119
# Iterate backwards to safely remove from list
122120
for inst_idx in range(len(lf_inst_to_remove.instances) - 1, -1, -1):
123121
inst = lf_inst_to_remove.instances[inst_idx]
122+
if type(inst) != type(instance):
123+
continue
124124

125125
# Compare instances using numpy arrays with NaN handling
126-
points_match = np.array_equal(
127-
inst.numpy(), instance.numpy(), equal_nan=True
128-
)
126+
points_match = inst.same_pose_as(instance)
129127

130128
if points_match:
131129
# Also check track matching

0 commit comments

Comments
 (0)