PatchDataset

class PatchDataset(inputs, labels=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

labels

List of labels for sample at the same index in inputs. Default is None.

Type:

list

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"],
... )

Initialize PatchDataset.

Methods

Attributes