Split imageSegmentation module in several sub modules - #58
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors segmentationRDS/segmentation.py to defer heavy third-party imports until the relevant classes/methods are used, and adds several new Meshroom nodes (SAM3 video/image segmentation, ViTMatte matting, RDS prompt/tag utilities, BiRefNet matting) organized into new submodules under meshroom/.
Changes:
- Deferred GroundingDINO / Segment Anything / RAM imports in
segmentationRDS/segmentation.pyfrom module scope into class constructors/methods. - Added multiple new Meshroom nodes under
meshroom/sam3,meshroom/vitMatte,meshroom/rds, andmeshroom/birefnet. - Introduced new package initializers (
__init__.py) for the added Meshroom submodules.
Reviewed changes
Copilot reviewed 1 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| segmentationRDS/segmentation.py | Moves heavy ML imports to local scope within classes/methods. |
| meshroom/vitMatte/ViTMatte.py | Adds a ViTMatte-based matting Meshroom node. |
| meshroom/vitMatte/init.py | Declares the vitMatte Meshroom submodule. |
| meshroom/sam3/VideoSegmentationSam3Text.py | Adds SAM3 video segmentation driven by text prompts (with optional cryptomatte/color outputs). |
| meshroom/sam3/VideoSegmentationSam3Boxes.py | Adds SAM3 video segmentation driven by bounding boxes + tiling/multi-res options. |
| meshroom/sam3/VideoSegmentationSam3.py | Adds SAM3 video segmentation supporting text, box prompt, and clicks. |
| meshroom/sam3/ImageSegmentationSam3.py | Adds SAM3 image segmentation driven by text and bounding boxes (including loading shapes). |
| meshroom/sam3/init.py | Declares the sam3 Meshroom submodule. |
| meshroom/rds/ImageTagsExtraction.py | Adds a node to extract tags using the recognition model. |
| meshroom/rds/ImageSegmentationPrompt.py | Adds an end-to-end prompt-driven segmentation node (recognize → detect → segment). |
| meshroom/rds/ImageSegmentationBox.py | Adds a bbox/click-driven segmentation node (supports tracker + JSON). |
| meshroom/rds/ImageDetectionPrompt.py | Adds a prompt-driven detection node producing bounding boxes. |
| meshroom/rds/init.py | Declares the rds Meshroom submodule. |
| meshroom/birefnet/ImageBiRefNetMatting.py | Adds a BiRefNet-based matting node driven by bounding boxes. |
| meshroom/birefnet/init.py | Declares the birefnet Meshroom submodule. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cbentejac
approved these changes
Jun 26, 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.
This pull request refactors the import statements in
segmentationRDS/segmentation.pyby moving several third-party and internal module imports from the global scope into the relevant class constructors and methods. This change helps reduce unnecessary imports when certain classes or methods are not used, which can improve startup time and reduce memory usage.Refactoring: Move imports to local scope
groundingdino,segment_anything, andramrelated imports from the global scope into the constructors or methods of the classes that use them, such asSegmentationRDS,SegmentAnything,RecognizeAnything, andDetectAnything.inference_ramfromramto within theget_tagsmethod ofRecognizeAnythingandDetectAnythingclasses.predictfunction fromgroundingdino.util.inferenceinto thedetectmethod of theDetectAnythingclass.sqrtfrom themathmodule into thesegmentmethod of theDetectAnythingclass.These changes make the codebase more modular and efficient by ensuring that dependencies are only loaded when necessary.