PyTorch Datasets
Bases: Dataset
Torch dataset yielding tile images and xywh-coordinates from reader (requires
PyTorch).
Source code in histoslice/utils/_torch.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
__init__(reader, coordinates, level=0, transform=None)
Initialize SlideReaderDataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
SlideReader
|
|
required |
coordinates
|
Iterator[tuple[int, int, int, int]]
|
Iterator of xywh-coordinates. |
required |
level
|
int
|
Slide level for reading tile image. Defaults to 0. |
0
|
transform
|
Optional[Callable[[ndarray], Any]]
|
Transform function for tile images. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
Could not import |
Source code in histoslice/utils/_torch.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
Bases: Dataset
Torch dataset yielding tile images, image paths and optional labels (requires
PyTorch).
Source code in histoslice/utils/_torch.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
__init__(paths, *, labels=None, transform=None, use_cache=False, tile_shape=None)
Torch dataset yielding tile images from paths (requires PyTorch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[Union[str, Path]]
|
Paths to tile images. |
required |
labels
|
Optional[list[str]]
|
Indexable list of labels for each path. Defaults to None. |
None
|
transform
|
Optional[Callable[[ndarray], Any]]
|
Transform function for tile images. Defaults to None. |
None
|
use_cache
|
bool
|
Cache each image to shared array, requires that each tile has the same shape. Defaults to False. |
False
|
tile_shape
|
Optional[tuple[int, ...]]
|
Tile shape for creating a shared cache array. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
Could not import |
ValueError
|
Label and path lengths differ. |
ValueError
|
Tile shape is undefined but |
Source code in histoslice/utils/_torch.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |