{ "info": { "author": "Microsoft Corporation", "author_email": "onnx@microsoft.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "\n

\n\n| Linux | Windows |\n|-------|---------|\n| [![Build Status](https://dev.azure.com/onnxmltools/onnxmltools/_apis/build/status/onnxmltools-linux-conda-ci?branchName=master)](https://dev.azure.com/onnxmltools/onnxmltools/_build/latest?definitionId=3?branchName=master)| [![Build Status](https://dev.azure.com/onnxmltools/onnxmltools/_apis/build/status/onnxmltools-win32-conda-ci?branchName=master)](https://dev.azure.com/onnxmltools/onnxmltools/_build/latest?definitionId=3?branchName=master)|\n\n# Introduction \nONNXMLTools enables you to convert models from different machine learning toolkits into [ONNX](https://onnx.ai). Currently the following toolkits are supported:\n* Keras (a wrapper of [keras2onnx converter](https://github.com/onnx/keras-onnx/))\n* Tensorflow (a wrapper of [tf2onnx converter](https://github.com/onnx/tensorflow-onnx/))\n* scikit-learn (a wrapper of [skl2onnx converter](https://github.com/onnx/sklearn-onnx/))\n* Apple Core ML\n* Spark ML (experimental)\n* LightGBM\n* libsvm\n* XGBoost\n\n## Install\nYou can install latest release of ONNXMLTools from [PyPi](https://pypi.org/project/onnxmltools/):\n```\npip install onnxmltools\n```\nor install from source:\n```\npip install git+https://github.com/onnx/onnxmltools\n```\nIf you choose to install `onnxmltools` from its source code, you must set the environment variable `ONNX_ML=1` before installing the `onnx` package. \n\n## Dependencies\nThis package relies on ONNX, NumPy, and ProtoBuf. If you are converting a model from scikit-learn, Core ML, Keras, LightGBM, SparkML, XGBoost, or LibSVM, you will need an environment with the respective package installed from the list below:\n1. scikit-learn\n2. CoreMLTools\n3. Keras (version 2.0.8 or higher) with the corresponding Tensorflow version\n4. LightGBM (scikit-learn interface)\n5. SparkML\n6. XGBoost (scikit-learn interface)\n7. libsvm\n\nONNXMLTools has been tested with Python **2.7**, **3.5**, **3.6**, and **3.7**. \n `Note: some wrapped converters may not support python 2.x anymore.`\n\n# Examples\nIf you want the converted ONNX model to be compatible with a certain ONNX version, please specify the target_opset parameter upon invoking the convert function. The following Keras model conversion example demonstrates this below. You can identify the mapping from ONNX Operator Sets (referred to as opsets) to ONNX releases in the [versioning documentation](https://github.com/onnx/onnx/blob/master/docs/Versioning.md#released-versions). \n\n## Keras to ONNX Conversion\nNext, we show an example of converting a Keras model into an ONNX model with `target_opset=7`, which corresponds to ONNX release version 1.2.\n\n```python\nimport onnxmltools\nfrom keras.layers import Input, Dense, Add\nfrom keras.models import Model\n\n# N: batch size, C: sub-model input dimension, D: final model's input dimension\nN, C, D = 2, 3, 3\n\n# Define a sub-model, it will become a part of our final model\nsub_input1 = Input(shape=(C,))\nsub_mapped1 = Dense(D)(sub_input1)\nsub_model1 = Model(inputs=sub_input1, outputs=sub_mapped1)\n\n# Define another sub-model, it will become a part of our final model\nsub_input2 = Input(shape=(C,))\nsub_mapped2 = Dense(D)(sub_input2)\nsub_model2 = Model(inputs=sub_input2, outputs=sub_mapped2)\n\n# Define a model built upon the previous two sub-models\ninput1 = Input(shape=(D,))\ninput2 = Input(shape=(D,))\nmapped1_2 = sub_model1(input1)\nmapped2_2 = sub_model2(input2)\nsub_sum = Add()([mapped1_2, mapped2_2])\nkeras_model = Model(inputs=[input1, input2], output=sub_sum)\n\n# Convert it! The target_opset parameter is optional.\nonnx_model = onnxmltools.convert_keras(keras_model, target_opset=7) \n```\n\n## CoreML to ONNX Conversion\nHere is a simple code snippet to convert a Core ML model into an ONNX model.\n\n```python\nimport onnxmltools\nimport coremltools\n\n# Load a Core ML model\ncoreml_model = coremltools.utils.load_spec('example.mlmodel')\n\n# Convert the Core ML model into ONNX\nonnx_model = onnxmltools.convert_coreml(coreml_model, 'Example Model')\n\n# Save as protobuf\nonnxmltools.utils.save_model(onnx_model, 'example.onnx')\n```\n\n## Spark ML to ONNX Conversion (experimental)\nPlease refer to the following documents:\n * [Conversion Framework](onnxmltools/convert/README.md)\n * [Spark ML to ONNX Model Conversion](onnxmltools/convert/sparkml/README.md)\n\n# Testing model converters\n\n*onnxmltools* converts models into the ONNX format which\ncan be then used to compute predictions with the\nbackend of your choice. \n\n## Checking the operator set version of your converted ONNX model\n\nYou can check the operator set of your converted ONNX model using [Netron](https://github.com/lutzroeder/Netron), a viewer for Neural Network models. Alternatively, you could identify your converted model's opset version through the following line of code.\n\n```\nopset_version = onnx_model.opset_import[0].version\n```\n\nIf the result from checking your ONNX model's opset is smaller than the `target_opset` number you specified in the onnxmltools.convert function, be assured that this is likely intended behavior. The ONNXMLTools converter works by converting each operator to the ONNX format individually and finding the corresponding opset version that it was most recently updated in. Once all of the operators are converted, the resultant ONNX model has the maximal opset version of all of its operators.\n\nTo illustrate this concretely, let's consider a model with two operators, Abs and Add. As of December 2018, [Abs](https://github.com/onnx/onnx/blob/master/docs/Operators.md#abs) was most recently updated in opset 6, and [Add](https://github.com/onnx/onnx/blob/master/docs/Operators.md#add) was most recently updated in opset 7. Therefore, the converted ONNX model's opset will always be 7, even if you request `target_opset=8`. The converter behavior was defined this way to ensure backwards compatibility. \n\nDocumentation for the [ONNX Model format](https://github.com/onnx/onnx) and more examples for converting models from different frameworks can be found in the [ONNX tutorials](https://github.com/onnx/tutorials) repository. \n\n## Test all existing converters\n\nThere exists a way\nto automatically check every converter with\n[onnxruntime](https://pypi.org/project/onnxruntime/) or\n[onnxruntime-gpu](https://pypi.org/project/onnxruntime-gpu/).\nThis process requires the user to clone the *onnxmltools* repository.\nThe following command runs all unit tests and generates\ndumps of models, inputs, expected outputs and converted models\nin folder ``TESTDUMP``.\n\n```\npython tests/main.py DUMP\n```\n\nIt requires *onnxruntime*, *numpy* for most models,\n*pandas* for transforms related to text features, and\n*scipy* for sparse features. One test also requires\n*keras* to test a custom operator. That means\n*sklearn* or any machine learning library is requested.\n\n## Add a new converter\n\nOnce the converter is implemented, a unit test is added\nto confirm that it works. At the end of the unit test, function\n*dump_data_and_model* or any equivalent function must be called\nto dump the expected output and the converted model.\nOnce these file are generated, a corresponding test must\nbe added in *tests_backend* to compute the prediction\nwith the runtime.\n\n# License\n[MIT License](LICENSE)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/onnx/onnxmltools", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "onnxmltools", "package_url": "https://pypi.org/project/onnxmltools/", "platform": "", "project_url": "https://pypi.org/project/onnxmltools/", "project_urls": { "Homepage": "https://github.com/onnx/onnxmltools" }, "release_url": "https://pypi.org/project/onnxmltools/1.5.1/", "requires_dist": [ "six", "numpy", "protobuf", "onnx", "skl2onnx", "keras2onnx", "onnxconverter-common (>=1.5.0)" ], "requires_python": "", "summary": "Converts Machine Learning models to ONNX", "version": "1.5.1" }, "last_serial": 5929645, "releases": { "1.0.0.0": [ { "comment_text": "", "digests": { "md5": "98c46386d617ae0708bae6e01e732d7d", "sha256": "5cc8ac6b3cf2e5f71919d4c5c56e4b407b3108627345f593496c46677a1f70c2" }, "downloads": -1, "filename": "onnxmltools-1.0.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "98c46386d617ae0708bae6e01e732d7d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 154021, "upload_time": "2018-03-06T19:28:11", "url": "https://files.pythonhosted.org/packages/43/4f/021c682822f4c3865244fc329825e57fe497c7abe00585454550e54844f3/onnxmltools-1.0.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3923695fcf707629752f7f982441fd3a", "sha256": "e4f5195abf157379673a4bada899770969f34c2491c4e8c34ae19fe2d74a6a6f" }, "downloads": -1, "filename": "onnxmltools-1.0.0.0.tar.gz", "has_sig": true, "md5_digest": "3923695fcf707629752f7f982441fd3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 97196, "upload_time": "2018-03-07T23:47:36", "url": "https://files.pythonhosted.org/packages/a9/b2/f9dab85f34bc4e48208e1523bf07cee8391ef2cae9cd5c618c50ef146e72/onnxmltools-1.0.0.0.tar.gz" } ], "1.2.0.116": [ { "comment_text": "", "digests": { "md5": "376980f13a2c1b4eb9416e83ad34841d", "sha256": "6a5bdb9b43748003f565f8a2b8beab195f6941d11271b4f0397bbfb1b7216cb1" }, "downloads": -1, "filename": "onnxmltools-1.2.0.116-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "376980f13a2c1b4eb9416e83ad34841d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 239498, "upload_time": "2018-07-28T01:07:00", "url": "https://files.pythonhosted.org/packages/9d/b9/5602f1facbed26dade48939df2c662feaf304b0cfaebf8578eb4e5fb16c0/onnxmltools-1.2.0.116-py2.py3-none-any.whl" } ], "1.2.2.129": [ { "comment_text": "", "digests": { "md5": "e32241542f4a3163e8475dcef6ba0f5c", "sha256": "5ec1f18e0c346875a82858579a91e7883b07257813a16a1d7bcee0db0070380e" }, "downloads": -1, "filename": "onnxmltools-1.2.2.129-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e32241542f4a3163e8475dcef6ba0f5c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 244982, "upload_time": "2018-08-25T00:37:02", "url": "https://files.pythonhosted.org/packages/e5/dd/0530dbe2d76a3c2dacc5ecc7f3561ffeae65967cf350fde776ef4f99c10d/onnxmltools-1.2.2.129-py2.py3-none-any.whl" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "50c30acf0d3e640a66d6b81f113d843a", "sha256": "a6cf1329e5ea5e502f21a067ae501f3a603d69d580e310834386df962fd62b13" }, "downloads": -1, "filename": "onnxmltools-1.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "50c30acf0d3e640a66d6b81f113d843a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 275003, "upload_time": "2018-11-29T03:20:25", "url": "https://files.pythonhosted.org/packages/8e/c1/7e75eec649d912bc91294b60fa3e03cf352bb7aa14f3c40c64e591fc9e40/onnxmltools-1.3.0-py2.py3-none-any.whl" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "6e8c65837b2bcb3358fdd605d89fa9ec", "sha256": "211a769fcc76aee96c580a43b64b0dd6afcd73be11d64ef6acf9b4b1f9bb8657" }, "downloads": -1, "filename": "onnxmltools-1.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6e8c65837b2bcb3358fdd605d89fa9ec", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 278415, "upload_time": "2018-12-13T23:23:51", "url": "https://files.pythonhosted.org/packages/9a/e6/083b6fe47400f49f02e1909b8327c955e0a3a2f64477bb524528a73960f6/onnxmltools-1.3.1-py2.py3-none-any.whl" } ], "1.3.2": [ { "comment_text": "", "digests": { "md5": "a0acac4ee590be2b453d9af20ae48103", "sha256": "186784697cb412cb50a1ac8b6905ad009f5016444c129190d5e9b3912860a087" }, "downloads": -1, "filename": "onnxmltools-1.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a0acac4ee590be2b453d9af20ae48103", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 324728, "upload_time": "2019-02-27T01:33:24", "url": "https://files.pythonhosted.org/packages/ae/c3/289babd985da99f7f578c34eafef1965c9fc6e91b215def0e3405a6f9ac7/onnxmltools-1.3.2-py2.py3-none-any.whl" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "c983872fa16c4b2a10949a5b910688dc", "sha256": "5bc1d272ed895a667917150824743fb32c3a367f061beac83a51153e1834fa7e" }, "downloads": -1, "filename": "onnxmltools-1.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c983872fa16c4b2a10949a5b910688dc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 326053, "upload_time": "2019-04-02T17:37:26", "url": "https://files.pythonhosted.org/packages/6f/0d/83201824e7693b63eac297e294cfa8af69f70b1b56492d40d580ba44bb6a/onnxmltools-1.4.0-py2.py3-none-any.whl" } ], "1.4.1": [ { "comment_text": "", "digests": { "md5": "e024f9b6a8458d4f95d83fe0a7e45cfb", "sha256": "8fe996214bfcef577b645ccbb29ba4d57d67719ef87e6505dce928e31485bbf5" }, "downloads": -1, "filename": "onnxmltools-1.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e024f9b6a8458d4f95d83fe0a7e45cfb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 371471, "upload_time": "2019-04-18T19:01:30", "url": "https://files.pythonhosted.org/packages/78/7f/1d47b82f1e98f742018e4c4c227ec9bd0ae1efdba3a6dfd7d30c45881fb9/onnxmltools-1.4.1-py2.py3-none-any.whl" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "d9455985e23a0f901a61e3b3c271ff1c", "sha256": "e56a7cdda84ffeb9b1ba01992e79aaafae4f0d15d902c7b9cd199b0435c4a2ae" }, "downloads": -1, "filename": "onnxmltools-1.5.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d9455985e23a0f901a61e3b3c271ff1c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 285906, "upload_time": "2019-06-11T21:12:41", "url": "https://files.pythonhosted.org/packages/9f/eb/831bd9a76a40fe9aaf9f885daaddc0e5a9e93cd76baa778ccfc059516dcd/onnxmltools-1.5.0-py2.py3-none-any.whl" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "47083433947bf54d091399abfe10df0e", "sha256": "bf3f694e536c06fc1caa87d020f877057a7d85f81bdff9f2de98654ab7ec20b8" }, "downloads": -1, "filename": "onnxmltools-1.5.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47083433947bf54d091399abfe10df0e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 287005, "upload_time": "2019-10-04T18:24:47", "url": "https://files.pythonhosted.org/packages/1a/8d/1ce8919aaea63e5bc3aa3e055639cd9cfb34350cb30f7de2499b3bd23c3f/onnxmltools-1.5.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47083433947bf54d091399abfe10df0e", "sha256": "bf3f694e536c06fc1caa87d020f877057a7d85f81bdff9f2de98654ab7ec20b8" }, "downloads": -1, "filename": "onnxmltools-1.5.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "47083433947bf54d091399abfe10df0e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 287005, "upload_time": "2019-10-04T18:24:47", "url": "https://files.pythonhosted.org/packages/1a/8d/1ce8919aaea63e5bc3aa3e055639cd9cfb34350cb30f7de2499b3bd23c3f/onnxmltools-1.5.1-py2.py3-none-any.whl" } ] }