onnxruntime/docs/api/python/sources/auto_examples/plot_pipeline.rst.txt
Cassie a0f3e30de6
Docs update: updated nav, get started sections, home page, apis (#9060)
* initial setup and rename "how to" to "setup"

* move API to main nav

* move api to main nav

* add get starated, rework nav order

* rename to install move mds out of install section

* update api nav and home page

* add install docs and python qs updates

* python get started work

* remove c and obj c for now

* move java, python, and obj-c docs under api folder

* move java api html to iframe (ugh)

* remove api docs w/o details, move api text getstar

* remove api docs wo detail updates get started

* remvoe iframes

* move eco system to main nav

* fix api buttons

* added more examples moved intro to ORT

* fix links

* fix get started titles

* fix get started titles

* fix more links

* fix more links

* more link fixes

* fix nav remove inferencing and training subnav

* fix top nav remove inference and training nav

* fix title

* fix tutorials nav hierarchy

* fix python api button

* add tenorflow keras example

* fix quickstart toc

* add imports fix spacing

* fix links

* update nav and python get started page

* move ort training example, add coming soon for iot

* update C# get started

* fix spacing on quantization

* Add some js get started content

* fix formatting

* fix typo

* removed onnx-pytorch and onnx-tf

* updated pip install torch and added links iot page

* added pytorch tutorial heirarchy

* updated web to docs soon added release blog link

* add web link
2021-09-15 16:23:42 -05:00

268 lines
4.5 KiB
ReStructuredText

.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_pipeline.py"
.. LINE NUMBERS ARE GIVEN BELOW.
.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here <sphx_glr_download_auto_examples_plot_pipeline.py>`
to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_plot_pipeline.py:
Draw a pipeline
===============
There is no other way to look into one model stored
in ONNX format than looking into its node with
*onnx*. This example demonstrates
how to draw a model and to retrieve it in *json*
format.
.. contents::
:local:
Retrieve a model in JSON format
+++++++++++++++++++++++++++++++
That's the most simple way.
.. GENERATED FROM PYTHON SOURCE LINES 22-32
.. code-block:: default
from onnxruntime.datasets import get_example
example1 = get_example("mul_1.onnx")
import onnx
model = onnx.load(example1) # model is a ModelProto protobuf message
print(model)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
ir_version: 3
producer_name: "chenta"
graph {
node {
input: "X"
input: "W"
output: "Y"
name: "mul_1"
op_type: "Mul"
}
name: "mul test"
initializer {
dims: 3
dims: 2
data_type: 1
float_data: 1.0
float_data: 2.0
float_data: 3.0
float_data: 4.0
float_data: 5.0
float_data: 6.0
name: "W"
}
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 2
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 2
}
}
}
}
}
}
opset_import {
domain: ""
version: 7
}
.. GENERATED FROM PYTHON SOURCE LINES 33-39
Draw a model with ONNX
++++++++++++++++++++++
We use `net_drawer.py <https://github.com/onnx/onnx/blob/master/onnx/tools/net_drawer.py>`_
included in *onnx* package.
We use *onnx* to load the model
in a different way than before.
.. GENERATED FROM PYTHON SOURCE LINES 39-47
.. code-block:: default
from onnx import ModelProto
model = ModelProto()
with open(example1, 'rb') as fid:
content = fid.read()
model.ParseFromString(content)
.. GENERATED FROM PYTHON SOURCE LINES 48-49
We convert it into a graph.
.. GENERATED FROM PYTHON SOURCE LINES 49-54
.. code-block:: default
from onnx.tools.net_drawer import GetPydotGraph, GetOpNodeProducer
pydot_graph = GetPydotGraph(model.graph, name=model.graph.name, rankdir="LR",
node_producer=GetOpNodeProducer("docstring"))
pydot_graph.write_dot("graph.dot")
.. GENERATED FROM PYTHON SOURCE LINES 55-56
Then into an image
.. GENERATED FROM PYTHON SOURCE LINES 56-59
.. code-block:: default
import os
os.system('dot -O -Tpng graph.dot')
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
0
.. GENERATED FROM PYTHON SOURCE LINES 60-61
Which we display...
.. GENERATED FROM PYTHON SOURCE LINES 61-70
.. code-block:: default
import matplotlib.pyplot as plt
image = plt.imread("graph.dot.png")
plt.imshow(image)
.. image:: /auto_examples/images/sphx_glr_plot_pipeline_001.png
:alt: plot pipeline
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
<matplotlib.image.AxesImage object at 0x7fd0a620e860>
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.244 seconds)
.. _sphx_glr_download_auto_examples_plot_pipeline.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_pipeline.py <plot_pipeline.py>`
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_pipeline.ipynb <plot_pipeline.ipynb>`
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_