Skip to content

Commit

Permalink
Update segmentation.py (#72)
Browse files Browse the repository at this point in the history
* Update segmentation.py

Changed function CellPose to CellposeModels which allows for loading of user trained models.

* added default model_type if not provided to cellpose

---------

Co-authored-by: Jordao Bragantini <[email protected]>
  • Loading branch information
a-jacobo and JoOkuma authored Apr 9, 2024
1 parent 4a7f71c commit 4f46179
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ultrack/imgproc/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def inverted_edt(
class Cellpose:
def __init__(self, **kwargs) -> None:
"""See cellpose.models.Cellpose documentation for details."""
from cellpose.models import Cellpose as _Cellpose
from cellpose.models import CellposeModel as _Cellpose

if "pretrained_model" not in kwargs and "model_type" not in kwargs:
kwargs["model_type"] = "cyto"

self.model = _Cellpose(**kwargs)

Expand All @@ -223,5 +226,5 @@ def __call__(self, image: ArrayLike, **kwargs) -> np.ndarray:
Predicts image labels.
See cellpose.models.Cellpose.eval documentation for details.
"""
labels, _, _, _ = self.model.eval(image, **kwargs)
labels, _, _ = self.model.eval(image, **kwargs)
return labels

0 comments on commit 4f46179

Please sign in to comment.