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.RandomAccessDatasetA helper to create aDatasetwhere the data contains a single image.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImageDataset.BaseBuilder<T extends ImageDataset.BaseBuilder<T>>Used to build anImageClassificationDataset.
-
Field Summary
Fields Modifier and Type Field Description protected ai.djl.modality.cv.Image.Flagflag
-
Constructor Summary
Constructors Constructor Description ImageDataset(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 protected abstract ai.djl.modality.cv.ImagegetImage(long index)Returns the image at the given index in the dataset.intgetImageChannels()Returns the number of channels in the images in the dataset.abstract java.util.Optional<java.lang.Integer>getImageHeight()Returns the height of the images in the dataset.abstract java.util.Optional<java.lang.Integer>getImageWidth()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, randomSplit, size, subDataset, toArray
-
-
-
-
Constructor Detail
-
ImageDataset
public ImageDataset(ImageDataset.BaseBuilder<?> builder)
Creates a new instance ofRandomAccessDatasetwith the given necessary configurations.- Parameters:
builder- a builder with the necessary configurations
-
-
Method Detail
-
getRecordImage
protected ai.djl.ndarray.NDArray getRecordImage(ai.djl.ndarray.NDManager manager, long index) throws java.io.IOException- Throws:
java.io.IOException
-
getImage
protected abstract ai.djl.modality.cv.Image getImage(long index) throws java.io.IOExceptionReturns 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:
java.io.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
public abstract java.util.Optional<java.lang.Integer> getImageWidth()
Returns the width of the images in the dataset.- Returns:
- the width of the images in the dataset
-
getImageHeight
public abstract java.util.Optional<java.lang.Integer> getImageHeight()
Returns the height of the images in the dataset.- Returns:
- the height of the images in the dataset
-
-