Feat/microsam#1097
Conversation
- cellacdc/promptable_models/micro-sam/acdcPromptSegment.py: Model with vit_b_lm default, same interface as sam2
- myutils: download_model('micro-sam') returns True (weights via pooch on first use)
- tests: ensure_microsam(), test_microsam.py (skipped when no GPU)
Co-authored-by: Cursor <cursoragent@cursor.com>
…_other_objects_as_background=False - micro-sam: remove i param from segment_from_points (2D data rejects index) - micro-sam, sam2, segment_anything: set treat_other_objects_as_background=False by default Co-authored-by: Cursor <cursoragent@cursor.com>
- Use micro-sam @ git+https://github.com/keejkrej/micro-sam.git in microsam extra - Remove [tool.uv.sources] override for broader pip/uv compatibility Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces initial micro-sam support into Cell-ACDC’s promptable segmentation framework, along with installation extras and a new prompt-segmentation test to exercise the integration.
Changes:
- Added a new promptable model implementation for micro-sam and a corresponding pytest module test.
- Simplified test import checks for SAM/SAM2 and added an import check for micro-sam.
- Updated packaging (
pyproject.toml) to add optional extras for SAM/SAM2/CellSAM/micro-sam and adjusted core dependencies.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tests/utils/segmentation.py |
Simplifies ensure_sam/ensure_sam2 and adds ensure_microsam. |
tests/utils/__init__.py |
Re-exports ensure_microsam for test modules. |
tests/prompt_segm/test_microsam.py |
Adds a prompt-based micro-sam integration test using ground-truth centroids. |
pyproject.toml |
Updates base deps and adds new optional dependency groups for promptable SAM variants and micro-sam. |
cellacdc/promptable_models/segment_anything/acdcPromptSegment.py |
Changes default treat_other_objects_as_background behavior. |
cellacdc/promptable_models/sam2/acdcPromptSegment.py |
Changes default treat_other_objects_as_background behavior. |
cellacdc/promptable_models/micro-sam/acdcPromptSegment.py |
Adds the new promptable micro-sam backend implementation. |
cellacdc/myutils.py |
Uses stdlib configparser for custom model config parsing and adds micro-sam handling in download_model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| acdcPromptSegment = import_module( | ||
| f'cellacdc.promptable_models.{model_name}.acdcPromptSegment' | ||
| ) |
| def _set_image(self, image): | ||
| img_rgb = self._to_rgb(image) | ||
| if self._embedded_shape is None or self._embedded_shape != img_rgb.shape: | ||
| self._image_embeddings = precompute_image_embeddings( | ||
| self.model, img_rgb, ndim=2, verbose=False, | ||
| ) | ||
| self._embedded_shape = img_rgb.shape | ||
|
|
| slice(x0, x0 + obj_mask.shape[2]), | ||
| ) | ||
|
|
||
| lab_out[obj_slice][obj_mask] = prompt_id |
| "matplotlib", | ||
| "sympy", | ||
| "imagecodecs" | ||
| "matplotlib" |
| # Check if custom model (config is GUI-only) | ||
| import configparser | ||
| cp = configparser.ConfigParser() | ||
| cp.read(models_list_file_path) |
|
Hi @keejkrej, I just saw this PR now, sorry for not replying before. Anyway, this looks awesome! Do you need any help? I tried integrating MicroSAM some time ago, but I needed a headless MicroSAM that does not exist, right? I also opened an issue on their GitHub page asking for a headless version of MicroSAM, but they haven't done it yet. Maybe you can comment on their issue as well? That way, they know more people would love this. I'm sure they would even be open to a PR from you, since you already went through this effort. |
Let micro-sam's install_requires pull transitive pip dependencies and pin the git fork to the cellacdc branch with headless import fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
microsam integration, requires modified microsam source for installation
https://github.com/keejkrej/micro-sam/tree/cellacdc
don't merge yet!