TensorFlow retrained inception v3 model crashes on Android
<p>I had retrained TensorFlow Inception v3 model with my own dataset as described in this <a href="https://www.tensorflow.org/versions/master/how_tos/image_retraining/index.html" rel="nofollow">tutorial</a>.</p>

<p>Now I'm trying to build and run TensorFlow <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android" rel="nofollow">Android example</a> using my retrained model. I built the native code from the example as is, copied the  model (.pb) and label (.txt) files to the assets dir and changed the model parameters in <code>TensorFlowImageListener.java</code>:</p>

<pre><code>private static final int NUM_CLASSES = 5; // number of categories
private static final int INPUT_SIZE = 299;
private static final int IMAGE_MEAN = 128;
private static final float IMAGE_STD = 128;
private static final String INPUT_NAME = "Mul:0";
private static final String OUTPUT_NAME = "final_result:0";
</code></pre>

<p>But the app crashes when parsing the model file loaded from assets:</p>

<pre><code>08-12 16:02:08.258 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:115 Loading TensorFlow.
08-12 16:02:08.258 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:117 Making new SessionOptions.
08-12 16:02:08.259 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:120 Got config, 0 devices
08-12 16:02:08.264 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:123 Session created.
08-12 16:02:08.264 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:126 Graph created.
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:130 Acquired AssetManager.
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:132 Reading file to proto: file:///android_asset/tensorflow_inception_graph.pb
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: jni_utils.cc:120 Opening asset tensorflow_inception_graph.pb from disk with copy.
08-12 16:02:09.382 25253-25253/com.iliakplv.tensorflow A/native: jni_utils.cc:123 Check failed: message-&gt;ParseFromArray(memory, data_size) 
08-12 16:02:09.382 25253-25253/com.iliakplv.tensorflow A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 25253 (tech.tensorflow)
</code></pre>

<p>P.S. I also tried using <code>tensorflow/python/tools/strip_unused.py</code> (as it suggested <a href="https://github.com/tensorflow/tensorflow/issues/1269" rel="nofollow">here</a>) like this:</p>

<pre><code>bazel build tensorflow/python/tools:strip_unused &amp;&amp; \
bazel-bin/tensorflow/python/tools/strip_unused \
--input_graph=some_graph_def.pb \
--output_graph=/tmp/stripped_graph.pb \
--input_node_names=Mul
--output_node_names=final_result
</code></pre>

<p>Didn't help.</p>