ONNX Runtime (Preview) enables high-performance evaluation of trained machine learning (ML) models while keeping resource usage low. Building on Microsoft’s dedication to the Open Neural Network Exchange (ONNX) community, it supports traditional ML models as well as Deep Learning algorithms in the ONNX-ML format. Documentation is available at Python Bindings for ONNX Runtime.
Example
The following example demonstrates an end-to-end example in a very common scenario. A model is trained with scikit-learn but it has to run very fast in a optimized environment. The model is then converted into ONNX format and ONNX Runtime replaces scikit-learn to compute the predictions.
# Train a model.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForest
iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y)
clr = RandomForest()
clr.fit(X_train, y_train)
# Convert into ONNX format with onnxmltools
from onnxmltools import convert_sklearn
from onnxmltools.utils import save_model
from onnxmltools.convert.common.data_types import FloatTensorType
initial_type = [('float_input', FloatTensorType([1, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
save_model(onx, "rf_iris.onnx")
# Compute the prediction with ONNX Runtime
import onnxruntime as rt
import numpy
sess = rt.InferenceSession("rf_iris.onnx")
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]
Release files for onnxruntime 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| onnxruntime-0.1.2-cp37-cp37m-manylinux1_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| onnxruntime-0.1.2-cp35-cp35m-manylinux1_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.5+ x86-64 | Details |
Total release size:13.9 MB
Release files / onnxruntime-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
| Download URL | onnxruntime-0.1.2-cp37-cp37m-manylinux1_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
045b943c1cab7ae2ec40cd12e6e52596860fa2fddd72cd25168795e9c6912320
|
|
BLAKE2b-256 checksum How to use checksums |
17d974e592de97d37763e2aac98782eaaaa17228ed82bc6d4314211a2e059e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.0
|
Release files / onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
| Download URL | onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
63b26ed59840cf9de695cb06319421cc40fd4863fe55f347493777041dd31385
|
|
BLAKE2b-256 checksum How to use checksums |
77c455a23c94f083aa41a68b0385f707db71a091b888142b2299b0313a0c5851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.0
|
Release files / onnxruntime-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
| Download URL | onnxruntime-0.1.2-cp35-cp35m-manylinux1_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
33d0310b4de56a7e66cd246d57cf3d3aa458736ec91c3016882d3b0f80ee9b2a
|
|
BLAKE2b-256 checksum How to use checksums |
e75bf4564ee4e8c96053f3c027f14e9fe42b08e051e3cbc173863a0b42872cf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.0
|