PatchDataset¶
tiatoolbox.models.dataset.dataset_abc.PatchDataset
- class PatchDataset(inputs, labels=None, patch_input_shape=None)[source]¶
Define PatchDataset for torch inference.
- Define a simple patch dataset, which inherits from the
torch.utils.data.Dataset class.
- Parameters:
- inputs¶
Either a list of patches, where each patch is a ndarray or a list of valid path with its extension be (“.jpg”, “.jpeg”, “.tif”, “.tiff”, “.png”) pointing to an image.
- Type:
list or np.ndarray
- patch_input_shape¶
Size of patches input to the model. Patches are at requested read resolution, not with respect to level 0, and must be positive.
- Type:
Examples
>>> # A user defined preproc func and expected behavior >>> preproc_func = lambda img: img/2 # reduce intensity by half >>> transformed_img = preproc_func(img) >>> # create a dataset to get patches preprocessed by the above function >>> ds = PatchDataset( ... inputs=['/A/B/C/img1.png', '/A/B/C/img2.png'], ... labels=["labels1", "labels2"], ... patch_input_shape=(224, 224), ... )
Initialize
PatchDataset.Methods
Attributes