Package deepnetts.data
Class ImageSet
java.lang.Object
javax.visrec.ml.data.BasicDataSet<ExampleImage>
- All Implemented Interfaces:
Iterable<ExampleImage>
,javax.visrec.ml.data.DataSet<ExampleImage>
Data set with images that will be used to train convolutional neural network.
- Author:
- Zoran Sevarac
-
Nested Class Summary
Nested classes/interfaces inherited from class deepnetts.data.TabularDataSet
TabularDataSet.Item
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavax.visrec.ml.data.DataSet
<ExampleImage> add
(ExampleImage exImage) Adds an example image that will be used to train deep learning model to this set.boolean
boolean
boolean
boolean
int
int
boolean
int
getMean()
boolean
Returns flag that indicates wheather images should be scaled to specified dimensions while creating image set.String[]
Returns output/image labels.boolean
boolean
void
loadImages
(File imageIdxFile) Loads example images with corresponding labels from the specified file.void
loadImages
(File imageIdxFile, int numOfImages) Loads specified number of example images with corresponding labels from the specified file.void
loadImages
(String imageIdxFile) Loads images from the specified image index file.String[]
loadLabels
(File file) Loads and returns image labels to train neural network from the specified file.These labels will be used to label network's outputs.String[]
loadLabels
(String filePath) Loads and returns image labels to train neural network from the specified file.void
setBrightness
(boolean brightness) void
setCropCornersAndCenter
(boolean cropCornersAndCenter) void
setDelimiter
(String delimiter) void
setFlipHorizontal
(boolean flipHorizontal) void
setGrayscale
(boolean grayscale) setInvertImages
(boolean invertImages) setResizeStrategy
(ImageResize resizeStrategy) final void
setScaleImages
(boolean scaleImages) void
setTranslate
(boolean translate) ImageSet[]
split
(double... partSizes) Splits data set into several parts specified by the input parameter partSizes.zeroMean()
Applies zero mean normalization to entire dataset, and returns mean tensor.Methods inherited from class deepnetts.data.TabularDataSet
countMissingValues, countMissingValues, getColumnNames, getNumInputs, getNumOutputs, hasMissingValues, hasMissingValues, setColumnNames, shuffle, shuffle, split, trainTestSplit
Methods inherited from class javax.visrec.ml.data.BasicDataSet
getColumns, getItems, setAsTargetColumns, setAsTargetColumns, setColumns
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.visrec.ml.data.DataSet
addAll, clear, get, isEmpty, iterator, shuffle, size, split, split, split, stream
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ImageSet
public ImageSet(int imageWidth, int imageHeight) Creates empty image set for images of specified size.- Parameters:
imageWidth
-imageHeight
-
-
ImageSet
Creates image set with images from specified directory path.- Parameters:
imageWidth
- all images in set will be scaled to this widthimageHeight
- all images in set will be scaled to this heightimageDirPath
- 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
Loads images from the specified image index file.- Parameters:
imageIdxFile
- txt file with list of images- Throws:
FileNotFoundException
-
loadImages
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
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 labelnumOfImages
- number of images to load- Throws:
DeepNettsException
-
getLabelsCount
public int getLabelsCount() -
split
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 interfacejavax.visrec.ml.data.DataSet<ExampleImage>
- Overrides:
split
in classTabularDataSet<ExampleImage>
- Parameters:
partSizes
- sizes of the parts in percents- Returns:
- parts of the data set of specified size
-
loadLabels
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
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
Applies zero mean normalization to entire dataset, and returns mean tensor.- Returns:
- mean Tensor for the entire dataset
-
zeroMeanPerChannel
-
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
-
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
Returns output/image labels.- Specified by:
getTargetColumnsNames
in interfacejavax.visrec.ml.data.DataSet<ExampleImage>
- Overrides:
getTargetColumnsNames
in classTabularDataSet<ExampleImage>
- Returns:
-
countByClasses
-
getDelimiter
-
setDelimiter
-
getResizeStrategy
-
setResizeStrategy
-
getImageWidth
public int getImageWidth() -
getImageHeight
public int getImageHeight() -
getMean
-
getZeroMeanPixels
public boolean getZeroMeanPixels()
-