Analyze a tensorflow graph or a .pb file on Tensorboard

Subhash_Reddy picture Subhash_Reddy · Apr 12, 2017 · Viewed 8k times · Source

I have been following github repository for "Tensorflow on Android".

  1. I was able to build the code using bazel and then import the Android project to Android Studio, as mentioned here.
  2. As you can see here, after building the APK, using Android Studio, the Model files/Graphs are included in the tensorflow/examples/android/assets
  3. By default, tensorflow_inception_graph.pb and imagenet_comp_graph_label_strings.txt are included, from inception5 file which is downloaded while the APK is built.

What's the issue?

  1. I have a retrained graph (InceptionV3 model, mentioned in tensorflow/examples/image_retraining/retrain.py), which I was able to place in the assets folder in android directory and generate a working APK.
  2. Inference time while I was using the default graph or .pb file was ~500ms and with my retrained.pb or graph it is ~1400ms.(tested on OnePlus3T device)

Please help me understand

  1. How to analyze the default tensorflow_inception_graph.pb on Tensorboard

Answer

P-Gn picture P-Gn · Jul 6, 2017

Last May they have introduced a helper script called import_pb_to_tensorboard to do just that.

usage: import_pb_to_tensorboard.py [-h] [--model_dir MODEL_DIR]
                                   [--log_dir LOG_DIR]

optional arguments:
  -h, --help            show this help message and exit
  --model_dir MODEL_DIR
                        The location of the protobuf ('pb') model to
                        visualize.
  --log_dir LOG_DIR     The location for the Tensorboard log to begin
                        visualization from.

Note that currently, the version in master seems to have received more love than the one present in the latest 1.2.1 distribution of tensorflow, so I would suggest to use this one.