Datasets
VisionDataset
eva.vision.data.datasets.VisionDataset
Bases: Dataset
, ABC
, Generic[DataSample]
Base dataset class for vision tasks.
filename
abstractmethod
Returns the filename of the index
'th data sample.
Note that this is the relative file path to the root.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the data-sample to select. |
required |
Returns:
Type | Description |
---|---|
str
|
The filename of the |
Source code in src/eva/vision/data/datasets/vision.py
Classification datasets
eva.vision.data.datasets.BACH
Bases: ImageClassification
Dataset class for BACH images and corresponding targets.
The dataset is split into train and validation by taking into account the patient IDs to avoid any data leakage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root |
str
|
Path to the root directory of the dataset. The dataset will be downloaded and extracted here, if it does not already exist. |
required |
split |
Literal['train', 'val'] | None
|
Dataset split to use. If |
None
|
download |
bool
|
Whether to download the data for the specified split.
Note that the download will be executed only by additionally
calling the :meth: |
False
|
transforms |
Callable | None
|
A function/transform which returns a transformed version of the raw data samples. |
None
|
Source code in src/eva/vision/data/datasets/classification/bach.py
eva.vision.data.datasets.PatchCamelyon
Bases: ImageClassification
Dataset class for PatchCamelyon images and corresponding targets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root |
str
|
The path to the dataset root. This path should contain the uncompressed h5 files and the metadata. |
required |
split |
Literal['train', 'val', 'test']
|
The dataset split for training, validation, or testing. |
required |
download |
bool
|
Whether to download the data for the specified split.
Note that the download will be executed only by additionally
calling the :meth: |
False
|
transforms |
Callable | None
|
A function/transform which returns a transformed version of the raw data samples. |
None
|
Source code in src/eva/vision/data/datasets/classification/patch_camelyon.py
Segmentation datasets
eva.vision.data.datasets.ImageSegmentation
Bases: VisionDataset[Tuple[Image, Mask]]
, ABC
Image segmentation abstract dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transforms |
Callable | None
|
A function/transforms that takes in an image and a label and returns the transformed versions of both. |
None
|
Source code in src/eva/vision/data/datasets/segmentation/base.py
classes: List[str] | None
property
Returns the list with names of the dataset names.
class_to_idx: Dict[str, int] | None
property
Returns a mapping of the class name to its target index.
load_image
abstractmethod
Loads and returns the index
'th image sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the data sample to load. |
required |
Returns:
Type | Description |
---|---|
Image
|
An image torchvision tensor (channels, height, width). |
Source code in src/eva/vision/data/datasets/segmentation/base.py
load_mask
abstractmethod
Returns the index
'th target masks sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the data sample target masks to load. |
required |
Returns:
Type | Description |
---|---|
Mask
|
The semantic mask as a (H x W) shaped tensor with integer |
Mask
|
values which represent the pixel class id. |
Source code in src/eva/vision/data/datasets/segmentation/base.py
load_metadata
Returns the dataset metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
The index of the data sample to return the metadata of.
If |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any] | None
|
The sample metadata. |
Source code in src/eva/vision/data/datasets/segmentation/base.py
eva.vision.data.datasets.TotalSegmentator2D
Bases: ImageSegmentation
TotalSegmentator 2D segmentation dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root |
str
|
Path to the root directory of the dataset. The dataset will be downloaded and extracted here, if it does not already exist. |
required |
split |
Literal['train', 'val', 'test'] | None
|
Dataset split to use. If |
required |
version |
Literal['small', 'full'] | None
|
The version of the dataset to initialize. If |
'full'
|
download |
bool
|
Whether to download the data for the specified split.
Note that the download will be executed only by additionally
calling the :meth: |
False
|
classes |
List[str] | None
|
Whether to configure the dataset with a subset of classes.
If |
None
|
optimize_mask_loading |
bool
|
Whether to pre-process the segmentation masks
in order to optimize the loading time. In the |
True
|
transforms |
Callable | None
|
A function/transforms that takes in an image and a target mask and returns the transformed versions of both. |
None
|