Skip to content

Commit 8432455

Browse files
authored
Merge pull request #59 from pengwa/readme-fix
Refine readme installation & usage
2 parents 88b317f + d74ad53 commit 8432455

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

README.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,79 @@ Tf2onnx is in its early development. Mileage will vary since TensorFlow supports
1212
# Status
1313
Basic net and conv nets should work. A list of models that pass tests can be found [here](tests/run_pretrained_models.yaml)
1414

15-
# Installation
15+
# Prerequisites
16+
17+
## Install TensorFlow
1618
If you don't have tensorflow installed already, install the desired tensorflow build, for example:
1719
```
1820
pip install tensorflow
1921
or
2022
pip install tensorflow-gpu
2123
```
22-
24+
## Install Caffe2 [**Optional**]
2325
If you want to run unit tests against the Caffe2 onnx backend, build and install Caffe2 following the instructions here: ```
2426
https://caffe2.ai/```
25-
We tested with tensorflow 1.5,1.6,1.7,1.8 and anaconda 3.5,3.6.
27+
28+
## Python Version
29+
We tested with tensorflow 1.5,1.6,1.7,1.8 and anaconda **3.5,3.6**.
30+
31+
# Installation
2632

2733
Once dependencies are installed, from the tensorflow-onnx folder call:
34+
2835
```
2936
python setup.py install
30-
```
3137
or
32-
```
3338
python setup.py develop
3439
```
40+
tensorflow-onnx requires onnx-1.2.2 or better and will install/upgrade onnx if needed.
3541

3642
To create a distribution:
3743
```
3844
python setup.py sdist
3945
```
4046

41-
tensorflow-onnx requires onnx-1.2.2 or better and will install/upgrade onnx if needed.
42-
4347
# Usage
48+
49+
To convert a TensorFlow model, tf2onnx expects a ```frozen TensorFlow graph``` and the user needs to specify inputs and outputs for the graph by passing the input and output
50+
names with ```--inputs INPUTS``` and ```--outputs OUTPUTS```.
51+
52+
Usage command:
4453
```
45-
python -m tf2onnx.convert
46-
usage: convert.py [-h] --input INPUT [--output OUTPUT] [--target TARGET] --inputs INPUTS --outputs OUTPUTS [--continue_on_error] [--verbose] [--opset OPSET]
54+
python -m tf2onnx.convert --input SOURCE_FROZEN_GRAPH_PB\
55+
--inputs SOURCE_GRAPH_INPUTS\
56+
--outputs SOURCE_GRAPH_OUTPUS\
57+
[--output TARGET_ONNX_GRAPH]\
58+
[--target TARGET]\
59+
[--continue_on_error]\
60+
[--verbose]\
61+
[--opset OPSET]
4762
```
48-
For example:
63+
64+
Parameters:
65+
- input: frozen TensorFlow graph, which can be got with [freeze graph tool](#freeze_graph).
66+
- output: the target onnx file path.
67+
- inputs/outputs: Tensorflow graph's input/output names, which can be got with [summarize graph tool](#summarize_graph).
68+
- target: There are different onnx versions and workarounds for runtimes that can be set with ```--target TARGET```. The default is onnx-1.1 and caffe2 which generates a graph
69+
that can be executed on a onnx-1.0/onnx-1.1 runtime, like caffe2 and winml.
70+
71+
Usage example (run following commands in tensorflow-onnx root directory):
4972
```
50-
python -m tf2onnx.convert --input tests/models/fc-layers/frozen.pb --inputs X:0 --outputs output:0 --output tests/models/fc-layers/model.onnx --pretty --verbose
73+
python -m tf2onnx.convert\
74+
--input tests/models/fc-layers/frozen.pb\
75+
--inputs X:0\
76+
--outputs output:0\
77+
--output tests/models/fc-layers/model.onnx\
78+
--verbose
5179
```
5280

53-
To convert a TensorFlow model, tf2onnx expects a ```frozen TensorFlow graph``` and the user needs to specify inputs and outputs for the graph by passing the input and output
54-
names with ```--inputs INPUTS``` and ```--outputs OUTPUTS```.
81+
## <a name="summarize_graph"></a>Tool to Get Graph Inputs & Outputs
82+
5583
To find the inputs and outputs for the TensorFlow graph the model developer will know or you can consult TensorFlow's [summarize_graph](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms) tool, for example:
5684
```
5785
summarize_graph --in_graph=tests/models/fc-layers/frozen.pb
5886
```
87+
## <a name="freeze_graph"></a>Tool to Freeze Graph
5988

6089
The TensorFlow tool to freeze the graph is [here](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py).
6190

@@ -70,8 +99,6 @@ python -m tensorflow.python.tools.freeze_graph \
7099
--output_graph=tests/models/fc-layers/frozen.pb
71100
```
72101

73-
There are different onnx versions and workarounds for runtimes that can be set with ```--target TARGET```. The default is onnx-1.1 and caffe2 which generates a graph
74-
that can be executed on a onnx-1.0/onnx-1.1 runtime, like caffe2 and winml.
75102

76103
# Testing
77104
There are 2 types of tests.

0 commit comments

Comments
 (0)