Skip to content

Commit

Permalink
Merge pull request #213 from computational-cell-analytics/fix-tuple-a…
Browse files Browse the repository at this point in the history
…nnotation

Fix tuple annotations
  • Loading branch information
constantinpape authored Sep 26, 2023
2 parents 1c4ffba + 6c5e146 commit 855ceda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion micro_sam/instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __getitem__(self, index):

def mask_data_to_segmentation(
masks: List[Dict[str, Any]],
shape: tuple[int, ...],
shape: Tuple[int, ...],
with_background: bool,
min_object_size: int = 0,
) -> np.ndarray:
Expand Down
8 changes: 4 additions & 4 deletions micro_sam/prompt_based_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import warnings
from typing import Optional
from typing import Optional, Tuple

import numpy as np
from nifty.tools import blocking
Expand Down Expand Up @@ -308,7 +308,7 @@ def segment_from_mask(
use_box: bool = True,
use_mask: bool = True,
use_points: bool = False,
original_size: Optional[tuple[int, ...]] = None,
original_size: Optional[Tuple[int, ...]] = None,
multimask_output: bool = False,
return_all: bool = False,
return_logits: bool = False,
Expand Down Expand Up @@ -365,7 +365,7 @@ def segment_from_box(
box: np.ndarray,
image_embeddings: Optional[util.ImageEmbeddings] = None,
i: Optional[int] = None,
original_size: Optional[tuple[int, ...]] = None,
original_size: Optional[Tuple[int, ...]] = None,
multimask_output: bool = False,
return_all: bool = False,
):
Expand Down Expand Up @@ -405,7 +405,7 @@ def segment_from_box_and_points(
labels: np.ndarray,
image_embeddings: Optional[util.ImageEmbeddings] = None,
i: Optional[int] = None,
original_size: Optional[tuple[int, ...]] = None,
original_size: Optional[Tuple[int, ...]] = None,
multimask_output: bool = False,
return_all: bool = False,
):
Expand Down
8 changes: 4 additions & 4 deletions micro_sam/prompt_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from collections.abc import Mapping
from typing import Optional, Tuple
from typing import List, Optional, Tuple

import numpy as np
from scipy.ndimage import binary_dilation
Expand Down Expand Up @@ -155,10 +155,10 @@ def __call__(
self,
segmentation: np.ndarray,
segmentation_id: int,
bbox_coordinates: Mapping[int, tuple],
bbox_coordinates: Mapping[int, Tuple],
center_coordinates: Optional[Mapping[int, np.ndarray]] = None
) -> tuple[
Optional[list[tuple]], Optional[list[int]], Optional[list[tuple]], np.ndarray
) -> Tuple[
Optional[List[Tuple]], Optional[List[int]], Optional[List[Tuple]], np.ndarray
]:
"""Generate the prompts for one object in the segmentation.
Expand Down
2 changes: 1 addition & 1 deletion micro_sam/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _project_tiled_embeddings(image_embeddings):

def project_embeddings_for_visualization(
image_embeddings: ImageEmbeddings
) -> tuple[np.ndarray, tuple[float, ...]]:
) -> Tuple[np.ndarray, Tuple[float, ...]]:
"""Project image embeddings to pixel-wise PCA.
Args:
Expand Down

0 comments on commit 855ceda

Please sign in to comment.