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.
Detection Fusion
Overview
This PR introduces Detection fusion functionality which adds ability to merge overlapping detections in
Sam3ProcessorSAM3 codebase.Summary
Implements detection fusion capability that merges overlapping detections based on IoU threshold, reducing duplicate detections and improving output quality.
Changes
1. New Parameter:
fuse_detections_iou_thresholdsam3/model/sam3_image_processor.py: Added optional parameter toSam3Processor.__init__()None(fusion disabled)0.3), enables merging of overlapping detections2. Detection Fusion Implementation
_fuse_detections()method: New private method implementing fusion logicmask_iou()fromsam3.perflib.masks_opsto compute pairwise mask IoUbox_ops.masks_to_boxes()3. Integration into Processing Pipeline
set_text_prompt()after mask generationfuse_detections_iou_thresholdis set and detections exist4. Comprehensive Test Suite
tests/test_sam3_image_processor.py: New test file with 260+ lines of tests5. Test Configuration Updates
pyproject.toml: Added warning filters for pytestUsage Example
Impact
Testing
tests/test_sam3_image_processor.pypytest tests/test_sam3_image_processor.pyFiles Changed
sam3/model/sam3_image_processor.py- Fusion implementationtests/__init__.py- Test module initializationtests/test_sam3_image_processor.py- Comprehensive test suitepyproject.toml- Test configuration updatesBackward Compatibility
✅ Fully backward compatible - All changes are additive or opt-in:
fuse_detections_iou_threshold=None)Future Considerations