Class OnnxInputProperties

java.lang.Object
com.itextpdf.pdfocr.onnx.OnnxInputProperties

public class OnnxInputProperties extends Object
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 Details

    • EXPECTED_SHAPE_SIZE

      public static final int EXPECTED_SHAPE_SIZE
      Expected 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

      public OnnxInputProperties (ImageResizeOptions imageResizeOptions, float[] mean, float[] std)
      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

      public OnnxInputProperties (ImageResizeOptions imageResizeOptions, int batchSize)
      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

      public OnnxInputProperties (ImageResizeOptions imageResizeOptions)
      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

      public ImageResizeOptions 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

      public PaddingStrategy getPaddingStrategy()
      Returns the padding strategy for image inputs.
      Returns:
      the padding strategy for image inputs
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals (Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object