Library to transform onnx model to pytorch.
Project description
ONNX to Pytorch
A library to transform ONNX model to Pytorch. This library enables use of Pytorch backend and all of its great features for manipulation of neural networks.
Installation
pip install onnx2pytorch
Usage
import onnx
from onnx2pytorch import ConvertModel
onnx_model = onnx.load(path_to_onnx_model)
pytorch_model = ConvertModel(onnx_model)
Currently supported and tested models from onnx_zoo:
- MobileNet
- ResNet
- ShuffleNet
- Bert
Limitations
Known current version limitations are:
batch_size > 1could deliver unexpected results due to ambiguity of onnx's BatchNorm layer.
That is why in this case for now we raise an assertion error.
Setexperimental=TrueinConvertModelto be able to usebatch_size > 1.- Fine tuning and training of converted models was not tested yet, only inference.
Development
Dependency installation
pip install -r requirements.txt
From onnxruntime>=1.5.0 you need to add the
following to your .bashrc or .zshrc if you are running OSx:
export KMP_DUPLICATE_LIB_OK=True
Code formatting
The Uncompromising Code Formatter: Black
black {source_file_or_directory}
Install it into pre-commit hook to always commit nicely formatted code:
pre-commmit install
Testing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onnx2pytorch-0.1.0.tar.gz.
File metadata
- Download URL: onnx2pytorch-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b830bc6dfb6b59f44b6734cc1b8361713b90c38a4fcacbd607141d648bdd2d0c
|
|
| MD5 |
a1ef8e426a92f7e2d192f13811e1fb5e
|
|
| BLAKE2b-256 |
f708af6bb7cf3273e9faef4ea1363f5561039fc5d5d62df69d63d002a2515c6c
|
File details
Details for the file onnx2pytorch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: onnx2pytorch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e6177c66b03ad0568dd6587bc601918c392bd8a0bb150ef1cb301ebf6a81944
|
|
| MD5 |
7e7d82d8a77fd47e7ce39e0fbcf1e8e9
|
|
| BLAKE2b-256 |
4d3c2b1058848cfa8cdf76c5fb69a00bd9bffb0dfce5af10ec46812f6a7ef768
|