Class ImageSet

java.lang.Object
javax.visrec.ml.data.BasicDataSet<ExampleImage>
All Implemented Interfaces:
Iterable<ExampleImage>, javax.visrec.ml.data.DataSet<ExampleImage>

public class ImageSet extends TabularDataSet<ExampleImage>
Data set with images that will be used to train convolutional neural network.
  • Constructor Details

    • ImageSet

      public ImageSet(int imageWidth, int imageHeight)
      Creates empty image set for images of specified size.
      Parameters:
      imageWidth -
      imageHeight -
    • ImageSet

      public ImageSet(int imageWidth, int imageHeight, String imageDirPath) throws IOException
      Creates image set with images from specified directory path.
      Parameters:
      imageWidth - all images in set will be scaled to this width
      imageHeight - all images in set will be scaled to this height
      imageDirPath - path to the root directory which contains subdirectories with images
      Throws:
      IOException
  • Method Details

    • add

      public javax.visrec.ml.data.DataSet<ExampleImage> add(ExampleImage exImage) throws DeepNettsException
      Adds an example image that will be used to train deep learning model to this set.
      Parameters:
      exImage - holds raw image pixel data and corresponding image label
      Returns:
      this instance of ImageSet
      Throws:
      DeepNettsException - if image is empty or has wrong dimensions.
    • loadImages

      public void loadImages(String imageIdxFile) throws FileNotFoundException
      Loads images from the specified image index file.
      Parameters:
      imageIdxFile - txt file with list of images
      Throws:
      FileNotFoundException
    • loadImages

      public void loadImages(File imageIdxFile) throws FileNotFoundException
      Loads example images with corresponding labels from the specified file.
      Parameters:
      imageIdxFile - Plain text file that contains space delimited image paths and labels
      Throws:
      FileNotFoundException - if imageIdxFile was not found
    • loadImages

      public void loadImages(File imageIdxFile, int numOfImages) throws DeepNettsException
      Loads specified number of example images with corresponding labels from the specified file.
      Parameters:
      imageIdxFile - Plain text file which contains space delimited image file paths and label
      numOfImages - number of images to load
      Throws:
      DeepNettsException
    • getLabelsCount

      public int getLabelsCount()
    • split

      public ImageSet[] split(double... partSizes)
      Splits data set into several parts specified by the input parameter partSizes. Values of partSizes parameter represent the sizes of data set parts that will be returned. Part sizes are integer values that represent percents, cannot be negative or zero, and their sum must be 100
      Specified by:
      split in interface javax.visrec.ml.data.DataSet<ExampleImage>
      Overrides:
      split in class TabularDataSet<ExampleImage>
      Parameters:
      partSizes - sizes of the parts in percents
      Returns:
      parts of the data set of specified size
    • loadLabels

      public String[] loadLabels(String filePath) throws DeepNettsException
      Loads and returns image labels to train neural network from the specified file. These labels will be used to label network's outputs.
      Parameters:
      filePath -
      Returns:
      Throws:
      DeepNettsException
    • loadLabels

      public String[] loadLabels(File file) throws DeepNettsException
      Loads and returns image labels to train neural network from the specified file.These labels will be used to label network's outputs.
      Parameters:
      file - file to load labels from
      Returns:
      Throws:
      DeepNettsException
    • zeroMean

      public TensorBase zeroMean()
      Applies zero mean normalization to entire dataset, and returns mean tensor.
      Returns:
      mean Tensor for the entire dataset
    • zeroMeanPerChannel

      public TensorBase zeroMeanPerChannel()
    • zeroMeanAndNormalize

      public TensorBase zeroMeanAndNormalize()
    • getScaleImages

      public boolean getScaleImages()
      Returns flag that indicates wheather images should be scaled to specified dimensions while creating image set.
      Returns:
    • setScaleImages

      public final void setScaleImages(boolean scaleImages)
    • getInvertImages

      public boolean getInvertImages()
    • setInvertImages

      public ImageSet setInvertImages(boolean invertImages)
    • getFlipHorizontal

      public boolean getFlipHorizontal()
    • getBrightness

      public boolean getBrightness()
    • getGrayscale

      public boolean getGrayscale()
    • setFlipHorizontal

      public void setFlipHorizontal(boolean flipHorizontal)
    • setBrightness

      public void setBrightness(boolean brightness)
    • setGrayscale

      public void setGrayscale(boolean grayscale)
    • getTranslate

      public boolean getTranslate()
    • setTranslate

      public void setTranslate(boolean translate)
    • getCropCornersAndCenter

      public boolean getCropCornersAndCenter()
    • setCropCornersAndCenter

      public void setCropCornersAndCenter(boolean cropCornersAndCenter)
    • getTargetColumnsNames

      public String[] getTargetColumnsNames()
      Returns output/image labels.
      Specified by:
      getTargetColumnsNames in interface javax.visrec.ml.data.DataSet<ExampleImage>
      Overrides:
      getTargetColumnsNames in class TabularDataSet<ExampleImage>
      Returns:
    • countByClasses

      public Map<String,Integer> countByClasses()
    • getDelimiter

      public String getDelimiter()
    • setDelimiter

      public void setDelimiter(String delimiter)
    • getResizeStrategy

      public ImageResize getResizeStrategy()
    • setResizeStrategy

      public ImageSet setResizeStrategy(ImageResize resizeStrategy)
    • getImageWidth

      public int getImageWidth()
    • getImageHeight

      public int getImageHeight()
    • getMean

      public TensorBase getMean()
    • getZeroMeanPixels

      public boolean getZeroMeanPixels()