Class AbstractImageFolder
java.lang.Object
ai.djl.training.dataset.RandomAccessDataset
ai.djl.basicdataset.cv.ImageDataset
ai.djl.basicdataset.cv.classification.ImageClassificationDataset
ai.djl.basicdataset.cv.classification.AbstractImageFolder
- All Implemented Interfaces:
ai.djl.training.dataset.Dataset
- Direct Known Subclasses:
FruitsFreshAndRotten,ImageFolder,ImageNet
A dataset for loading image files stored in a folder structure.
Usually, you want to use ImageFolder instead.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class ai.djl.basicdataset.cv.ImageDataset
ImageDataset.BaseBuilder<T extends ImageDataset.BaseBuilder<T>>Nested classes/interfaces inherited from interface ai.djl.training.dataset.Dataset
ai.djl.training.dataset.Dataset.Usage -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ai.djl.repository.MRLprotected booleanFields inherited from class ai.djl.basicdataset.cv.ImageDataset
flagFields inherited from class ai.djl.training.dataset.RandomAccessDataset
dataBatchifier, device, labelBatchifier, limit, pipeline, prefetchNumber, sampler, targetPipeline -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected longReturns the classes that the images in the dataset are classified into.protected longgetClassNumber(long index) Returns the class of the data item at the given index.protected ai.djl.modality.cv.ImagegetImage(long index) Returns the image at the given index in the dataset.Returns the height of the images in the dataset.protected abstract PathgetImagePath(String key) Returns the width of the images in the dataset.Returns the synsets of the ImageFolder dataset.protected booleanprotected voidlistImages(Path root, List<String> classes) Methods inherited from class ai.djl.basicdataset.cv.classification.ImageClassificationDataset
get, matchingTranslatorOptionsMethods inherited from class ai.djl.basicdataset.cv.ImageDataset
getImageChannels, getRecordImageMethods inherited from class ai.djl.training.dataset.RandomAccessDataset
getData, getData, getData, getData, newSubDataset, newSubDataset, randomSplit, size, subDataset, subDataset, subDataset, subDataset, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.djl.training.dataset.Dataset
prepare, prepare
-
Field Details
-
synset
-
items
-
mrl
protected ai.djl.repository.MRL mrl -
prepared
protected boolean prepared
-
-
Constructor Details
-
AbstractImageFolder
-
-
Method Details
-
getImage
Returns the image at the given index in the dataset.- Specified by:
getImagein classImageDataset- Parameters:
index- the index (if the dataset is a list of data items)- Returns:
- the image
- Throws:
IOException- if the image could not be loaded
-
getClassNumber
protected long getClassNumber(long index) Returns the class of the data item at the given index.- Specified by:
getClassNumberin classImageClassificationDataset- Parameters:
index- the index (if the dataset is a list of data items)- Returns:
- the class number or the index into the list of classes of the desired class name
-
availableSize
protected long availableSize()- Specified by:
availableSizein classai.djl.training.dataset.RandomAccessDataset
-
getSynset
Returns the synsets of the ImageFolder dataset.- Returns:
- a list that contains synsets
- Throws:
IOException- for various exceptions depending on the datasetai.djl.translate.TranslateException- if there is an error while processing input
-
listImages
-
getImagePath
-
isImage
-
getImageWidth
Returns the width of the images in the dataset.- Specified by:
getImageWidthin classImageDataset- Returns:
- the width of the images in the dataset
-
getImageHeight
Returns the height of the images in the dataset.- Specified by:
getImageHeightin classImageDataset- Returns:
- the height of the images in the dataset
-
getClasses
Returns the classes that the images in the dataset are classified into.- Specified by:
getClassesin classImageClassificationDataset- Returns:
- the classes that the images in the dataset are classified into
-