deeplitemodelconverter 1.2.4
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.
Installation
Install using pip
Install from source
Install in Dev mode
How to Use
PyTorch2ONNX
TF2TFLite
Examples
Supported Converters
Contribute a Converter
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.
Fork the repo on GitHub
Clone the project to your own machine
Commit changes to your own branch
Push your work back up to your fork
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!
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.