Class OnnxOrientationPredictor
java.lang.Object
com.itextpdf.pdfocr.onnxtr.AbstractOnnxPredictor<BufferedImage,
TextOrientation>
com.itextpdf.pdfocr.onnxtr.orientation.OnnxOrientationPredictor
- All Implemented Interfaces:
-
IPredictor<BufferedImage,,TextOrientation> IOrientationPredictor,AutoCloseable
public class OnnxOrientationPredictor extends AbstractOnnxPredictor<BufferedImage,TextOrientation> implements IOrientationPredictor
A crop orientation predictor implementation, which is using ONNX Runtime and its ML models to figure out, how text is oriented in a cropped image of text.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a crop orientation predictor with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected List<TextOrientation>fromOutputBuffer(List<BufferedImage> inputBatch, FloatBufferMdArray outputBatch) Converts ONNX runtime model batched output MD-array buffer to a list of predictor outputs.Returns the crop orientation predictor properties.static OnnxOrientationPredictormobileNetV3(String modelPath) Creates a new crop orientation predictor using an existing pre-trained MobileNetV3 model, stored on disk.protected FloatBufferMdArraytoInputBuffer(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, predictMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface com.itextpdf.pdfocr.onnxtr.IPredictor
predict, predict
-
Constructor Details
-
OnnxOrientationPredictor
Creates a crop orientation predictor with the specified properties.- Parameters:
-
properties- properties of the predictor
-
-
Method Details
-
mobileNetV3
Creates a new crop orientation predictor using an existing pre-trained MobileNetV3 model, stored on disk. This is the only crop orientation model architecture available 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 MobileNetV3 model loaded
-
getProperties
Returns the crop orientation predictor properties.- Returns:
- the crop orientation predictor properties
-
toInputBuffer
Converts predictor inputs to an ONNX runtime model batched input MD-array buffer.- Specified by:
-
toInputBufferin classAbstractOnnxPredictor<BufferedImage,TextOrientation> - Parameters:
-
batch- batch of raw predictor inputs - Returns:
- batched model input MD-array buffer
-
fromOutputBuffer
protected List<TextOrientation> fromOutputBuffer(List<BufferedImage> inputBatch, FloatBufferMdArray outputBatch) Converts ONNX runtime model batched output MD-array buffer to a list of predictor outputs.- Specified by:
-
fromOutputBufferin classAbstractOnnxPredictor<BufferedImage,TextOrientation> - Parameters:
-
inputBatch- list of raw predictor inputs, matching the output -
outputBatch- batched model output MD-array buffer - Returns:
- a list of predictor output
-