Package com.itextpdf.pdfocr.onnx
Class OnnxInputProperties
java.lang.Object
com.itextpdf.pdfocr.onnx.OnnxInputProperties
Properties of the input of an ONNX model, which expects an image.
It contains the input shape (batchSize, channel, height, width), mean and standard deviation values for normalization, what type of padding should be used.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOnnxInputProperties(ImageResizeOptions imageResizeOptions) Creates model input properties.OnnxInputProperties(ImageResizeOptions imageResizeOptions, float[] mean, float[] std) Creates model input properties.OnnxInputProperties(ImageResizeOptions imageResizeOptions, float[] mean, float[] std, int batchSize) Creates model input properties.OnnxInputProperties(ImageResizeOptions imageResizeOptions, int batchSize) Creates model input properties. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns input batch size.floatReturns blue channel mean, used for normalization.floatReturns blue channel standard deviation, used for normalization.intReturns input channel count.floatReturns gray channel mean, used for normalization.floatReturns gray channel standard deviation, used for normalization.floatReturns green channel mean, used for normalization.floatReturns green channel standard deviation, used for normalization.intReturns input minimum height.Returns image resize options for the input.float[]getMean()Returns per-channel mean, used for normalization.floatgetMean(int index) Returns channel-specific mean, used for normalization.Returns the padding strategy for image inputs.floatReturns red channel mean, used for normalization.floatReturns red channel standard deviation, used for normalization.long[]getShape()Returns target input shape.intgetShape(int index) Returns target input dimension value.float[]getStd()Returns per-channel standard deviation, used for normalization.floatgetStd(int index) Returns channel-specific standard deviation, used for normalization.intgetWidth()Returns input minimum width.inthashCode()toString()booleanReturns whether padding should be symmetrical during input resizing.
-
Field Details
-
EXPECTED_SHAPE_SIZE
public static final int EXPECTED_SHAPE_SIZEExpected shape size. We expect the standard BCHW format (batch, channel, height, width).- See Also:
-
-
Constructor Details
-
OnnxInputProperties
public OnnxInputProperties(ImageResizeOptions imageResizeOptions, float[] mean, float[] std, int batchSize) Creates model input properties.- Parameters:
-
imageResizeOptions- options, that control the way the input images for the models will be converted, resized and padded for ML model input -
mean- per-channel mean, used for normalization. Length of the array should match the channel count in the image resize options -
std- per-channel standard deviation, used for normalization. Length of the array should match the channel count in the image resize options -
batchSize- size of the batch used for the ML model. Should be a positive number
-
OnnxInputProperties
Creates model input properties.With this constructor variant batching is disabled (i.e. batch size is set to 1).
- Parameters:
-
imageResizeOptions- options, that control the way the input images for the models will be converted, resized and padded for ML model input -
mean- per-channel mean, used for normalization. Length of the array should match the channel count in the image resize options -
std- per-channel standard deviation, used for normalization. Length of the array should match the channel count in the image resize options
-
OnnxInputProperties
Creates model input properties.With this constructor variant no input normalization is done, only mapping to [0; 1].
- Parameters:
-
imageResizeOptions- options, that control the way the input images for the models will be converted, resized and padded for ML model input -
batchSize- size of the batch used for the ML model. Should be a positive number
-
OnnxInputProperties
Creates model input properties.With this constructor variant no input normalization is done, only mapping to [0; 1], and batching is disabled (i.e. batch size is set to 1).
- Parameters:
-
imageResizeOptions- options, that control the way the input images for the models will be converted, resized and padded for ML model input
-
-
Method Details
-
getImageResizeOptions
Returns image resize options for the input.- Returns:
- image resize options for the input.
-
getMean
public float[] getMean()Returns per-channel mean, used for normalization.- Returns:
- per-channel mean, used for normalization
-
getMean
public float getMean(int index) Returns channel-specific mean, used for normalization.- Parameters:
-
index- index of the channel - Returns:
- channel-specific mean, used for normalization
-
getGrayMean
public float getGrayMean()Returns gray channel mean, used for normalization.- Returns:
- gray channel mean, used for normalization
-
getRedMean
public float getRedMean()Returns red channel mean, used for normalization.- Returns:
- red channel mean, used for normalization
-
getGreenMean
public float getGreenMean()Returns green channel mean, used for normalization.- Returns:
- green channel mean, used for normalization
-
getBlueMean
public float getBlueMean()Returns blue channel mean, used for normalization.- Returns:
- blue channel mean, used for normalization
-
getStd
public float[] getStd()Returns per-channel standard deviation, used for normalization.- Returns:
- per-channel standard deviation, used for normalization
-
getStd
public float getStd(int index) Returns channel-specific standard deviation, used for normalization.- Parameters:
-
index- index of the channel - Returns:
- channel-specific standard deviation, used for normalization
-
getGrayStd
public float getGrayStd()Returns gray channel standard deviation, used for normalization.- Returns:
- gray channel standard deviation, used for normalization
-
getRedStd
public float getRedStd()Returns red channel standard deviation, used for normalization.- Returns:
- red channel standard deviation, used for normalization
-
getGreenStd
public float getGreenStd()Returns green channel standard deviation, used for normalization.- Returns:
- green channel standard deviation, used for normalization
-
getBlueStd
public float getBlueStd()Returns blue channel standard deviation, used for normalization.- Returns:
- blue channel standard deviation, used for normalization
-
getShape
public long[] getShape()Returns target input shape. Minimum height and width are used.- Returns:
- target input shape
-
getShape
public int getShape(int index) Returns target input dimension value.- Parameters:
-
index- index of the dimension - Returns:
- target input dimension value
-
getBatchSize
public int getBatchSize()Returns input batch size.- Returns:
- input batch size
-
getChannelCount
public int getChannelCount()Returns input channel count.- Returns:
- input channel count
-
getHeight
public int getHeight()Returns input minimum height.- Returns:
- input minimum height
-
getWidth
public int getWidth()Returns input minimum width.- Returns:
- input minimum width
-
useSymmetricPad
public boolean useSymmetricPad()Returns whether padding should be symmetrical during input resizing.- Returns:
- whether padding should be symmetrical during input resizing
-
getPaddingStrategy
Returns the padding strategy for image inputs.- Returns:
- the padding strategy for image inputs
-
hashCode
public int hashCode() -
equals
-
toString
-