Dataset over a directory tree of the form root_dir/<class_name>/<image_file>, mirroring torchvision's ImageFolder convention. Class names are the sorted subdirectory names; each class's label is its index in that sorted order. Images are decoded lazily (per get() call) via ImageDecoder.
More...
#include <image_folder_dataset.hpp>
Dataset over a directory tree of the form root_dir/<class_name>/<image_file>, mirroring torchvision's ImageFolder convention. Class names are the sorted subdirectory names; each class's label is its index in that sorted order. Images are decoded lazily (per get() call) via ImageDecoder.
◆ ImageFolderDataset()
| pulsatrix::ImageFolderDataset::ImageFolderDataset |
( |
const std::string & |
root_dir, |
|
|
DeviceBackend * |
backend |
|
) |
| |
- Parameters
-
| root_dir | Directory containing one subdirectory per class. |
| backend | Backend to allocate decoded image Tensors through. Not owned. |
- Exceptions
-
| std::runtime_error | if root_dir doesn't exist/isn't a directory, or contains no class subdirectories – external boundary: a caller-supplied path. |
◆ classes()
| const std::vector< std::string > & pulsatrix::ImageFolderDataset::classes |
( |
| ) |
const |
|
inline |
Sorted class names; classes()[i] is the human-readable name for label i.
◆ get()
| Sample pulsatrix::ImageFolderDataset::get |
( |
int64_t |
index | ) |
const |
|
overridevirtual |
- Exceptions
-
| std::out_of_range | if index is out of bounds. |
| std::runtime_error | if the image file fails to decode (see ImageDecoder). |
- Returns
- {image (1,C,H,W), label (1,) float, the class's sorted-order index}.
Implements pulsatrix::Dataset.
◆ size()
| int64_t pulsatrix::ImageFolderDataset::size |
( |
| ) |
const |
|
overridevirtual |
The documentation for this class was generated from the following file: