Skip to content

Commit

Permalink
Updated documentation to use .meta files
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyan7 committed Nov 15, 2018
1 parent 2fe5a5d commit a1e0eb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions example/tensorflow/code_template/tensorflow_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# Read the protobuf text and build a tf.GraphDef
with open(model_file_name, 'r') as model_file:
model_protobuf = text_format.Parse(model_file.read(),
tf.GraphDef())
tf.MetaGraphDef())

# Import the GraphDef built above into the default graph
tf.import_graph_def(model_protobuf)
tf.train.import_meta_graph(model_protobuf)

# You can now add operations on top of the imported graph
18 changes: 9 additions & 9 deletions tutorials/tensorflow_prototxt_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ In order to export a Tensorflow model from Fabrik:
<img src="https://raw.githubusercontent.com/Cloud-CV/Fabrik/master/tutorials/exportbutton.png">

2. A drop-down list should appear. Select Tensorflow.
* This should download a pbtxt file to your computer.
* This should download a ```.meta``` file to your computer.
<img src="https://raw.githubusercontent.com/Cloud-CV/Fabrik/master/tutorials/export_tensorflow.png">

3. Rename the file to ```model.pbtxt```.
3. Rename the file to ```model.meta```.

4. Load the model from the ProtoBuf file using the following code:
4. Load the model from ```model.meta``` using the following code:

```
import tensorflow as tf
from google.protobuf import text_format
# read the graphdef from the model file
with open('model.pbtxt', 'r') as model_file:
with open('model.meta', 'r') as model_file:
model_protobuf = text_format(model_file.read(),
tf.Graphdef())
tf.MetaGraphDef())
# import the graphdef into the default graph
tf.import_graph_def(model_protobuf)
tf.train.import_meta_graph(model_protobuf)
```
### Code template
[The code template](../example/tensorflow/code_template/tensorflow_sample.py) loads the model from a pbtxt file into the default graph. Additional operations like layers and optimizers can be then built onto the graph as required.
[The code template](../example/tensorflow/code_template/tensorflow_sample.py) loads the model from a ```.meta``` file into the default graph. Additional operations like layers and optimizers can be then built onto the graph as required.
To run the code, run:
```
python tensorflow_sample.py model.pbtxt
python tensorflow_sample.py model.meta
```
Replace ```model.pbtxt``` with the model file that you want to use.
Replace ```model.meta``` with the model file that you want to use.

0 comments on commit a1e0eb6

Please sign in to comment.