OnnxInferenceModel

open class OnnxInferenceModel : ExecutionProviderCompatible

Inference model built on ONNX format.

Since

0.3

Constructors

OnnxInferenceModel
Link copied to clipboard
common
fun OnnxInferenceModel(modelPath: String)

Constructs an ONNX inference model from the given model file.

OnnxInferenceModel
Link copied to clipboard
common
fun OnnxInferenceModel(modelBytes: ByteArray)

Constructs an ONNX inference model from the byte array representing an ONNX model.

OnnxInferenceModel
Link copied to clipboard
common
fun OnnxInferenceModel(loadBytes: () -> ByteArray)

Constructs an ONNX inference model from the function which returns a byte array representing an ONNX model.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

close
Link copied to clipboard
common
open fun close()

Releases the ONNXRuntime - related resources.

copy
Link copied to clipboard
common
open fun copy(copiedModelName: String?, saveOptimizerState: Boolean, copyWeights: Boolean): OnnxInferenceModel
initializeWith
Link copied to clipboard
common
open override fun initializeWith(vararg executionProviders: ExecutionProvider)

Initializes the model, if it's not initialized, or re-initializes it, depending on the execution providers.

predict
Link copied to clipboard
common
open fun predict(inputData: FloatArray): Int
predictRaw
Link copied to clipboard
common
fun predictRaw(inputData: FloatArray): Map<String, Any>

Returns list of multidimensional arrays with data from model outputs.

fun <R> predictRaw(inputData: FloatArray, extractResult: (<ERROR CLASS>) -> R): R

Runs prediction on a given inputData and calls extractResult function to process output.

predictSoftly
Link copied to clipboard
common
fun predictSoftly(inputData: FloatArray): FloatArray

Predicts vector of probabilities instead of specific class in predict method.

open fun predictSoftly(inputData: FloatArray, predictionTensorName: String): FloatArray
reshape
Link copied to clipboard
common
open fun reshape(vararg dims: Long)

Chain-like setter to set up input shape.

summary
Link copied to clipboard
common
open fun summary(): <ERROR CLASS>
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

inputDataType
Link copied to clipboard
common
lateinit var inputDataType: <ERROR CLASS>

Data type for input tensor.

inputDimensions
Link copied to clipboard
common
open val inputDimensions: LongArray
name
Link copied to clipboard
common
var name: String? = null

Model name.

outputDataType
Link copied to clipboard
common
lateinit var outputDataType: <ERROR CLASS>

Data type for output tensor.

outputShape
Link copied to clipboard
common
lateinit var outputShape: LongArray

Data shape for prediction.