Skip to content

Commit

Permalink
Check if predicted instance is removed that it's not referenced
Browse files Browse the repository at this point in the history
  • Loading branch information
Jvshen committed Nov 20, 2024
1 parent b55d4ef commit e4c542b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sleap/io/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
LABELS_JSON_FILE_VERSION = "2.0.0"

# For debugging, we can replace missing video files with a "dummy" video
USE_DUMMY_FOR_MISSING_VIDEOS = os.getenv("SLEAP_USE_DUMMY_VIDEOS", default="")
USE_DUMMY_FOR_MISSING_VIDEOS = os.getenv("SLEAP_USE_DUMMY_VIDEOS", default=True)


@attr.s(auto_attribs=True)
Expand Down Expand Up @@ -1441,6 +1441,13 @@ def remove_instance(
if not in_transaction:
self._cache.remove_instance(frame, instance)

# Check that if a `PredictedInstance` is removed, that it is not referenced
from_predicted_instances = [inst.from_predicted for inst in frame.instances]
if instance in from_predicted_instances:
containing_inst_idx: int = from_predicted_instances.index(instance)
containing_inst: Instance = frame.instances[containing_inst_idx]
containing_inst.from_predicted = None

# Also remove instance from `InstanceGroup` if any
session = self.get_session(frame.video)
if session is None:
Expand Down

0 comments on commit e4c542b

Please sign in to comment.