Skip to content

Feat/microsam#1097

Open
keejkrej wants to merge 5 commits intoSchmollerLab:mainfrom
keejkrej:feat/microsam
Open

Feat/microsam#1097
keejkrej wants to merge 5 commits intoSchmollerLab:mainfrom
keejkrej:feat/microsam

Conversation

@keejkrej
Copy link
Copy Markdown
Contributor

@keejkrej keejkrej commented May 7, 2026

microsam integration, requires modified microsam source for installation
https://github.com/keejkrej/micro-sam/tree/cellacdc
don't merge yet!

keejkrej and others added 5 commits May 7, 2026 11:02
- 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>
Copilot AI review requested due to automatic review settings May 7, 2026 09:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread cellacdc/myutils.py
Comment on lines 3999 to 4001
acdcPromptSegment = import_module(
f'cellacdc.promptable_models.{model_name}.acdcPromptSegment'
)
Comment on lines +83 to +90
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
Comment thread pyproject.toml
"matplotlib",
"sympy",
"imagecodecs"
"matplotlib"
Comment thread cellacdc/myutils.py
# Check if custom model (config is GUI-only)
import configparser
cp = configparser.ConfigParser()
cp.read(models_list_file_path)
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