Datasets
For EasyPL to work correctly, your dataset must return a dict. For ease of creating such a class, we prepared the base class PathBaseDataset.
- class easypl.datasets.base.PathBaseDataset(image_prefix: str = '', path_transform: Optional[Callable] = None, transform: Optional = None)
Abstract class of path based dataset
- image_prefix
path prefix which will be added to paths of images in csv file
- Type:
str
- path_transform
None or function for transform of path. Will be os.path.join(image_prefix, path_transform(image_path))
- Type:
Optional[Callable]
- transform
albumentations transform class or None
- Type:
Optional
- __len__() int
Return length of dataset
- Return type:
int
- __getitem__(idx: int) Dict
Read object of dataset by index
- idx
index of object in dataset
- Type:
int
- Returns:
object of dataset if dict format
- Return type:
Dict
- _read_image(image_id: Any, image_prefix: Optional[str] = None, **image_read_kwargs) Any
Read image from disk
- image_id
Any image identifier
- Type:
Any
- image_prefix
prefix identifier with os.path.join if is str
- Type:
Optional
- image_read_kwargs
Additional arguments for function easypl.datasets.utils.read_image
- Returns:
image object
- Return type:
Any
For correctly using PathBaseDataset you should override __len__ and __getitem__ methods. You can use _read_image method for simply image loading.
We create simply examples of datasets for classification and segmentation tasks. See below.