Package ai.djl.basicdataset.cv
Class ImageDataset
java.lang.Object
ai.djl.training.dataset.RandomAccessDataset
ai.djl.basicdataset.cv.ImageDataset
- All Implemented Interfaces:
ai.djl.training.dataset.Dataset
- Direct Known Subclasses:
ImageClassificationDataset,ObjectDetectionDataset
public abstract class ImageDataset
extends ai.djl.training.dataset.RandomAccessDataset
A helper to create a
Dataset where the data contains a single
image.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImageDataset.BaseBuilder<T extends ImageDataset.BaseBuilder<T>>Used to build anImageClassificationDataset.Nested classes/interfaces inherited from interface ai.djl.training.dataset.Dataset
ai.djl.training.dataset.Dataset.Usage -
Field Summary
FieldsFields inherited from class ai.djl.training.dataset.RandomAccessDataset
dataBatchifier, device, labelBatchifier, limit, pipeline, prefetchNumber, sampler, targetPipeline -
Constructor Summary
ConstructorsConstructorDescriptionImageDataset(ImageDataset.BaseBuilder<?> builder) Creates a new instance ofRandomAccessDatasetwith the given necessary configurations. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ai.djl.modality.cv.ImagegetImage(long index) Returns the image at the given index in the dataset.intReturns the number of channels in the images in the dataset.Returns the height of the images in the dataset.Returns the width of the images in the dataset.protected ai.djl.ndarray.NDArraygetRecordImage(ai.djl.ndarray.NDManager manager, long index) Methods inherited from class ai.djl.training.dataset.RandomAccessDataset
availableSize, get, 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
matchingTranslatorOptions, prepare, prepare
-
Field Details
-
flag
protected ai.djl.modality.cv.Image.Flag flag
-
-
Constructor Details
-
ImageDataset
Creates a new instance ofRandomAccessDatasetwith the given necessary configurations.- Parameters:
builder- a builder with the necessary configurations
-
-
Method Details
-
getRecordImage
protected ai.djl.ndarray.NDArray getRecordImage(ai.djl.ndarray.NDManager manager, long index) throws IOException - Throws:
IOException
-
getImage
Returns the image at the given index in the dataset.- 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
-
getImageChannels
public int getImageChannels()Returns the number of channels in the images in the dataset.For example, RGB would be 3 channels while grayscale only uses 1 channel.
- Returns:
- the number of channels in the images in the dataset
-
getImageWidth
Returns the width of the images in the dataset.- Returns:
- the width of the images in the dataset
-
getImageHeight
Returns the height of the images in the dataset.- Returns:
- the height of the images in the dataset
-