Skip to content

Commit

Permalink
Fix check in automatic instance segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Oct 18, 2024
1 parent e623e58 commit 6330b72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions micro_sam/automatic_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def automatic_instance_segmentation(
ndim = image_data.ndim if ndim is None else ndim

if ndim == 2:
if image_data.ndim != 2 or image_data.shape[-1] != 3:
if (image_data.ndim != 2) and (image_data.ndim != 3 and image_data.shape[-1] != 3):
raise ValueError(f"The inputs does not match the shape expectation of 2d inputs: {image_data.shape}")

# Precompute the image embeddings.
Expand Down Expand Up @@ -135,7 +135,7 @@ def automatic_instance_segmentation(
else:
instances = mask_data_to_segmentation(masks, with_background=True, min_object_size=0)
else:
if image_data.ndim != 3 or image_data.shape[-1] != 3:
if (image_data.ndim != 3) and (image_data.ndim != 4 and image_data.shape[-1] != 3):
raise ValueError(f"The inputs does not match the shape expectation of 3d inputs: {image_data.shape}")

instances = automatic_3d_segmentation(
Expand Down

0 comments on commit 6330b72

Please sign in to comment.