Class AbstractImageFolder

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ai.djl.util.PairList<java.lang.String,​java.lang.Integer> items  
      protected ai.djl.repository.MRL mrl  
      protected boolean prepared  
      protected java.util.List<java.lang.String> synset  
      • Fields inherited from class ai.djl.training.dataset.RandomAccessDataset

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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected long availableSize()
      java.util.List<java.lang.String> getClasses()
      Returns the classes that the images in the dataset are classified into.
      protected long getClassNumber​(long index)
      Returns the class of the data item at the given index.
      protected ai.djl.modality.cv.Image getImage​(long index)
      Returns the image at the given index in the dataset.
      java.util.Optional<java.lang.Integer> getImageHeight()
      Returns the height of the images in the dataset.
      protected abstract java.nio.file.Path getImagePath​(java.lang.String key)  
      java.util.Optional<java.lang.Integer> getImageWidth()
      Returns the width of the images in the dataset.
      java.util.List<java.lang.String> getSynset()
      Returns the synsets of the ImageFolder dataset.
      protected void listImages​(java.nio.file.Path root, java.util.List<java.lang.String> classes)  
      • Methods inherited from class ai.djl.training.dataset.RandomAccessDataset

        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

        prepare, prepare
    • Field Detail

      • synset

        protected java.util.List<java.lang.String> synset
      • items

        protected ai.djl.util.PairList<java.lang.String,​java.lang.Integer> items
      • mrl

        protected ai.djl.repository.MRL mrl
      • prepared

        protected boolean prepared
    • Method Detail

      • getImage

        protected ai.djl.modality.cv.Image getImage​(long index)
                                             throws java.io.IOException
        Returns the image at the given index in the dataset.
        Specified by:
        getImage in class ImageDataset
        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
      • getClassNumber

        protected long getClassNumber​(long index)
        Returns the class of the data item at the given index.
        Specified by:
        getClassNumber in class ImageClassificationDataset
        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:
        availableSize in class ai.djl.training.dataset.RandomAccessDataset
      • getSynset

        public java.util.List<java.lang.String> getSynset()
                                                   throws java.io.IOException,
                                                          ai.djl.translate.TranslateException
        Returns the synsets of the ImageFolder dataset.
        Returns:
        a list that contains synsets
        Throws:
        java.io.IOException - for various exceptions depending on the dataset
        ai.djl.translate.TranslateException - if there is an error while processing input
      • listImages

        protected void listImages​(java.nio.file.Path root,
                                  java.util.List<java.lang.String> classes)
      • getImagePath

        protected abstract java.nio.file.Path getImagePath​(java.lang.String key)
      • getImageWidth

        public java.util.Optional<java.lang.Integer> getImageWidth()
        Returns the width of the images in the dataset.
        Specified by:
        getImageWidth in class ImageDataset
        Returns:
        the width of the images in the dataset
      • getImageHeight

        public java.util.Optional<java.lang.Integer> getImageHeight()
        Returns the height of the images in the dataset.
        Specified by:
        getImageHeight in class ImageDataset
        Returns:
        the height of the images in the dataset
      • getClasses

        public java.util.List<java.lang.String> getClasses()
        Returns the classes that the images in the dataset are classified into.
        Specified by:
        getClasses in class ImageClassificationDataset
        Returns:
        the classes that the images in the dataset are classified into