Class OnnxDetectionPredictorProperties
It contains a path to the model, model input properties and a model output post-processor.
-
Field Summary
Fields inherited from class com.itextpdf.pdfocr.onnx.AbstractOnnxPredictorProperties
DEFAULT_ORT_SESSION_CREATOR, inputProperties, modelPath, ortSessionOptionsCreator -
Constructor Summary
ConstructorsConstructorDescriptionOnnxDetectionPredictorProperties(String modelPath, OnnxInputProperties inputProperties, IDetectionPostProcessor postProcessor) Creates new text detection predictor properties.OnnxDetectionPredictorProperties(String modelPath, OnnxInputProperties inputProperties, IDetectionPostProcessor postProcessor, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates new text detection predictor properties. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new text detection properties object for existing pre-trained DBNet models, stored on disk.dbNet(String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for existing pre-trained DBNet models, stored on disk.Creates a new text detection properties object for an existing pre-trained EasyOCR CRAFT model, stored on disk.easyOcr(String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for an existing pre-trained EasyOCR CRAFT model, stored on disk.booleanCreates a new text detection properties object for existing pre-trained FAST models, stored on disk.fast(String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for existing pre-trained FAST models, stored on disk.Returns the ONNX model output post-processor.inthashCode()Creates a new text detection properties object for existing pre-trained LinkNet models, stored on disk.linkNet(String modelPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for existing pre-trained LinkNet models, stored on disk.Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.paddleOcr(String modelDirPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.paddleOcr(String modelPath, String configPath, IOrtSessionOptionsCreator ortSessionOptionsCreator) Creates a new text detection properties object for existing pre-trained PaddleOCR models, stored on disk.toString()Methods inherited from class com.itextpdf.pdfocr.onnx.AbstractOnnxPredictorProperties
getInputProperties, getModelPath, getOrtSessionOptionsCreator
-
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
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:
- db_resnet50
- db_resnet50 (8-bit quantized)
- db_resnet34
- db_resnet34 (8-bit quantized)
- db_mobilenet_v3_large
- db_mobilenet_v3_large (8-bit quantized)
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:
- db_resnet50
- db_resnet50 (8-bit quantized)
- db_resnet34
- db_resnet34 (8-bit quantized)
- db_mobilenet_v3_large
- db_mobilenet_v3_large (8-bit quantized)
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
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
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:
- linknet_resnet50
- linknet_resnet50 (8-bit quantized)
- linknet_resnet34
- linknet_resnet34 (8-bit quantized)
- linknet_resnet18
- linknet_resnet18 (8-bit quantized)
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:
- linknet_resnet50
- linknet_resnet50 (8-bit quantized)
- linknet_resnet34
- linknet_resnet34 (8-bit quantized)
- linknet_resnet18
- linknet_resnet18 (8-bit quantized)
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
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 formatinference.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 formatinference.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
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
Returns the ONNX model output post-processor.- Returns:
- the ONNX model output post-processor
-
equals
-
hashCode
public int hashCode() -
toString
-