lazyslide.tl.tile_prediction

lazyslide.tl.tile_prediction#

tile_prediction(wsi, model, transform=None, batch_size=16, num_workers=0, tile_key='tiles', amp=None, autocast_dtype=None, device=None, pbar=True)#

Predict tiles using a tile prediction model.

A list of available models can be listed with:

from lazyslide_models import list_models

list_models(task="tile_prediction")
Parameters:
wsiWSIData

The WSIData object to work on.

modelstr or TilePredictionModel

The tile prediction model to use. If a string, it should be the name of the model.

transformcallable, optional

A transform function to apply to the tiles before prediction. If None, the model’s default transform is used.

batch_sizeint, default: 16

The batch size for the DataLoader.

num_workersint, default: 0

Number of worker threads for the DataLoader.

tile_keystr, default: “tiles”

The key in the WSIData object where the tiles are stored.

ampbool, optional, default: False

Whether to use automatic mixed precision.

autocast_dtypetorch.dtype, optional, default: torch.float16

The dtype for automatic mixed precision.

devicestr, optional

The device to run the model on.

pbarbool, default: True

Whether to show a progress bar during prediction.

Returns:
None

The predictions are added to the WSIData object.