Skip to content

Commit

Permalink
Minor update to avoid caching embeddings in evaluation (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 authored Nov 18, 2024
1 parent 962e34d commit bb548f9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions micro_sam/evaluation/instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bb548f9

Please sign in to comment.