lazyslide_models.segmentation.Cellpose

Contents

lazyslide_models.segmentation.Cellpose#

class Cellpose(diam_mean=None, model_path=None, pretrained_model='cpsam_v2', **eval_kwargs)#

Bases: SegmentationModel

cellpose 🤗Hugging Face GitHub Paper BSD-3-Clause [Stringer et al., 2021] Cell segmentation model

Cellpose-SAM cell segmentation. Needs cellpose>=4.2.0.

pretrained_model picks the weights. The default, "cpsam_v2", is upstream’s default since cellpose 4.2: the same SAM ViT-L as the original "cpsam", retrained to predict fewer spurious masks in low-contrast regions. "cpsam" is still available. "cpdino" and "cpdino-vitb" also need facebookresearch/dinov3 installed and come under the DINOv3 licence.

>>> zs.seg.cells(wsi, model="cellpose", pretrained_model="cpsam")

If you want to fine-tune the cellpose model, please take a look at the following resources:

To run a fine-tuned model, pass the model_path argument pointing to the fine-tuned weights.

>>> zs.seg.cells(wsi, model="cellpose", model_path="fine-tuned-checkpoint.pth")