• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

onnx_tf/H01-Dec-2020-10,5437,979

onnx_tf.egg-info/H03-May-2022-1312

test/H01-Dec-2020-4,8574,174

third_party/H01-Dec-2020-11267

LICENSEH A D01-Dec-202011 KiB214170

MANIFEST.inH A D01-Dec-202067 43

ONNX_VERSION_NUMBERH A D01-Dec-20206 21

PKG-INFOH A D01-Dec-2020433 1312

README.mdH A D01-Dec-20204.6 KiB9772

VERSION_NUMBERH A D01-Dec-20206 21

setup.cfgH A D01-Dec-2020102 96

setup.pyH A D01-Dec-20201.2 KiB4033

README.md

1# Tensorflow Backend for ONNX
2[![Build Status](https://travis-ci.org/onnx/onnx-tensorflow.svg?branch=master)](https://travis-ci.org/onnx/onnx-tensorflow)
3
4## To convert models from ONNX to Tensorflow:
5
6### Use CLI:
7
8[Command Line Interface Documentation](https://github.com/onnx/onnx-tensorflow/blob/master/doc/CLI.md)
9
10From ONNX to Tensorflow: `onnx-tf convert -i /path/to/input.onnx -o /path/to/output.pb`
11
12### Convert programmatically:
13
14[From ONNX to Tensorflow](https://github.com/onnx/onnx-tensorflow/blob/master/example/onnx_to_tf.py)
15
16### Migrating from `onnx-tf` to `tf-onnx`:
17We have joined force with Microsoft to co-develop ONNX Tensorflow frontend.
18For current onnx-tf frontend users, please migrate to use tf-onnx (https://github.com/onnx/tensorflow-onnx) where our code had been merged into.
19
20## ONNX model inference with Tensorflow backend:
21```
22import onnx
23from onnx_tf.backend import prepare
24
25onnx_model = onnx.load("input_path")  # load onnx model
26output = prepare(onnx_model).run(input)  # run the loaded model
27```
28
29## More tutorials:
30[Running an ONNX model using Tensorflow](https://github.com/onnx/tutorials/blob/master/tutorials/OnnxTensorflowImport.ipynb)
31
32## Production Installation:
33ONNX-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](https://github.com/onnx/onnx) for documentation and help. Notably, please ensure that protoc is available if you plan to install ONNX via pip.
34
35The specific ONNX release version that we support in the master branch of ONNX-TF can be found [here](https://github.com/onnx/onnx-tensorflow/blob/master/ONNX_VERSION_NUMBER). 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.
36
37To install the latest version of ONNX-TF via pip, run `pip install onnx-tf`.
38
39Because 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. Moreover, we require Tensorflow version == 2.2.0.
40
41## Development:
42
43### Coverage Status:
44[ONNX-Tensorflow Op Coverage Status](https://github.com/onnx/onnx-tensorflow/blob/master/doc/support_status.md)
45
46### API:
47[ONNX-Tensorflow API](https://github.com/onnx/onnx-tensorflow/blob/master/doc/API.md)
48
49### Installation:
50- Run `git clone https://github.com/onnx/onnx.git && cd onnx`.
51- Run `git submodule update --init --recursive`.
52- Run `pip install -e .`.
53- Install Tensorflow >= 2.2.0 and tensorflow-addons. (Note for Tensorflow 1.x please refer the [tf-1.x branch](https://github.com/onnx/onnx-tensorflow/tree/tf-1.x))
54- Run `git clone https://github.com/onnx/onnx-tensorflow.git && cd onnx-tensorflow`.
55- Run `pip install -e .`.
56
57### Folder Structure:
58- __onnx_tf__ main source code file.
59- __test__ test files.
60
61### Code Standard:
62- Format code:
63```
64pip install yapf
65yapf -rip --style="{based_on_style: google, indent_width: 2}" $FilePath$
66```
67- Install pylint:
68```
69pip install pylint
70wget -O /tmp/pylintrc https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/ci_build/pylintrc
71```
72- Check format:
73```
74pylint --rcfile=/tmp/pylintrc myfile.py
75```
76
77### Documentation Standard:
78http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
79
80### To test:
81To perfom unit tests, run `python -m unittest discover test`.
82Testing 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.
83
84PS. Please ensure your code is backward compatible with older version of ONNX. You can easily test it by running the following [docker container](https://hub.docker.com/r/winnietsang/onnx-tensorflow) with your code. If you don't have Docker installed yet, please follow this link to install [Docker](https://docs.docker.com/install/) on your environment.
85```
86sudo docker pull winnietsang/onnx-tensorflow:onnx1.7.0-tf2.2
87sudo docker run -it --name=YOUR-CONTAINER-NAME winnietsang/onnx-tensorflow:onnx1.7.0-tf2.2 /bin/bash
88git clone https://github.com/YOUR-USERNAME/onnx-tensorflow.git
89cd onnx-tensorflow
90git checkout -b YOUR-BRANCH --track remotes/origin/YOUR-BRANCH
91pip3 install -e .
92python3 -m unittest discover test
93```
94
95#### Test Help:
96https://docs.python.org/2/library/unittest.html
97