public class OnnxModel extends Object implements ImageInferenceModel<ai.onnxruntime.OnnxTensor>
Note that a temporary directory is created by the ONNX Runtime, something ala C:\Users\owen\AppData\Local\Temp\onnxruntime-java3819764023069624084
with the final number
changing. This should be deleted after the Java VM closes, but this doesn't seem to always
happen. This requires further investigation, but can cause up a large buildup of files, as each
instance is approximately 300MBs.
Constructor and Description |
---|
OnnxModel(ai.onnxruntime.OrtSession session) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Indicates that the model will no longer be used, and does appropriate tidying up and freeing
of resources.
|
<S> S |
performInference(ai.onnxruntime.OnnxTensor input,
String inputName,
List<String> outputNames,
CheckedFunction<List<ai.onnxruntime.OnnxTensor>,S,OperationFailedException> convertFunction)
Performs inference on a single-input, to create an output.
|
public <S> S performInference(ai.onnxruntime.OnnxTensor input, String inputName, List<String> outputNames, CheckedFunction<List<ai.onnxruntime.OnnxTensor>,S,OperationFailedException> convertFunction) throws OperationFailedException
ImageInferenceModel
performInference
in interface ImageInferenceModel<ai.onnxruntime.OnnxTensor>
S
- the data-type the output is exposed as.input
- the input for inference.inputName
- the name associated with input
in the model.convertFunction
- converts the output to type <S>
.OperationFailedException
- if the inference cannot successfully complete.public void close() throws OperationFailedException
InferenceModel
close
in interface AutoCloseable
close
in interface InferenceModel
OperationFailedException
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.