Skip to content

Commit

Permalink
Minor update to prompt-based segmentation (#825)
Browse files Browse the repository at this point in the history
* Minor update to prompt-based segmentation

* Make foreground check efficient
  • Loading branch information
anwai98 authored Jan 5, 2025
1 parent f20416f commit 9073486
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions micro_sam/prompt_based_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def _to_tile(prompts, shape, tile_shape, halo):
raise ValueError("If points are passed you also need to pass labels.")
point_coords, point_labels = points, labels

elif use_points:
elif use_points and mask.sum() != 0:
point_coords, point_labels = _compute_points_from_mask(
mask, original_size=original_size, box_extension=box_extension,
use_single_point=use_single_point,
Expand All @@ -395,7 +395,7 @@ def _to_tile(prompts, shape, tile_shape, halo):
if box is None:
box = _compute_box_from_mask(
mask, original_size=original_size, box_extension=box_extension
) if use_box else None
) if use_box and mask.sum() != 0 else None
else:
box = _process_box(box, mask.shape, original_size=original_size, box_extension=box_extension)

Expand Down

0 comments on commit 9073486

Please sign in to comment.