Class OnnxDetectionPredictorProperties

java.lang.Object
com.itextpdf.pdfocr.onnx.AbstractOnnxPredictorProperties
com.itextpdf.pdfocr.onnx.detection.OnnxDetectionPredictorProperties

public class OnnxDetectionPredictorProperties extends AbstractOnnxPredictorProperties
Properties for configuring text detection ONNX models.

It contains a path to the model, model input properties and a model output post-processor.

  • Constructor Details

    • OnnxDetectionPredictorProperties

      public OnnxDetectionPredictorProperties (String modelPath, OnnxInputProperties inputProperties, IDetectionPostProcessor postProcessor)
      Creates new text detection predictor properties.
      Parameters:
      modelPath - path to the ONNX model to load
      inputProperties - ONNX model input properties
      postProcessor - ONNX model output post-processor
    • OnnxDetectionPredictorProperties

      public OnnxDetectionPredictorProperties (String modelPath, OnnxInputProperties inputProperties, IDetectionPostProcessor postProcessor, IOrtSessionOptionsCreator ortSessionOptionsCreator)
      Creates new text detection predictor properties.
      Parameters:
      modelPath - path to the ONNX model to load
      inputProperties - ONNX model input properties
      postProcessor - ONNX model output post-processor
      ortSessionOptionsCreator - ONNX runtime session options creator
  • Method Details

    • dbNet

      public static OnnxDetectionPredictorProperties dbNet (String modelPath)
      Creates a new text detection properties object for existing pre-trained DBNet models, stored on disk.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      Returns:
      a new text detection properties object for a DBNet model
    • dbNet

      public static OnnxDetectionPredictorProperties dbNet (String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator)
      Creates a new text detection properties object for existing pre-trained DBNet models, stored on disk.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for a DBNet model
    • fast

      public static OnnxDetectionPredictorProperties fast (String modelPath)
      Creates a new text detection properties object for existing pre-trained FAST models, stored on disk. This is the default text detection model in OnnxTR.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      Returns:
      a new text detection properties object for a FAST model
    • fast

      public static OnnxDetectionPredictorProperties fast (String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator)
      Creates a new text detection properties object for existing pre-trained FAST models, stored on disk. This is the default text detection model in OnnxTR.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for a FAST model
    • linkNet

      public static OnnxDetectionPredictorProperties linkNet (String modelPath)
      Creates a new text detection properties object for existing pre-trained LinkNet models, stored on disk.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      Returns:
      a new text detection properties object for a LinkNet model
    • linkNet

      public static OnnxDetectionPredictorProperties linkNet (String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator)
      Creates a new text detection properties object for existing pre-trained LinkNet models, stored on disk.

      This can be used to load the following models from OnnxTR:

      These models output boxes of words.

      Parameters:
      modelPath - path to the pre-trained model
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for a LinkNet model
    • paddleOcr

      public static OnnxDetectionPredictorProperties paddleOcr (String modelDirPath) throws IOException
      Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.

      Only models in the ONNX format are supported. Since, by default, PaddleOCR does not provide models in the ONNX format, you might need to do a model conversion yourself. Check out this page for information on how to do that.

      This method expects the directory to contain two files:

      • inference.onnx - the inference model in the ONNX format
      • inference.yml - the configuration file for the model in YAML

      This method can be used to load the following PaddleOCR models:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelDirPath - path to the directory with the model and its configuration file
      Returns:
      a new text detection properties object for a PaddleOCR model
      Throws:
      IOException - if any I/O error occurs while loading configuration file
    • paddleOcr

      public static OnnxDetectionPredictorProperties paddleOcr (String modelDirPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) throws IOException
      Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.

      Only models in the ONNX format are supported. Since, by default, PaddleOCR does not provide models in the ONNX format, you might need to do a model conversion yourself. Check out this page for information on how to do that.

      This method expects the directory to contain two files:

      • inference.onnx - the inference model in the ONNX format
      • inference.yml - the configuration file for the model in YAML

      This method can be used to load the following PaddleOCR models:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelDirPath - path to the directory with the model and its configuration file
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for a PaddleOCR model
      Throws:
      IOException - if any I/O error occurs while loading configuration file
    • paddleOcr

      public static OnnxDetectionPredictorProperties paddleOcr (String modelPath, String configPath) throws IOException
      Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.

      Only models in the ONNX format are supported. Since, by default, PaddleOCR does not provide models in the ONNX format, you might need to do a model conversion yourself. Check out this page for information on how to do that.

      This method can be used to load the following PaddleOCR models:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelPath - path to the pre-trained model in the ONNX format
      configPath - path to the configuration file for the model
      Returns:
      a new text detection properties object for a PaddleOCR model
      Throws:
      IOException - if any I/O error occurs while loading configuration file
    • paddleOcr

      public static OnnxDetectionPredictorProperties paddleOcr (String modelPath, String configPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) throws IOException
      Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.

      Only models in the ONNX format are supported. Since, by default, PaddleOCR does not provide models in the ONNX format, you might need to do a model conversion yourself. Check out this page for information on how to do that.

      This method can be used to load the following PaddleOCR models:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelPath - path to the pre-trained model in the ONNX format
      configPath - path to the configuration file for the model
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for a PaddleOCR model
      Throws:
      IOException - if any I/O error occurs while loading configuration file
    • easyOcr

      public static OnnxDetectionPredictorProperties easyOcr (String modelPath)
      Creates a new text detection properties object for an existing pre-trained EasyOCR CRAFT model, stored on disk.

      Only models in the ONNX format are supported. Since, by default, EasyOCR does not provide models in the ONNX format, you might need to do a model conversion yourself.

      This can be used to load the following models from EasyOCR:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelPath - path to the pre-trained model
      Returns:
      a new text detection properties object for an EasyOCR CRAFT model
    • easyOcr

      public static OnnxDetectionPredictorProperties easyOcr (String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator)
      Creates a new text detection properties object for an existing pre-trained EasyOCR CRAFT model, stored on disk.

      Only models in the ONNX format are supported. Since, by default, EasyOCR does not provide models in the ONNX format, you might need to do a model conversion yourself.

      This can be used to load the following models from EasyOCR:

      These models output boxes of text lines. Make sure you choose a recognition model that can handle spaces.

      Parameters:
      modelPath - path to the pre-trained model
      ortSessionOptionsCreator - the ONNX runtime session options creator
      Returns:
      a new text detection properties object for an EasyOCR CRAFT model
    • getPostProcessor

      public IDetectionPostProcessor getPostProcessor()
      Returns the ONNX model output post-processor.
      Returns:
      the ONNX model output post-processor
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object