Skip to content

Commit

Permalink
Make foreground check efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 committed Jan 5, 2025
1 parent c42c144 commit 112f7e3
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 and len(np.unique(mask)) > 1:
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 and len(np.unique(mask)) > 1 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 112f7e3

Please sign in to comment.