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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Used to build an ImageClassificationDataset.

    Nested classes/interfaces inherited from interface ai.djl.training.dataset.Dataset

    ai.djl.training.dataset.Dataset.Usage
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ai.djl.modality.cv.Image.Flag
     

    Fields inherited from class ai.djl.training.dataset.RandomAccessDataset

    dataBatchifier, device, labelBatchifier, limit, pipeline, prefetchNumber, sampler, targetPipeline
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of RandomAccessDataset with the given necessary configurations.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract ai.djl.modality.cv.Image
    getImage(long index)
    Returns the image at the given index in the dataset.
    int
    Returns the number of channels in the images in the dataset.
    abstract Optional<Integer>
    Returns the height of the images in the dataset.
    abstract Optional<Integer>
    Returns the width of the images in the dataset.
    protected ai.djl.ndarray.NDArray
    getRecordImage(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, toArray

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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

      public ImageDataset(ImageDataset.BaseBuilder<?> builder)
      Creates a new instance of RandomAccessDataset with 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

      protected abstract ai.djl.modality.cv.Image getImage(long index) throws IOException
      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

      public abstract Optional<Integer> getImageWidth()
      Returns the width of the images in the dataset.
      Returns:
      the width of the images in the dataset
    • getImageHeight

      public abstract Optional<Integer> getImageHeight()
      Returns the height of the images in the dataset.
      Returns:
      the height of the images in the dataset