Skip to content

Split imageSegmentation module in several sub modules - #58

Merged
cbentejac merged 2 commits into
mainfrom
dev/splitInSubModules
Jun 26, 2026
Merged

Split imageSegmentation module in several sub modules#58
cbentejac merged 2 commits into
mainfrom
dev/splitInSubModules

Conversation

@demoulinv

Copy link
Copy Markdown
Collaborator

This pull request refactors the import statements in segmentationRDS/segmentation.py by 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

  • Moved all groundingdino, segment_anything, and ram related imports from the global scope into the constructors or methods of the classes that use them, such as SegmentationRDS, SegmentAnything, RecognizeAnything, and DetectAnything.
  • Deferred the import of inference_ram from ram to within the get_tags method of RecognizeAnything and DetectAnything classes.
  • Moved the import of the predict function from groundingdino.util.inference into the detect method of the DetectAnything class.
  • Moved the import of sqrt from the math module into the segment method of the DetectAnything class.

These changes make the codebase more modular and efficient by ensuring that dependencies are only loaded when necessary.

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

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.py from module scope into class constructors/methods.
  • Added multiple new Meshroom nodes under meshroom/sam3, meshroom/vitMatte, meshroom/rds, and meshroom/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.

Comment thread segmentationRDS/segmentation.py
Comment thread segmentationRDS/segmentation.py
@demoulinv
demoulinv requested a review from cbentejac June 25, 2026 15:01
@cbentejac
cbentejac merged commit dc815b8 into main Jun 26, 2026
1 check passed
@cbentejac
cbentejac deleted the dev/splitInSubModules branch June 26, 2026 16:53
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.

3 participants