lazyslide.seg.zero_shot

Contents

lazyslide.seg.zero_shot#

zero_shot(wsi, prompts, table_key, tile_key, tissue_key='tissues', threshold='otsu', model='sam', device=None, model_kwargs=None, key_added='zero_shot_segmentation', min_area=10, pbar=None, *, show_progress=None)#

Perform zero-shot learning segmentation on the WSI using the specified model and prompts.

Parameters:
wsiWSIData

The WSIData object to work on.

promptslist[str]

List of prompts for zero-shot segmentation.

table_keystr

The key for the similarity matrix in the WSIData object.

tile_keystr

The key for the tiles in the WSIData object.

tissue_keystr, default: “tissues”

The key for the tissues in the WSIData object.

thresholdstr | float | list[float], default: ‘otsu’

Thresholding method or value for segmentation. - ‘otsu’: Use Otsu’s method to determine threshold - float: Use a fixed threshold value - list[float]: Use different threshold values for each prompt

modelstr or SegmentationModelProtocol, default: “sam”

A promptable segmentation model, like SAM: a model registry key (see Models) or a model instance.

devicestr, optional

The device to run the model on (e.g., ‘cpu’, ‘cuda’).

model_kwargsdict, optional

Additional keyword arguments for the model, when model is a key.

key_addedstr, default: “zero_shot_segmentation”

The key to store the results in the WSIData object.

min_areafloat, default: 10

Minimum area for polygons to be included in the results.

pbarbool, optional

Whether to show a progress bar. If None, uses settings.pbar.

show_progressbool, optional

Deprecated since version 0.13.0: Use pbar instead; show_progress will be removed in 0.14.0.

Returns:
WSIData

The updated WSIData object with segmentation results.