Class ImageToNDArrayConfig
- java.lang.Object
-
- ai.konduit.serving.data.image.convert.ImageToNDArrayConfig
-
public class ImageToNDArrayConfig extends java.lang.ObjectConfiguration for convertingImages toNDArrays.The following can be configured:
- height: Output NDArray image height: leave null to convert to the same size as the input. Default: null
- width: Output NDArray image width: leave null to convert to the same size as the input. Default: null
- datatype:
NDArrayType(data type) of the output array - includeMinibatchDim: If true: the output array will be rank 4 with shape [1, c, h, w] or [1, h, w, c]. If false: return rank 3 array with shape [c, h, w] or [h, w, c]. Default: true
- aspectRatioHandling: How should input images with different aspect ratio to the output height/width be handled? Default: CENTER_CROP
- CENTER_CROP: Crop the larger dimension down to the correct aspect ratio (and then resize if necessary).
- PAD: Zero pad the smaller dimension to make the aspect ratio match the output (and then resize if necessary)
- STRETCH: Simply resize the image to the required aspect ratio, distorting the image if necessary
- format: CHANNELS_FIRST (output shape: [1, c, h, w] or [c, h, w]) or CHANNELS_LAST (output shape: [1, h, w, c] or [h, w, c])
- channels: The layout for the returned array. Note input images will be converted if necessary. Default: RGB
- RGB: 3 channels, ordered according to: red, green, blue - most common for TensorFlow, Keras, and some other libraries
- BGR: 3 channels, ordered according to: blue, green, red - the default for OpenCV, JavaCV, DL4J
- RGBA: 4 channels, ordered according to: red, green, blue, alpha
- BGRA: 4 channels, ordered according to: blue, green, red, alpha
- GRAYSCALE: 1 channel - grayscale
- normalization: How the image should be normalized. See
ImageNormalization- support scaling ([0,1] range), subtracting mean (out = (in-mean)), standardization (out = (in-mean)/stdev), inception ([-1, 1] range) and VGG mean subtraction (fixed out = in - meanRgb, where meanRgb is hardcoded to [123.68, 116.779, 103.939]. Default: simple scale normalization ([0, 1] range). Note: If image normalization in null, or ImageNormalization.type == Type.NONE, no normalization is applied. - listHandling: Only applies in situations such as
ImageToNDArrayStep, and only whenList<Image>is passed in instead ofImage. This setting determines what the output should be. NONE: Error forList<Image>input (only single Images are allowed). BATCH: a single output NDArray is returned, with the images batched along dimension 0. LIST_OUT: AList<NDArray>is returned instead of a singleNDArray- one entry for each entry in the inputList<Image>. FIRST: the first bounding box only is returned as as singleNDArray- the remainder are discarded/ignored.
- Author:
- Alex Black
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImageToNDArrayConfig.ListHandlingSeeImageToNDArrayConfig- listHandling field
-
Constructor Summary
Constructors Constructor Description ImageToNDArrayConfig(java.lang.Integer height, java.lang.Integer width, ai.konduit.serving.pipeline.api.data.NDArrayType dataType, boolean includeMinibatchDim, AspectRatioHandling aspectRatioHandling, NDFormat format, NDChannelLayout channelLayout, ImageNormalization normalization, ImageToNDArrayConfig.ListHandling listHandling)
-
-
-
Constructor Detail
-
ImageToNDArrayConfig
public ImageToNDArrayConfig(java.lang.Integer height, java.lang.Integer width, ai.konduit.serving.pipeline.api.data.NDArrayType dataType, boolean includeMinibatchDim, AspectRatioHandling aspectRatioHandling, NDFormat format, NDChannelLayout channelLayout, ImageNormalization normalization, ImageToNDArrayConfig.ListHandling listHandling)
-
-