Class OnnxInputProperties

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

public class OnnxInputProperties extends Object
Properties of the input of an ONNX model, which expects an RGB image.

It contains the input shape, as a [batchSize, channel, height, width] array, mean and standard deviation values for normalization, whether padding should be symmetrical or not.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Expected channel count.
    static final int
    Expected shape size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OnnxInputProperties(float[] mean, float[] std, long[] shape, boolean symmetricPad)
    Creates model input properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    int
    Returns input batch size.
    float
    Returns blue channel mean, used for normalization.
    float
    Returns blue channel standard deviation, used for normalization.
    int
    Returns input channel count.
    float
    Returns green channel mean, used for normalization.
    float
    Returns green channel standard deviation, used for normalization.
    int
    Returns input height.
    float[]
    Returns per-channel mean, used for normalization.
    float
    getMean(int index)
    Returns channel-specific mean, used for normalization.
    float
    Returns red channel mean, used for normalization.
    float
    Returns red channel standard deviation, used for normalization.
    long[]
    Returns target input shape.
    int
    getShape(int index)
    Returns target input dimension value.
    float[]
    getStd()
    Returns per-channel standard deviation, used for normalization.
    float
    getStd(int index)
    Returns channel-specific standard deviation, used for normalization.
    int
    Returns input width.
    int
    boolean
    Returns whether padding should be symmetrical during input resizing.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EXPECTED_CHANNEL_COUNT

      public static final int EXPECTED_CHANNEL_COUNT
      Expected channel count. We expect RGB format.
      See Also:
    • EXPECTED_SHAPE_SIZE

      public static final int EXPECTED_SHAPE_SIZE
      Expected shape size. We inspect the standard BCHW format (batch, channel, height, width).
      See Also:
  • Constructor Details

    • OnnxInputProperties

      public OnnxInputProperties (float[] mean, float[] std, long[] shape, boolean symmetricPad)
      Creates model input properties.
      Parameters:
      mean - per-channel mean, used for normalization. Should be EXPECTED_SHAPE_SIZE length
      std - per-channel standard deviation, used for normalization. Should be EXPECTED_SHAPE_SIZE length
      shape - target input shape. Should be EXPECTED_SHAPE_SIZE length
      symmetricPad - whether padding should be symmetrical during input resizing
  • Method Details

    • 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
    • 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
    • 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.
      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 height.
      Returns:
      input height
    • getWidth

      public int getWidth()
      Returns input width.
      Returns:
      input width
    • useSymmetricPad

      public boolean useSymmetricPad()
      Returns whether padding should be symmetrical during input resizing.
      Returns:
      whether padding should be symmetrical during input resizing
    • 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