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, 10, name='ExampleModel')

Post Training Weight 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')


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

Toolkit Source
libsvm You can download libsvm wheel from various web sources. One example can be found here:
coremltools Currenlty coreml does not distribute coreml packaging on windows. You can install from source: pip install git+

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


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.

Files for winmltools, version 1.5.1
Filename, size File type Python version Upload date Hashes
Filename, size winmltools-1.5.1-py2.py3-none-any.whl (40.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size winmltools-1.5.1.tar.gz (26.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page