Fix TypeError when loading image sequences #2452
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a
TypeErrorthat occurred when loading SLEAP files containing image sequences (e.g., from DeepLabCut projects) in the GUI.Problem
After a recent update, opening certain
.slpfiles in the GUI resulted in:Error location:
sleap/sleap_io_adaptors/lf_labels_utils.py:817Root Cause
The
sleap-iolibrary'sVideo.filenameattribute can be either:str- for regular video files (mp4, avi, etc.)list[str]- for image sequences (multiple PNG/JPG files)The video callback code assumed
filenamewas always a single value. When processing image sequences, this created a list of lists, causingos.path.exists()to fail with a TypeError.Example Issue
Solution
Modified the video callback in
lf_labels_utils.pyto handle both single files and image sequences:Code Changes
Before:
After:
Also updated the filename restoration logic to preserve image sequence lists when updating paths.
Testing
Tested with a DeepLabCut project file containing:
Results:
Investigation
Detailed investigation materials are available in
scratch/video_path_bug_investigation/:Impact
🤖 Generated with Claude Code