Class CrnnPostProcessor

java.lang.Object
com.itextpdf.pdfocr.onnx.recognition.BasicLabelPostProcessor
com.itextpdf.pdfocr.onnx.recognition.CrnnPostProcessor
All Implemented Interfaces:
IRecognitionPostProcessor

public class CrnnPostProcessor extends BasicLabelPostProcessor
Implementation of a text recognition predictor post-processor, used for OnnxTR CRNN model outputs.

Notably it does not have end-of-string tokens. Only token, besides the vocabulary one, is blank, which is just skipped or used as a char separator. Multiple of the same label in a row is aggregated into one.

  • Constructor Details

    • CrnnPostProcessor

      public CrnnPostProcessor (Vocabulary vocabulary)
      Creates a new post-processor.
      Parameters:
      vocabulary - vocabulary used for the model output (without special tokens)
    • CrnnPostProcessor

      public CrnnPostProcessor()
      Creates a new post-processor with the default vocabulary.
  • Method Details

    • appendLabel

      protected void appendLabel (StringBuilder output, int labelIndex)
      Adds label to the string output, based on the label's index. Can be a noop, if label index should be ignored.
      Specified by:
      appendLabel in class BasicLabelPostProcessor
      Parameters:
      output - string builder to append the label to
      labelIndex - index of the label to append, guaranteed to be in the [0; labelDimension()) range.
    • labelDimension

      public int labelDimension()
      Returns the size of the output character label vector. I.e. how many distinct tokens/characters the model recognizes.
      Returns:
      the size of the output character label vector