Conversation
Avoid running stitch/tracklet conversion when no animals were detected in a video. `analyze_videos` now detects empty assemblies, warns, and leaves the pose predictions available without creating tracking files. `TrackletStitcher` raises a dedicated `EmptyTrackletsError`, and the stitcher test now expects that case.
Cover the no-detection path in pose-estimation assembly generation and the header-only tracklet case in the stitcher. These tests pin the expected empty-input behavior and the error type for invalid tracklet files.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Identity-padded predictions are miscounted, and skipped stitching can incorrectly be reported as successful.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Prevents empty multi-animal detections from aborting tracking and introduces a dedicated empty-tracklet exception.
Changes:
- Counts generated assemblies and skips stitching when none exist.
- Adds
EmptyTrackletsErrorand continues batch stitching after empty input. - Adds regression tests for assembly counts and empty tracklets.
File summaries
| File | Description |
|---|---|
deeplabcut/pose_estimation_pytorch/apis/videos.py |
Detects empty assemblies and skips automatic tracking. |
deeplabcut/refine_training_dataset/stitch.py |
Defines and handles EmptyTrackletsError. |
tests/pose_estimation_pytorch/apis/test_videos.py |
Tests assembly counting. |
tests/test_stitcher.py |
Tests empty-tracklet exceptions. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| snapshot_index=snapshot_index, | ||
| detector_snapshot_index=detector_snapshot_index, | ||
| ) | ||
| h5_files_created = True # .h5 file was created by stitch_tracklets |
| mask = ~np.all(preds < 0, axis=(1, 2)) | ||
| preds = preds[mask] | ||
|
|
||
| num_assemblies += len(preds) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
For multi-animal analysis with
auto_track=True, a video with no detections causes the entire operation to abort.Undetected frames are represented by
-1padded predictions. These entries are removed when assemblies are generated, so a fully undetected video produces an empty assemblies file. Tracking then proceeds anyway, eventually causingTrackletStitcherto raiseOSError("Tracklets are empty.").Changes
_generate_assemblies_file_full.picklepredictions availableEmptyTrackletsErroras aValueErrorsubclass for empty tracklet inputstitch_trackletsskip videos that raiseEmptyTrackletsError, allowing batch processing to continueCompatibility
Changes the exception raised for empty tracklets from
OSErrortoValueError. It also changesstitch_trackletsso that empty-tracklet videos are skipped rather than propagated as failures, including for GUI and standalone callers.No callers in the repository currently catch either exception.
Follow-up to #3488, where handling an
OverflowErrorin_generate_output_datarevealed this failure.