Class ImageClassificationDataset
- java.lang.Object
-
- ai.djl.training.dataset.RandomAccessDataset
-
- ai.djl.basicdataset.cv.ImageDataset
-
- ai.djl.basicdataset.cv.classification.ImageClassificationDataset
-
- All Implemented Interfaces:
ai.djl.training.dataset.Dataset
- Direct Known Subclasses:
AbstractImageFolder
public abstract class ImageClassificationDataset extends ImageDataset
A helper to createDatasets forApplication.CV.IMAGE_CLASSIFICATION.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ai.djl.basicdataset.cv.ImageDataset
ImageDataset.BaseBuilder<T extends ImageDataset.BaseBuilder<T>>
-
-
Field Summary
-
Fields inherited from class ai.djl.basicdataset.cv.ImageDataset
flag
-
-
Constructor Summary
Constructors Constructor Description ImageClassificationDataset(ImageDataset.BaseBuilder<?> builder)Creates a new instance ofRandomAccessDatasetwith the given necessary configurations.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ai.djl.training.dataset.Recordget(ai.djl.ndarray.NDManager manager, long index)abstract java.util.List<java.lang.String>getClasses()Returns the classes that the images in the dataset are classified into.protected abstract longgetClassNumber(long index)Returns the class of the data item at the given index.ai.djl.translate.Translator<ai.djl.modality.cv.Image,ai.djl.modality.Classifications>makeTranslator()Returns theImageClassificationTranslatormatching the format of this dataset.-
Methods inherited from class ai.djl.basicdataset.cv.ImageDataset
getImage, getImageChannels, getImageHeight, getImageWidth, getRecordImage
-
Methods inherited from class ai.djl.training.dataset.RandomAccessDataset
availableSize, getData, getData, getData, getData, randomSplit, size, subDataset, toArray
-
-
-
-
Constructor Detail
-
ImageClassificationDataset
public ImageClassificationDataset(ImageDataset.BaseBuilder<?> builder)
Creates a new instance ofRandomAccessDatasetwith the given necessary configurations.- Parameters:
builder- a builder with the necessary configurations
-
-
Method Detail
-
getClassNumber
protected abstract long getClassNumber(long index) throws java.io.IOExceptionReturns the class of the data item at the given index.- 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
- Throws:
java.io.IOException- if the data could not be loaded
-
get
public ai.djl.training.dataset.Record get(ai.djl.ndarray.NDManager manager, long index) throws java.io.IOException- Specified by:
getin classai.djl.training.dataset.RandomAccessDataset- Throws:
java.io.IOException
-
makeTranslator
public ai.djl.translate.Translator<ai.djl.modality.cv.Image,ai.djl.modality.Classifications> makeTranslator()
Returns theImageClassificationTranslatormatching the format of this dataset.- Returns:
- the
ImageClassificationTranslatormatching the format of this dataset
-
getClasses
public abstract java.util.List<java.lang.String> getClasses()
Returns the classes that the images in the dataset are classified into.- Returns:
- the classes that the images in the dataset are classified into
-
-