Class OnnxDetectionPredictor
java.lang.Object
com.itextpdf.pdfocr.onnxtr.AbstractOnnxPredictor<BufferedImage,
List>
com.itextpdf.pdfocr.onnxtr.detection.OnnxDetectionPredictor
- All Implemented Interfaces:
-
IDetectionPredictor
,IPredictor<BufferedImage,
,List > AutoCloseable
public class OnnxDetectionPredictor extends AbstractOnnxPredictor<BufferedImage,List> implements IDetectionPredictor
A text detection predictor implementation, which is using ONNX Runtime and its ML models to find, where text is located on an image.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a text detection predictor with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionstatic OnnxDetectionPredictor
Creates a new text detection predictor using an existing pre-trained DBNet model, stored on disk.static OnnxDetectionPredictor
Creates a new text detection predictor using an existing pre-trained FAST model, stored on disk.fromOutputBuffer
(List<BufferedImage> inputBatch, FloatBufferMdArray outputBatch) Converts ONNX runtime model batched output MD-array buffer to a list of predictor outputs.Returns the text detection predictor properties.static OnnxDetectionPredictor
Creates a new text detection predictor using an existing pre-trained LinkNet model, stored on disk.protected FloatBufferMdArray
toInputBuffer
(List<BufferedImage> batch) Converts predictor inputs to an ONNX runtime model batched input MD-array buffer.Methods inherited from class com.itextpdf.pdfocr.onnxtr.AbstractOnnxPredictor
close, predict
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
Methods inherited from interface com.itextpdf.pdfocr.onnxtr.IPredictor
predict, predict
-
Constructor Details
-
OnnxDetectionPredictor
Creates a text detection predictor with the specified properties.- Parameters:
-
properties
- properties of the predictor
-
-
Method Details
-
dbNet
Creates a new text detection predictor using an existing pre-trained DBNet model, stored on disk.This can be used to load the following models from OnnxTR:
- Parameters:
-
modelPath
- path to the pre-trained model - Returns:
- a new predictor with the DBNet model loaded
-
fast
Creates a new text detection predictor using an existing pre-trained FAST model, stored on disk. This is the default text detection model in OnnxTR.This can be used to load the following models from OnnxTR:
- Parameters:
-
modelPath
- path to the pre-trained model - Returns:
- a new predictor with the FAST model loaded
-
linkNet
Creates a new text detection predictor using an existing pre-trained LinkNet model, stored on disk.This can be used to load the following models from OnnxTR:
- Parameters:
-
modelPath
- path to the pre-trained model - Returns:
- a new predictor with the LinkNet model loaded
-
getProperties
Returns the text detection predictor properties.- Returns:
- the text detection predictor properties
-
toInputBuffer
Converts predictor inputs to an ONNX runtime model batched input MD-array buffer.- Specified by:
-
toInputBuffer
in classAbstractOnnxPredictor<BufferedImage,
List > - Parameters:
-
batch
- batch of raw predictor inputs - Returns:
- batched model input MD-array buffer
-
fromOutputBuffer
protected List<List> fromOutputBuffer(List<BufferedImage> inputBatch, FloatBufferMdArray outputBatch) Converts ONNX runtime model batched output MD-array buffer to a list of predictor outputs.- Specified by:
-
fromOutputBuffer
in classAbstractOnnxPredictor<BufferedImage,
List > - Parameters:
-
inputBatch
- list of raw predictor inputs, matching the output -
outputBatch
- batched model output MD-array buffer - Returns:
- a list of predictor output
-