Skip to main content

ONNX Runtime Runtime Python bindings

Project description

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]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

onnxruntime-0.1.3-cp37-cp37m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.7m

onnxruntime-0.1.3-cp36-cp36m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.6m

onnxruntime-0.1.3-cp35-cp35m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.5m

File details

Details for the file onnxruntime-0.1.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.1.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for onnxruntime-0.1.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5b80d422b40ec0a29fe5054ba6987c983f5359377130a67be0114e5a8bb9dda0
MD5 6198ac0725be751d785803bef106aef7
BLAKE2b-256 02180b95c86c5a8ac0e77d7299a38e28df5298058a43df136f13320ec1ceda2d

See more details on using hashes here.

File details

Details for the file onnxruntime-0.1.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for onnxruntime-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 823b428364a50c3287a87f216a773d5543da40aff29142b9ce0920b0e6032eaf
MD5 18b68e06b21d6ad408d2b0dcd9eb3451
BLAKE2b-256 9ce76781ac5845525ee04722a42a151fd9d93421abc75eae5c58904815865b17

See more details on using hashes here.

File details

Details for the file onnxruntime-0.1.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.5m
  • Uploaded using 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

File hashes

Hashes for onnxruntime-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6548b5251bba22cef43897e281dc65b236324c38136e0cd52a4169d136b89f49
MD5 a89156cb34996373dd15799db8ee5e20
BLAKE2b-256 63f91148bd031a98ea128ce76885bd51cdadef3457e87ffe14884d9ab0fe1bd2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page