From 1d74fbcb2ca280a553e0ecdb018e97b710b0abe0 Mon Sep 17 00:00:00 2001 From: Anwai Archit Date: Tue, 24 Sep 2024 18:05:58 +0200 Subject: [PATCH] Add docstring --- micro_sam/instance_segmentation.py | 18 ++++++++++++++++-- micro_sam/precompute_state.py | 4 ++-- micro_sam/util.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/micro_sam/instance_segmentation.py b/micro_sam/instance_segmentation.py index 9fc5d33a..5c7e0d9d 100644 --- a/micro_sam/instance_segmentation.py +++ b/micro_sam/instance_segmentation.py @@ -1157,8 +1157,22 @@ def automatic_instance_segmentation( halo: Optional[Tuple[int, int]] = None, use_amg: bool = False, **generate_kwargs -): - """ +) -> None: + """Run automatic segmentation for the input image. + + Args: + input_path: input_path: The input image file(s). Can either be a single image file (e.g. tif or png), + or a container file (e.g. hdf5 or zarr). + output_path: The output path where the instance segmentations will be saved. + embedding_path: The path where the embeddings are cached already / will be saved. + model_type: The SegmentAnything model to use. Will use the standard vit_l model by default. + checkpoint_path: Path to a checkpoint for a custom model. + key: The key to the input file. This is needed for container files (eg. hdf5 or zarr) + or to load several images as 3d volume. Provide a glob patterm, eg. "*.tif", for this case. + ndim: The dimensionality of the data. + tile_shape: Shape of the tiles for tiled prediction. By default prediction is run without tiling. + halo: Overlap of the tiles for tiled prediction. + use_amg: Whether to use Automatic Mask Generation (AMG) as the automatic segmentation method. """ predictor, state = util.get_sam_model(model_type=model_type, checkpoint_path=checkpoint_path, return_state=True) diff --git a/micro_sam/precompute_state.py b/micro_sam/precompute_state.py index e4a970b7..520f2bae 100644 --- a/micro_sam/precompute_state.py +++ b/micro_sam/precompute_state.py @@ -235,10 +235,10 @@ def precompute_state( a container file (e.g. hdf5 or zarr) or a folder with images files. In case of a container file the argument `key` must be given. In case of a folder it can be given to provide a glob pattern to subselect files from the folder. - output_path: The output path were the embeddings and other state will be saved. + output_path: The output path where the embeddings and other state will be saved. pattern: Glob pattern to select files in a folder. The embeddings will be computed for each of these files. To select all files in a folder pass "*". - model_type: The SegmentAnything model to use. Will use the standard vit_h model by default. + model_type: The SegmentAnything model to use. Will use the standard vit_l model by default. checkpoint_path: Path to a checkpoint for a custom model. key: The key to the input file. This is needed for contaner files (e.g. hdf5 or zarr) or to load several images as 3d volume. Provide a glob pattern, e.g. "*.tif", for this case. diff --git a/micro_sam/util.py b/micro_sam/util.py index af1d1dc6..6a4cbc9e 100644 --- a/micro_sam/util.py +++ b/micro_sam/util.py @@ -44,7 +44,7 @@ from tqdm import tqdm # this is the default model used in micro_sam -# currently set to the default vit_h +# currently set to the default vit_l _DEFAULT_MODEL = "vit_l" # The valid model types. Each type corresponds to the architecture of the