ONNX Runtime

:fire: ONNX Runtime - the high performance scoring engine for ML models - for Ruby

Check out an example

Build Status Build status

Installation

Add this line to your application’s Gemfile:

gem 'onnxruntime'

Getting Started

Load a model and make predictions

model = OnnxRuntime::Model.new("model.onnx")
model.predict(x: [1, 2, 3])

Download pre-trained models from the ONNX Model Zoo

Get inputs

model.inputs

Get outputs

model.outputs

Load a model from a string

byte_str = File.binread("model.onnx")
model = OnnxRuntime::Model.new(byte_str)

Get specific outputs

model.predict({x: [1, 2, 3]}, output_names: ["label"])

Inference Session API

You can also use the Inference Session API, which follows the Python API.

session = OnnxRuntime::InferenceSession.new("model.onnx")
session.run(nil, {x: [1, 2, 3]})

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: