Skip to content

Refactor CLI for micro-sam backend support#1276

Open
anwai98 wants to merge 8 commits into
devfrom
refactor-cli-backend
Open

Refactor CLI for micro-sam backend support#1276
anwai98 wants to merge 8 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
return device


def get_embedding_function(model_type: str) -> callable:

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.

This doesn't raise an error for an invalid model_type. I think it's better to raise here if model_type is invalid rather than relying on v1.util.precompute_image_embeddings to raise later.

@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

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