Skip to content

[McByte part 2] Feat/mcbyte mask manager#418

Merged
tstanczyk95 merged 6 commits into
dev/mcbytefrom
feat/mcbyte-mask-manager
May 20, 2026
Merged

[McByte part 2] Feat/mcbyte mask manager#418
tstanczyk95 merged 6 commits into
dev/mcbytefrom
feat/mcbyte-mask-manager

Conversation

@tstanczyk95
Copy link
Copy Markdown
Collaborator

@tstanczyk95 tstanczyk95 commented May 15, 2026

What does this PR do?

Adds the initial mask manager infrastructure for McByte.

This PR introduces:

  • MaskManager
  • mask generator / propagator abstractions
  • MaskOutput and TrackletSnapshot
  • dummy box-mask generator
  • dummy identity mask propagator
  • initial integration with McByteTracker
  • unit tests for the mask manager and dummy backends

The current implementation is intentionally lightweight and uses dummy mask generation/propagation to establish the architecture before integrating SAM/Cutie and mask-aware association logic.

The tracker integration is currently passive and focused on validating the temporal mask-management pipeline and interfaces.

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Refactoring (no functional changes)

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:
Added tests for:

  • dummy box-mask generation
  • mask manager initialization
  • propagator usage after initialization
  • reset/state clearing behavior
  • McByte tracker integration with the mask manager

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas*
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)
  • The comments for the McByteTracker class code will provided when finalized. Currently still in development.

Additional Context

This PR is part of a larger staged McByte integration effort.

The current implementation focuses on establishing clean abstractions and testable infrastructure before integrating external segmentation/mask propagation backends (SAM and Cutie).

@tstanczyk95 tstanczyk95 requested a review from SkalskiP as a code owner May 15, 2026 01:23
@tstanczyk95 tstanczyk95 changed the title Feat/mcbyte mask manager [McByte part 2] Feat/mcbyte mask manager May 15, 2026
@tstanczyk95 tstanczyk95 requested a review from Borda May 15, 2026 01:27
@tstanczyk95 tstanczyk95 self-assigned this May 15, 2026
@tstanczyk95 tstanczyk95 requested a review from AlexBodner May 15, 2026 01:30
@Borda Borda added the enhancement New feature or request label May 15, 2026
@Borda Borda requested a review from Copilot May 15, 2026 07:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the initial McByte mask-management architecture (manager + generator/propagator abstractions) and wires it into McByteTracker with dummy backends, plus new unit tests to validate the basic temporal pipeline.

Changes:

  • Introduces MaskManager, MaskOutput, TrackletSnapshot, and mask generator/propagator base interfaces (with dummy implementations).
  • Integrates mask-management state into McByteTracker (previous-frame buffering and per-frame mask update call).
  • Adds unit tests covering dummy mask generation, mask-manager lifecycle, and a basic McByte tracking sequence.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/core/test_mcbyte_tracker.py Adds a basic McByteTracker smoke test using CMC + repeated detections.
tests/core/test_mcbyte_mask_manager.py Adds unit tests for MaskManager behavior and dummy generator/propagator backends.
src/trackers/core/mcbyte/utils.py Adds McByte lifecycle helper (get_alive_tracklets) and score fusion helper.
src/trackers/core/mcbyte/tracklet.py Implements McByteTracklet with scale-aware noise and CMC application support.
src/trackers/core/mcbyte/tracker.py Implements McByteTracker and integrates optional MaskManager pipeline state.
src/trackers/core/mcbyte/masks/base.py Defines TrackletSnapshot, MaskOutput, and abstract generator/propagator interfaces.
src/trackers/core/mcbyte/masks/dummy.py Adds dummy box-mask generator and identity propagator for scaffolding/tests.
src/trackers/core/mcbyte/masks/init.py Re-exports mask components for convenient imports.
src/trackers/core/mcbyte/mask_manager.py Adds MaskManager orchestration for init + propagation timing.
src/trackers/core/mcbyte/init.py Exposes McByteTracker from the mcbyte subpackage.

Comment on lines +55 to +72
if not self._initialized or self.mask_propagator is None:
mask_output = self.mask_generator.generate(previous_frame, previous_tracklets)
self._initialized = True

if self.mask_propagator is not None:
self.mask_propagator.initialize(previous_frame, mask_output)
propagated_output = self.mask_propagator.propagate(frame)
return propagated_output if propagated_output is not None else mask_output

return mask_output

propagated_output = self.mask_propagator.propagate(frame)
if propagated_output is not None:
return propagated_output

mask_output = self.mask_generator.generate(previous_frame, previous_tracklets)
self.mask_propagator.initialize(previous_frame, mask_output)
return mask_output
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 51874ea.

"""
self.tracks = []
self.frame_id = 0
McByteTracklet.count_id = 0
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 51874ea.

Comment thread src/trackers/core/mcbyte/tracker.py Outdated
Comment on lines +282 to +297
self._previous_frame = None if frame is None else frame.copy()
self._previous_tracklets = []

if detections.tracker_id is None:
return

for xyxy, tracker_id in zip(detections.xyxy, detections.tracker_id):
if tracker_id < 0:
continue
self._previous_tracklets.append(
TrackletSnapshot(
tracker_id=int(tracker_id),
xyxy=xyxy.copy(),
)
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 51874ea.

Comment on lines +9 to +13
import numpy as np
import supervision as sv
from deprecate import deprecated
from scipy.optimize import linear_sum_assignment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kept consistent with the existing BoT-SORT and CMC deprecation style, which already imports deprecated from deprecate in runtime source files.

Comment on lines +32 to +54
class McByteTracker(BaseTracker):
tracker_id = "mcbyte"

def __init__(
self,
lost_track_buffer: int = 30,
frame_rate: float = 30.0,
track_activation_threshold: float = 0.7,
minimum_consecutive_frames: int = 2,
minimum_iou_threshold_first_assoc: float = 0.2,
minimum_iou_threshold_second_assoc: float = 0.5,
minimum_iou_threshold_unconfirmed_assoc: float = 0.3,
high_conf_det_threshold: float = 0.6,
enable_cmc: bool = True,
cmc_method: CMCMethod = "sparseOptFlow",
cmc_downscale: int = 2,
instant_first_frame_activation: bool = True,
state_estimator_class: type[BaseStateEstimator] = XCYCWHStateEstimator,
iou: BaseIoU | None = None,
enable_mask_manager: bool = False,
mask_manager: MaskManager | None = None,
) -> None:
# Calculate maximum frames without update based on lost_track_buffer and
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 51874ea.

@tstanczyk95 tstanczyk95 force-pushed the feat/mcbyte-mask-manager branch 2 times, most recently from 5fdd43a to e05fed6 Compare May 18, 2026 16:06
@tstanczyk95 tstanczyk95 changed the base branch from develop to feat/mcbyte-core-skeleton May 18, 2026 16:07
Base automatically changed from feat/mcbyte-core-skeleton to dev/mcbyte May 20, 2026 12:11
@tstanczyk95 tstanczyk95 force-pushed the feat/mcbyte-mask-manager branch from f9ec49e to c6843d0 Compare May 20, 2026 12:14
Comment on lines +13 to +16
from trackers.core.mcbyte.masks.dummy import (
DummyBoxMaskGenerator,
DummyIdentityMaskPropagator,
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Dummy a public API?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was used to see/demonstrate that implementations of MaskGenerator and MaskPropagator can be successfully imported and used.

Now, to make it cleaner, Dummy masks are limited to the explicit masks.dummy module import. Adjusted in 588b852.

Thanks for pointing it out!

@tstanczyk95 tstanczyk95 merged commit d66fc25 into dev/mcbyte May 20, 2026
5 checks passed
@tstanczyk95 tstanczyk95 deleted the feat/mcbyte-mask-manager branch May 20, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants