wsinfer.modellib.data#

Classes#

WholeSlideImagePatches

Dataset of one whole slide image.

Module Contents#

class wsinfer.modellib.data.WholeSlideImagePatches(wsi_path: str | pathlib.Path, patch_path: str | pathlib.Path, transform: Callable[[PIL.Image.Image], torch.Tensor] | None = None)[source]#

Bases: torch.utils.data.Dataset

Dataset of one whole slide image.

This object retrieves patches from a whole slide image on the fly.

Parameters:
  • wsi_path (str, Path) – Path to whole slide image file.

  • patch_path (str, Path) – Path to npy file with coordinates of input image.

  • transform (callable, optional) – A callable to modify a retrieved patch. The callable must accept a PIL.Image.Image instance and return a torch.Tensor.

worker_init(worker_id: int | None = None) None[source]#
__len__() int[source]#
__getitem__(idx: int) tuple[PIL.Image.Image | torch.Tensor, torch.Tensor][source]#