lazyslide.seg.semantic#
- semantic(wsi, model, tile_key='tiles', class_names=None, transform=None, mode='gaussian', sigma_scale=0.125, low_memory=False, threshold=0.5, ignore_index=0, buffer_px=2, chunk_size=512, batch_size=4, num_workers=0, device=None, amp=None, autocast_dtype=None, pbar=None, key_added='anatomical_structures')#
Semantic segmentation for the whole slide image.
- Parameters:
- wsi
WSIData The WSIData object to work on.
- modelSegmentationModel
The segmentation model.
- tile_keystr, default: “tiles”
The key of the tile table.
- class_nameslist of str or dict, optional
The class names for the segmentation. Either a list of class names or a dict mapping class indices to names.
- transformcallable, default: None
The transformation to apply to each input tile before segmentation.
- mode{“constant”, “gaussian”}, default: “gaussian”
The probability distribution to apply for the prediction map. “constant” uses uniform weights, “gaussian” applies a Gaussian weighting.
- sigma_scalefloat, default: 0.125
The scale of the Gaussian sigma for the importance map if mode is “gaussian”.
- low_memorybool, default: False
Whether to use a low-memory mode for processing large slides.
- thresholdfloat, default: 0.5
The threshold to binarize the probability map for segmentation.
- ignore_indexint or None, default: 0
The index to ignore during segmentation (e.g., background).
- buffer_pxint, default: 2
The buffer in pixels to apply when merging polygons.
- chunk_sizeint, default: 512
The size of chunks to process at a time when merging probability maps.
- batch_sizeint, default: 4
The batch size for segmentation.
- num_workersint, default: 0
The number of workers for data loading.
- devicestr, default: None
The device for the model (e.g., “cpu” or “cuda”). If None, automatically selected.
- ampbool, optional, default: False
Whether to use automatic mixed precision.
- autocast_dtypetorch.dtype, optional, default: torch.float16
The dtype for automatic mixed precision.
- pbarbool, default: True
Whether to show the progress bar.
- key_addedstr, default: “anatomical_structures”
The key for the added instance shapes in the WSIData object.
- wsi
- Returns:
- None
The segmentation results are added to the WSIData object under the specified key.