[McByte part 7] Mask manager delayed mask creation#491
Open
tstanczyk95 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the McByte MaskManager to support delayed mask creation for heavily occluded tracklets by maintaining a shared “pending tracklets” pool and retrying mask creation when tracklets become suitable, aligning behavior with the original McByte design. It also adds automated tests and a GT-replay visual script to validate the lifecycle across longer sequences.
Changes:
- Added overlap-based delayed mask creation with a shared pending-tracklet pool and retry logic in
MaskManager. - Expanded unit tests to cover delayed initialization/addition and pending-tracklet lifecycle behavior.
- Added a ground-truth replay visualization script to sanity-check delayed creation end-to-end over sequences.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/trackers/core/mcbyte/mask_manager.py | Implements delayed mask creation, pending pool management, and retry logic based on bbox overlap. |
| tests/core/test_mcbyte_mask_manager.py | Adds unit tests for delayed initialization/addition, retry behavior, and pending removal on termination. |
| visual_tests/visualize_mask_manager_from_gt.py | Adds GT-driven visual integration script to replay tracklets and inspect delayed creation behavior across sequences. |
Comment on lines
147
to
+160
| if previous_frame is None: | ||
| return None | ||
|
|
||
| if not self._initialized and len(previous_tracklets) == 0: | ||
| return None | ||
|
|
||
| if self.mask_propagator is None: | ||
| return None | ||
|
|
||
| new_tracklets = [] if new_tracklets is None else new_tracklets | ||
| removed_tracklet_ids = [] if removed_tracklet_ids is None else removed_tracklet_ids | ||
|
|
||
| self._remove_pending_tracklets(removed_tracklet_ids) | ||
|
|
Comment on lines
85
to
+89
| self.mask_generator = mask_generator | ||
| self.mask_propagator = mask_propagator | ||
| self.mask_creation_bbox_overlap_threshold = mask_creation_bbox_overlap_threshold | ||
| self._initialized = False | ||
| self._pending_tracklet_ids: set[int] = set() |
Borda
approved these changes
Jul 8, 2026
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.
What does this PR do?
This PR extends
MaskManagerwith robust delayed mask creation, reproducing the original McByte behavior for heavily occluded tracklets.Instead of creating masks immediately for every newly detected tracklet,
MaskManagernow postpones mask generation for tracklets whose bounding boxes are strongly occluded. Delayed tracklets are maintained in a shared pending pool and are automatically retried on subsequent frames using their most recent tracker state until a suitable bounding box becomes available.The same delayed mask creation logic is consistently applied both during the initial
CutieMaskPropagatorinitialization and during subsequent dynamic mask additions.Main additions:
MaskManagerinitialization when no suitable tracklets are available during the first framesvisualize_mask_manager_from_gt.py) replaying ground-truth tracklets to validate delayed mask creation on complete video sequencesMaskManagerType of Change
Testing
Test details:
Added and updated unit tests covering:
MaskManagerinitializationMaskManagerinitialization after multiple initial frames without suitable trackletsManual validation:
Checklist
Additional Context
This PR builds directly on the previous
MaskManagerintegration PR (#481) and extends it with the delayed mask creation strategy used by the original McByte implementation.To facilitate the validation of the introduced functionality, a new visualization script (
visualize_mask_manager_from_gt.py) has been added. Unlike the previous visualization utility, which manually specified lifecycle events, the new script replays complete MOT-style ground-truth annotations and emulates the original McByte execution order:Ground-truth tracklets ---> Tracker state replay ---> MaskManager (frame t using tracker state from frame t-1) ---> SAMBoxMaskGenerator ---> CutieMaskPropagator ---> VisualizationThis allows delayed initialization, delayed mask addition, pending-tracklet retry, and late initialization to be inspected over complete video sequences.
No additional external dependencies beyond those introduced by the previous Cutie integration PR #452 (section Additional Context) are required.
Tested on CPU (very slow, not recommended) and on GPU (CUDA 12.6) using separate Anaconda environments.
Visual validation was performed on all 49 SoccerNet-tracking test sequences.
Example test run:
The
--tracklet-idargument can be repeated to visualize selected tracklets only. If omitted, or when--tracklet-id allis specified, all tracklets from the ground-truth file are replayed.As described in #452 (at the end of the PR description), the required model weights are downloaded automatically.