Skip to content

Refactor CLI for micro-sam backend support#1276

Merged
constantinpape merged 10 commits into
devfrom
refactor-cli-backend
Jul 11, 2026
Merged

Refactor CLI for micro-sam backend support#1276
constantinpape merged 10 commits into
devfrom
refactor-cli-backend

Conversation

@anwai98

@anwai98 anwai98 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

WIP!

@anwai98 anwai98 marked this pull request as ready for review July 2, 2026 13:23
@anwai98

anwai98 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Okay this is sorted now! @constantinpape

Some details on how things would work:

  1. Needs a pip install -e . in the current branch
  2. Check out some simple integrations, eg. micro_sam --help / micro_sam --version / micro_sam info
  3. And the other ports:
    a. micro_sam.annotator -> micro_sam segmentation_annotator
    b. micro_sam.annotator_tracking -> micro_sam tracking_annotator
    c. micro_sam.automatic_segmentation (SAM1) -> micro_sam v1 automatic_segmentation
    d. micro_sam.train (SAM1) -> micro_sam v1 train
    e. micro_sam.evaluate / micro_sam.benchmark_sam -> micro_sam v1 evaluate / micro_sam v1 benchmark_sam
    f. micro_sam.precompute_embeddings / micro_sam.info -> micro_sam precompute_embeddings / micro_sam info
    g. ...and all other CLIs too

@constantinpape constantinpape 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.

I will test this properly tomorrow morning. Noticed one minor thing that could be improved in the code review.

Comment thread micro_sam/util.py
@constantinpape

Copy link
Copy Markdown
Contributor

Here's some more feedback:

General:

  • Shorten the first part of the doc string so that it is not cut from the general help message (see screenshot below)
  • It would be good to have a short usage example in the help message of each command (except info and v1).
  • Unify naming "-i" -> "--input" (currently varies between input, input_path, input_folder); "-o" -> "--outtput"
  • Rename halo -> overlap (mirror change in GUI)
image

Specific:

  • automatic_segmentation:
    • add an optional --view to display results in napari?
    • segmentation in a folder does not work: micro_sam automatic_segmentation --input_path /home/pape/.cache/micro_sam/sample_data/image-series.zip.unzip/series/ -o test-out-seg --pattern *.tif fails with File "/home/pape/Work/my_projects/micro-sam/micro_sam/cli.py", line 324, in automatic_segmentation assert len(input_paths) > 0, "'micro-sam' could not extract any image data internally."; folder contains 3 tif images
    • Note: it actually works when passing "*.tif", so probably just an issue in argument parsing
  • batch_annotator: opens the segmentation annotator but should support all of the annotators

I haven't checked the rest in detail

with the image as guidance instead of plain interpolation. Use the same setting that
the classifier was trained with.
model_type: The model family of `predictor`, used to pick the matching embedding function
(SAM1 / SAM2 / VFM). If not given, the SAM1 embedding function is used.

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.

I think we should use the SAM2 embedding function by default --- and use our uSAM2 model as the default model.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see. Then I'll wrap this out around it like that!

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.

Let's address this separately.

* Some CLI updates

* Fix CLI tests

* Update micro_sam/_cli.py

* Update micro_sam/_cli.py

---------

Co-authored-by: Anwai Archit <anwai.archit@gmail.com>
@constantinpape

Copy link
Copy Markdown
Contributor

Should we merge this @anwai98 ?

@anwai98

anwai98 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Oh I kind of was waiting for your approval here haha. If you assessment is positive here, let's go for it. It is GTM from my side!

@constantinpape

Copy link
Copy Markdown
Contributor

Yeah let's merge it.

@constantinpape constantinpape merged commit 66b0376 into dev Jul 11, 2026
4 checks passed
@constantinpape constantinpape deleted the refactor-cli-backend branch July 11, 2026 11:06
@anwai98

anwai98 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

Nice! ;)

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