Skip to main content

Converts Machine Learning models to ONNX for use in Windows ML

Project description

WinMLTools provide following tools for Windows ML:

Model Conversion

WinMLTools enables you to convert models from different machine learning toolkits into ONNX for use with Windows ML. Currently the following toolkits are supported:

  • apple CoreML

  • keras

  • scikit-learn

  • lightgbm

  • xgboost

  • libSVM

  • tensorflow (experimental)

Here is a simple example to convert a Core ML model:

from coremltools.models.utils import load_spec
from winmltools import convert_coreml
model_coreml = load_spec('example.mlmodel')
model_onnx = convert_coreml(model_coreml, 7, name='ExampleModel')

Quantization

WinMLTools provides quantization tool to reduce the memory footprint of the model.

Here is an example to convert an ONNX model to a quantized ONNX model:

import winmltools

model = winmltools.load_model('model.onnx')
quantized_model = winmltools.quantize(model, per_channel=True, nbits=8, use_dequantize_linear=True)
winmltools.save_model(quantized_model, 'quantized.onnx')

Dependencies

In order to convert from different toolkits, you may have to install the following packages for different converters:

Toolkit

Source

keras

https://pypi-hypernode.com/project/Keras

tensorflow

https://pypi-hypernode.com/project/tensorflow

scikit-learn

https://pypi-hypernode.com/project/scikit-learn

lightgbm

https://pypi-hypernode.com/project/lightgbm

xgboost

https://pypi-hypernode.com/project/xgboost

libsvm

You can download libsvm wheel from various web sources. One example can be found here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm

coremltools

Currenlty coreml does not distribute coreml packaging on windows. You can install from source: pip install git+https://github.com/apple/coremltools

For more information on WinMLTools, you can go to Convert ML models to ONNX with WinMLTools

License

MIT License

Project details


Download files

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

Source Distribution

winmltools-1.3.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

winmltools-1.3.0-py2.py3-none-any.whl (57.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file winmltools-1.3.0.tar.gz.

File metadata

  • Download URL: winmltools-1.3.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.14

File hashes

Hashes for winmltools-1.3.0.tar.gz
Algorithm Hash digest
SHA256 196048fbfa66ec9ade74daa7223b9fb5771d6653dda79abb44b7c1e5ceabf944
MD5 c529fe09d3e53e282be8083367331bf3
BLAKE2b-256 185530fbd08c86ce98f7085e173cb8a7bf4fa1a7d3d329140d1910be38da3ccb

See more details on using hashes here.

File details

Details for the file winmltools-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: winmltools-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 57.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.14

File hashes

Hashes for winmltools-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 508dd847f65a29f17f57695147b035db89aa9809ee3d7dc5fd6b633b94dded5a
MD5 61590e794544cc1e4362f99ea0982a41
BLAKE2b-256 1eed8b3cd64cc499e6826a11874fcd60da5ebeebf42618df791426b32b50a6d2

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