{
"info": {
"author": "Microsoft Corporation",
"author_email": "winmlcvt@microsoft.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
],
"description": "# Introduction\nThe keras2onnx model converter enables users to convert Keras models into the [ONNX](https://onnx.ai) model format.\nInitially, the Keras converter was developed in the project [onnxmltools](https://github.com/onnx/onnxmltools). keras2onnx converter development was moved into an [independent repository](https://github.com/onnx/keras-onnx) to support more kinds of Keras models and reduce the complexity of mixing multiple converters.\n\nMost of the common Keras layers have been supported for conversion. Please refer to the [Keras documentation](https://keras.io/layers/about-keras-layers/) or [tf.keras docs](https://www.tensorflow.org/api_docs/python/tf/keras/layers) for details on Keras layers.\n\nWindows Machine Learning (WinML) users can use [WinMLTools](https://docs.microsoft.com/en-us/windows/ai/windows-ml/convert-model-winmltools) which wrap its call on keras2onnx to convert the Keras models. If you want to use the keras2onnx converter, please refer to the [WinML Release Notes](https://docs.microsoft.com/en-us/windows/ai/windows-ml/release-notes) to identify the corresponding ONNX opset number for your WinML version.\n\nkeras2onnx has been tested on **Python 3.5, 3.6, and 3.7**, with **tensorflow 1.x/2.0/2.1** (CI build). It does not support **Python 2.x**.\n\n# Install\nYou can install latest release of Keras2ONNX from PyPi: **Due to some reason, the package release paused, please install it from the source, and the support of keras or tf.keras over tensorflow 2.x is only available in the source.**\n\n```\npip install keras2onnx\n```\nor install from source:\n\n```\npip install -U git+https://github.com/microsoft/onnxconverter-common\npip install -U git+https://github.com/onnx/keras-onnx\n```\nBefore running the converter, please notice that tensorflow has to be installed in your python environment,\nyou can choose **tensorflow**/**tensorflow-cpu** package(CPU version) or **tensorflow-gpu**(GPU version)\n\n# Notes\nKeras2ONNX supports the new Keras subclassing model which was introduced in tensorflow 2.0 since the version **1.6.5**. Some typical subclassing models like [huggingface/transformers](https://github.com/huggingface/transformers) have been converted into ONNX and validated by ONNXRuntime.
\n\nSince its version 2.3, the [multi-backend Keras (keras.io)](https://keras.io/#multi-backend-keras-and-tfkeras) stops the support of the tensorflow version above 2.0. The auther suggests to switch to tf.keras for the new features.\n## Multi-backend Keras and tf.keras:\nBoth Keras model types are now supported in the keras2onnx converter. If in the user python env, Keras package was installed from [Keras.io](https://keras.io/) and tensorflow package version is 1.x, the converter converts the model as it was created by the keras.io package. Otherwise, it will convert it through [tf.keras](https://www.tensorflow.org/guide/keras).
\n\nIf you want to override this behaviour, please specify the environment variable TF_KERAS=1 before invoking the converter python API.\n# Development\nKeras2ONNX depends on [onnxconverter-common](https://github.com/microsoft/onnxconverter-common). In practice, the latest code of this converter requires the latest version of onnxconverter-common, so if you install this converter from its source code, please install the onnxconverter-common in source code mode before keras2onnx installation.\n\n# Validated pre-trained Keras models\nMost Keras models could be converted successfully by calling ```keras2onnx.convert_keras```, including CV, GAN, NLP, Speech and etc. See the tutorial [here](https://github.com/onnx/keras-onnx/tree/master/tutorial). However some models with a lot of custom operations need custom conversion, the following are some examples,\nlike [YOLOv3](https://github.com/qqwweee/keras-yolo3), and [Mask RCNN](https://github.com/matterport/Mask_RCNN).\n\n\n## Scripts\nIt will be useful to convert the models from Keras to ONNX from a python script.\nYou can use the following API:\n```\nimport keras2onnx\nkeras2onnx.convert_keras(model, name=None, doc_string='', target_opset=None, channel_first_inputs=None):\n # type: (keras.Model, str, str, int, []) -> onnx.ModelProto\n \"\"\"\n :param model: keras model\n :param name: the converted onnx model internal name\n :param doc_string:\n :param target_opset:\n :param channel_first_inputs: A list of channel first input.\n :return:\n \"\"\"\n```\n\nUse the following script to convert keras application models to onnx, and then perform inference:\n```\nimport numpy as np\nfrom keras.preprocessing import image\nfrom keras.applications.resnet50 import preprocess_input\nimport keras2onnx\nimport onnxruntime\n\n# image preprocessing\nimg_path = 'street.jpg' # make sure the image is in img_path\nimg_size = 224\nimg = image.load_img(img_path, target_size=(img_size, img_size))\nx = image.img_to_array(img)\nx = np.expand_dims(x, axis=0)\nx = preprocess_input(x)\n\n# load keras model\nfrom keras.applications.resnet50 import ResNet50\nmodel = ResNet50(include_top=True, weights='imagenet')\n\n# convert to onnx model\nonnx_model = keras2onnx.convert_keras(model, model.name)\n\n# runtime prediction\ncontent = onnx_model.SerializeToString()\nsess = onnxruntime.InferenceSession(content)\nx = x if isinstance(x, list) else [x]\nfeed = dict([(input.name, x[n]) for n, input in enumerate(sess.get_inputs())])\npred_onnx = sess.run(None, feed)\n```\n\nThe inference result is a list which aligns with keras model prediction result `model.predict()`.\nAn alternative way to load onnx model to runtime session is to save the model first:\n```\ntemp_model_file = 'model.onnx'\nkeras2onnx.save_model(onnx_model, temp_model_file)\nsess = onnxruntime.InferenceSession(temp_model_file)\n```\n\n## Contribute\nWe welcome contributions in the form of feedback, ideas, or code.\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/keras-onnx",
"keywords": "",
"license": "MIT License",
"maintainer": "",
"maintainer_email": "",
"name": "keras2onnx",
"package_url": "https://pypi.org/project/keras2onnx/",
"platform": "",
"project_url": "https://pypi.org/project/keras2onnx/",
"project_urls": {
"Homepage": "https://github.com/onnx/keras-onnx"
},
"release_url": "https://pypi.org/project/keras2onnx/1.7.0/",
"requires_dist": [
"numpy",
"protobuf",
"requests",
"onnx",
"onnxconverter-common (>=1.7.0)",
"fire"
],
"requires_python": "",
"summary": "Converts Machine Learning models to ONNX for use in Windows ML",
"version": "1.7.0",
"yanked": false,
"yanked_reason": null
},
"last_serial": 9949793,
"releases": {
"1.3.0": [
{
"comment_text": "",
"digests": {
"md5": "dede36e79ac57538e6291b8ebf6ecaad",
"sha256": "7b755ed49f330510506c9e0b70beedfd966089d529b42afebae301bb33ca6fec"
},
"downloads": -1,
"filename": "keras2onnx-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dede36e79ac57538e6291b8ebf6ecaad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 50495,
"upload_time": "2019-02-08T01:33:15",
"upload_time_iso_8601": "2019-02-08T01:33:15.276980Z",
"url": "https://files.pythonhosted.org/packages/06/49/d65c82afefb063d5143874c21a457ce968a21ecfb44092873565411a5a4a/keras2onnx-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.3.2": [
{
"comment_text": "",
"digests": {
"md5": "42af2b545a2f7bb13148418fbb361345",
"sha256": "1bd587ae327742dbff4867f5bf37d233d04042b83a5719018bc31bd6a0d9f8b2"
},
"downloads": -1,
"filename": "keras2onnx-1.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "42af2b545a2f7bb13148418fbb361345",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 51752,
"upload_time": "2019-03-18T23:19:16",
"upload_time_iso_8601": "2019-03-18T23:19:16.530667Z",
"url": "https://files.pythonhosted.org/packages/54/aa/80a3f2ed4af13edb63c806891c2fc5737e080d57b759bca4cac1f00b4f84/keras2onnx-1.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.4.0": [
{
"comment_text": "",
"digests": {
"md5": "84af4d69148a4e4d713e9d57911a0be6",
"sha256": "acc622e2d17c24b491d8183296ef603c4808772cf6de86aaee7e767788ee4f7e"
},
"downloads": -1,
"filename": "keras2onnx-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "84af4d69148a4e4d713e9d57911a0be6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 174638,
"upload_time": "2019-04-24T19:34:16",
"upload_time_iso_8601": "2019-04-24T19:34:16.177553Z",
"url": "https://files.pythonhosted.org/packages/d8/17/c1583b741af6400abfd4e6497689acee1b01dc53955321d703a7b5348bd4/keras2onnx-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.5.0": [
{
"comment_text": "",
"digests": {
"md5": "c53b46183a74046d9882555f901c0260",
"sha256": "2c51d98fe2bb588e8df89d297263bd6905c760af12ef65b63a211b368c7a1615"
},
"downloads": -1,
"filename": "keras2onnx-1.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c53b46183a74046d9882555f901c0260",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 186495,
"upload_time": "2019-06-10T23:06:16",
"upload_time_iso_8601": "2019-06-10T23:06:16.337074Z",
"url": "https://files.pythonhosted.org/packages/1a/b0/6f3012cb0c959203dd3ce05e0fc61c9112f0d4043fdf917cf665d8c53254/keras2onnx-1.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.5.1": [
{
"comment_text": "",
"digests": {
"md5": "d29b44064801ab0f8d54309a172257cd",
"sha256": "57b78532987f859edc7c583a9271d05e3953fb4a60940c00e278df4420a89f33"
},
"downloads": -1,
"filename": "keras2onnx-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d29b44064801ab0f8d54309a172257cd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 207915,
"upload_time": "2019-07-26T21:24:58",
"upload_time_iso_8601": "2019-07-26T21:24:58.310075Z",
"url": "https://files.pythonhosted.org/packages/bf/a0/ac1e84e39a115155e57654ae4785f29ed1619f8f80cdbe0344526e4fd04c/keras2onnx-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.5.2": [
{
"comment_text": "",
"digests": {
"md5": "83da4974eb19bc1262dc6b13d9aad04b",
"sha256": "6130c48d3831b066275786a4bde066f03a6c93a531214715b304c8724f3d6c8d"
},
"downloads": -1,
"filename": "keras2onnx-1.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "83da4974eb19bc1262dc6b13d9aad04b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 216853,
"upload_time": "2019-09-27T23:47:39",
"upload_time_iso_8601": "2019-09-27T23:47:39.277247Z",
"url": "https://files.pythonhosted.org/packages/3b/76/f6b4afe9c0b3b46318498324897b8696cd9f976de8c0e4058ec619850c8d/keras2onnx-1.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.6.0": [
{
"comment_text": "",
"digests": {
"md5": "29ee01f2e70876378a10eb61fe4bb82c",
"sha256": "8a47e0dc740617a58945dc9e46bdfe48013b5e8fa2798db4c03b3ee4d8ae395f"
},
"downloads": -1,
"filename": "keras2onnx-1.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "29ee01f2e70876378a10eb61fe4bb82c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 219762,
"upload_time": "2019-10-31T01:21:32",
"upload_time_iso_8601": "2019-10-31T01:21:32.481149Z",
"url": "https://files.pythonhosted.org/packages/60/df/38475abd5ef1e0c5a19f021add159e8a07d10525b2c01f13bf06371aedd4/keras2onnx-1.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.6.1": [
{
"comment_text": "",
"digests": {
"md5": "1d13994ff080ab9b6302a72796f15795",
"sha256": "9063d0bba8cf72526258b7d39ba0bbb747861d365495d540b4ea86ca49581759"
},
"downloads": -1,
"filename": "keras2onnx-1.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d13994ff080ab9b6302a72796f15795",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 220094,
"upload_time": "2020-04-03T21:50:37",
"upload_time_iso_8601": "2020-04-03T21:50:37.098976Z",
"url": "https://files.pythonhosted.org/packages/0a/f5/ea1d0482b7fdb07889fd3d5b2d0954a5813db0a282888968cc00fde897ec/keras2onnx-1.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"1.7.0": [
{
"comment_text": "",
"digests": {
"md5": "85b9e59f942f07e5763ec150f4d1b5b6",
"sha256": "341159ae4b8b2ae06d876e71475e87a364ee2160b49981474a53f1d62b9626e6"
},
"downloads": -1,
"filename": "keras2onnx-1.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85b9e59f942f07e5763ec150f4d1b5b6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 96334,
"upload_time": "2020-06-08T16:31:59",
"upload_time_iso_8601": "2020-06-08T16:31:59.326627Z",
"url": "https://files.pythonhosted.org/packages/a6/2f/c7aef8f8215c62d55ea05f5b36737c1726e4fea6c73970909523ae497fd9/keras2onnx-1.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "85b9e59f942f07e5763ec150f4d1b5b6",
"sha256": "341159ae4b8b2ae06d876e71475e87a364ee2160b49981474a53f1d62b9626e6"
},
"downloads": -1,
"filename": "keras2onnx-1.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85b9e59f942f07e5763ec150f4d1b5b6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 96334,
"upload_time": "2020-06-08T16:31:59",
"upload_time_iso_8601": "2020-06-08T16:31:59.326627Z",
"url": "https://files.pythonhosted.org/packages/a6/2f/c7aef8f8215c62d55ea05f5b36737c1726e4fea6c73970909523ae497fd9/keras2onnx-1.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"vulnerabilities": []
}