From bb548f9029af211fbe3596397332126dff1bbf72 Mon Sep 17 00:00:00 2001 From: Anwai Archit <52396323+anwai98@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:22:53 +0100 Subject: [PATCH] Minor update to avoid caching embeddings in evaluation (#782) --- micro_sam/evaluation/instance_segmentation.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/micro_sam/evaluation/instance_segmentation.py b/micro_sam/evaluation/instance_segmentation.py index 5e657190..ad1956b9 100644 --- a/micro_sam/evaluation/instance_segmentation.py +++ b/micro_sam/evaluation/instance_segmentation.py @@ -227,14 +227,16 @@ def run_instance_segmentation_grid_search( gt = _load_image(gt_path, gt_key, roi=None if rois is None else rois[i]) if embedding_dir is None: - segmenter.initialize(image) + embedding_path = None else: assert predictor is not None embedding_path = os.path.join(embedding_dir, f"{os.path.splitext(image_name)[0]}.zarr") - image_embeddings = util.precompute_image_embeddings( - predictor, image, embedding_path, ndim=2, verbose=verbose_embeddings - ) - segmenter.initialize(image, image_embeddings) + + image_embeddings = util.precompute_image_embeddings( + predictor, image, embedding_path, ndim=2, verbose=verbose_embeddings + ) + + segmenter.initialize(image, image_embeddings) _grid_search_iteration( segmenter, gs_combinations, gt, image_name,