pulsatrix
Loading...
Searching...
No Matches
pulsatrix::ImageFolderDataset Class Reference

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>

Inheritance diagram for pulsatrix::ImageFolderDataset:
Collaboration diagram for pulsatrix::ImageFolderDataset:

Public Member Functions

 ImageFolderDataset (const std::string &root_dir, DeviceBackend *backend)
 
int64_t size () const override
 Number of samples in this dataset.
 
Sample get (int64_t index) const override
 
const std::vector< std::string > & classes () const
 Sorted class names; classes()[i] is the human-readable name for label i.
 
- Public Member Functions inherited from pulsatrix::Dataset
virtual ~Dataset ()=default
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ImageFolderDataset()

pulsatrix::ImageFolderDataset::ImageFolderDataset ( const std::string &  root_dir,
DeviceBackend *  backend 
)
Parameters
root_dirDirectory containing one subdirectory per class.
backendBackend to allocate decoded image Tensors through. Not owned.
Exceptions
std::runtime_errorif root_dir doesn't exist/isn't a directory, or contains no class subdirectories – external boundary: a caller-supplied path.

Member Function Documentation

◆ 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_rangeif index is out of bounds.
std::runtime_errorif 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

Number of samples in this dataset.

Implements pulsatrix::Dataset.


The documentation for this class was generated from the following file: