Skip to main content

Converter of Deep Learning Model Formats

Project description

Deeplite Model Converter

Collaboration is one of the biggest challenge is designing deep learning based solutions. There are multiple formats available using which a deep learning mdoel can be expressed: PyTorch, Tensorflow, ONNX, TFLite. This open source converter library aims to convert convert deep learning models from one format to another.

Install using pip

Use following command to install the package from our internal PyPI repository.

$ pip install --upgrade pip
$ pip install deeplite-model-converter

Install from source

$ git clone https://github.com/Deeplite/deeplite-model-converter.git
$ pip install .

Install in Dev mode

$ git clone https://github.com/Deeplite/deeplite-model-converter.git
$ pip install -e .
$ pip install -r requirements-test.txt

To test the installation, one can run the basic tests using pytest command in the root folder.

NOTE: Currently, we support Tensorflow 2.4+ versions, and onnxruntime 1.8. We do not support all the OPSET versions of ONNX, yet.

How to Use

PyTorch2ONNX

# Step 1: Define native pytorch dataloaders and model
data_splits = /* ... load iterable data loaders ... */
model = /* ... load native deep learning model ... */

# Step 2: Instantiate a converter object
pytorch2onnx = PyTorch2ONNX(model=model)
pytorch2onnx.set_config(precision='fp32', device=Device.CPU)

# Step 3: Convert the format and save
dataloader = TorchProfiler.enable_forward_pass_data_splits(data_splits)
rval = pytorch2onnx.convert(dataloader, dynamic_input='bchw', path="model.onnx")

TF2TFLite

# Step 1: Define native Tensorflow model
model_conc_functions = /* ... load TF native model as concrete functions ... */

# Step 2: Instantiate a converter object
tf2tflite = TF2TFLite(model=model_conc_functions)

# Step 3: Convert the format and save
tflite_model, rval = tf2tflite.convert()
tf2tflite.save(tflite_model, "model.tflite")

Examples

To run an example,

pip install deeplite-torch-zoo
python examples/converters/pytorch2tflite.py

Supported Converters

The following converters are supported till now,

  • pytorch2onnx
  • pytorch2jit
  • onnx2tf
  • tf2tflite

Contribute a Converter

We always welcome community contributions to expand the scope of deeplite-model-converter and also to have additional new converters. In general, we follow the fork-and-pull Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

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

deeplite_model_converter-1.2.4-cp39-cp39-manylinux2010_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

deeplite_model_converter-1.2.4-cp38-cp38-manylinux2010_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

deeplite_model_converter-1.2.4-cp37-cp37m-manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

deeplite_model_converter-1.2.4-cp36-cp36m-manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

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