Skip to content

Sam3 instance bonding#59

Open
demoulinv wants to merge 4 commits into
mainfrom
dev/sam3InstanceBonding
Open

Sam3 instance bonding#59
demoulinv wants to merge 4 commits into
mainfrom
dev/sam3InstanceBonding

Conversation

@demoulinv

Copy link
Copy Markdown
Collaborator

This pull request introduces a new "masks bonding" feature to the SAM3 image and video segmentation nodes in Meshroom, allowing overlapping instance masks to be merged using morphological operations. The change is configurable via new parameters and is implemented consistently across all relevant segmentation nodes and processing pipelines.

Feature: Masks Bonding for Overlapping Instances

  • Added new parameters enableBonding (bool) and bondingKernelSize (int) to the following nodes: ImageSegmentationSam3, VideoSegmentationSam3, VideoSegmentationSam3Text, and VideoSegmentationSam3Boxes, enabling users to control bonding behavior and kernel size for morphological processing.

Implementation: Mask Bonding Logic

  • Introduced a new utility function bond_masks in sam3Utils.py that performs dilation, conflict region detection, and morphological closing to merge overlapping masks, controlled by kernel size parameters.

Integration: Processing Pipeline Updates

  • Updated mask processing logic in all relevant processChunk methods to use the new bonding feature: when enabled and multiple masks are present, masks are merged using the bonding kernel size. This affects both forward and backward propagation in video segmentation, as well as tiling and text-prompted segmentation.

Documentation and Versioning

  • Updated documentation strings and comments to reflect the new bonding feature, and incremented the version of VideoSegmentationSam3Boxes to 4.1.

These changes collectively provide more robust control over how overlapping segmentation masks are handled, improving the quality of mask outputs in scenarios with touching or overlapping objects.

@demoulinv
demoulinv requested a review from Copilot July 6, 2026 08:42
@demoulinv demoulinv self-assigned this Jul 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread segmentationRDS/sam3Utils.py
Comment thread meshroom/sam3/VideoSegmentationSam3Text.py
Comment thread meshroom/sam3/VideoSegmentationSam3.py
Comment thread meshroom/sam3/VideoSegmentationSam3Boxes.py
Comment thread meshroom/sam3/ImageSegmentationSam3.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants