onnx-tensorflow

Tensorflow Backend and Frontend for ONNX

Github星跟蹤圖

Tensorflow Backend for ONNX

Build Status

To convert models from ONNX to Tensorflow:

Use CLI:

Command Line Interface Documentation

From ONNX to Tensorflow: onnx-tf convert -t tf -i /path/to/input.onnx -o /path/to/output.pb

Convert programmatically:

From ONNX to Tensorflow

Migrating from onnx-tf to tf-onnx:

We have joined force with Microsoft to co-develop ONNX Tensorflow frontend.
For current onnx-tf frontend users, please migrate to use tf-onnx (https://github.com/onnx/tensorflow-onnx) where our code had been merged into.

ONNX model inference with Tensorflow backend:

import onnx
from onnx_tf.backend import prepare

onnx_model = onnx.load("input_path")  # load onnx model
output = prepare(onnx_model).run(input)  # run the loaded model

More tutorials:

Running an ONNX model using Tensorflow

Production Installation:

ONNX-TF requires ONNX (Open Neural Network Exchange) as an external dependency, for any issues related to ONNX installation, we refer our users to ONNX project repository for documentation and help. Notably, please ensure that protoc is available if you plan to install ONNX via pip.

The specific ONNX release version that we support in the master branch of ONNX-TF can be found here. This information about ONNX version requirement is automatically encoded in setup.py, therefore users needn't worry about ONNX version requirement when installing ONNX-TF.

To install the latest version of ONNX-TF via pip, run pip install onnx-tf.

Because users often have their own preferences for which variant of Tensorflow to install (i.e., a GPU version instead of a CPU version), we do not explicitly require tensorflow in the installation script. It is therefore users' responsibility to ensure that the proper variant of Tensorflow is available to ONNX-TF. Moreoever, we require Tensorflow version == 1.15.0.

Development:

Coverage Status:

ONNX-Tensorflow Op Coverage Status

API:

ONNX-Tensorflow API

Installation:

  • Install ONNX master branch from source.
  • Install Tensorflow >= 2.0 and tensorflow-addons. (Note for Tensorflow 1.x please refer the tf-1.x branch)
  • Run git clone git@github.com:onnx/onnx-tensorflow.git && cd onnx-tensorflow.
  • Run pip install -e ..

Folder Structure:

  • onnx_tf main source code file.
  • test test files.

Code Standard:

  • Format code:
pip install yapf
yapf -rip --style="{based_on_style: google, indent_width: 2}" $FilePath$
  • Install pylint:
pip install pylint
wget -O /tmp/pylintrc https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/ci_build/pylintrc
  • Check format:
pylint --rcfile=/tmp/pylintrc myfile.py

Documentation Standard:

http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

To test:

To perfom unit tests, run python -m unittest discover test.
Testing requires significant hardware resources, but nonetheless, we highly recommend that users run through the complete test suite before deploying onnx-tf. The complete test suite typically takes between 15 and 45 minutes to complete, depending on hardware configurations.

PS. Please ensure your code is backward compatible with older version of ONNX. You can easily test it by running the following docker container with your code. If you don't have Docker installed yet, please follow this link to install Docker on your environment.

sudo docker pull winnietsang/onnx-tensorflow:onnx1.6.0-tf2.0
sudo docker run -it --name=YOUR-CONTAINER-NAME winnietsang/onnx-tensorflow:onnx1.6.0-tf2.0 /bin/bash
git clone https://github.com/YOUR-USERNAME/onnx-tensorflow.git
cd onnx-tensorflow
git checkout -b YOUR-BRANCH --track remotes/origin/YOUR-BRANCH
pip3 install -e .
python3 -m unittest discover test

Test Help:

https://docs.python.org/2/library/unittest.html

Authors:

Arpith Jacob (IBM Research)

Tian Jin (IBM Research)

Gheorghe-Teodor Bercea (IBM Research)

Wenhao Hu (LeapMind)

主要指標

概覽
名稱與所有者onnx/onnx-tensorflow
主編程語言Python
編程語言Shell (語言數: 2)
平台
許可證Other
所有者活动
創建於2017-10-05 21:30:34
推送於2024-03-28 08:15:06
最后一次提交
發布數14
最新版本名稱v1.10.0 (發布於 )
第一版名稱v1.1 (發布於 )
用户参与
星數1.3k
關注者數48
派生數297
提交數747
已啟用問題?
問題數547
打開的問題數256
拉請求數468
打開的拉請求數12
關閉的拉請求數53
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?