<p dir="auto">It's a great step to support importing Android lib via jcenter. However, I'm having trouble in loading pretrained models into <code class="notranslate">TensorFlowInferenceInterface</code>, which says <code class="notranslate">NodeDef mentions attr 'dilations' not in Op...</code>. I think it's a compatibility issue, meaning that the model graph is not consistent with the graph interpreter. The models directly downloaded from <code class="notranslate">slim</code> and frozen by myself. Anyone can help me?</p>
<p dir="auto">Please go to Stack Overflow for help and support:</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/tagged/tensorflow" rel="nofollow">https://stackoverflow.com/questions/tagged/tensorflow</a></p>
<p dir="auto">If you open a GitHub issue, here is our policy:</p>
<ol dir="auto">
<li>It must be a bug or a feature request.</li>
<li>The form below must be filled out.</li>
<li>It shouldn't be a TensorBoard issue. Those go <a href="https://github.com/tensorflow/tensorboard/issues">here</a>.</li>
</ol>
<p dir="auto"><strong>Here's why we have that policy</strong>: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.</p>
<hr>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:<br>
no</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>:<br>
Linux Ubuntu 16.04</li>
<li><strong>TensorFlow installed from (source or binary)</strong>:<br>
source</li>
<li><strong>TensorFlow version (use command below)</strong>:<br>
('v1.3.0-rc1-5733-gb43d0f3', '1.4.0')</li>
<li><strong>Python version</strong>:<br>
2.7.12</li>
<li><strong>Bazel version (if compiling from source)</strong>:<br>
0.9.0</li>
<li><strong>GCC/Compiler version (if compiling from source)</strong>:<br>
5.4.0</li>
<li><strong>CUDA/cuDNN version</strong>:</li>
<li><strong>GPU model and memory</strong>:</li>
<li><strong>Exact command to reproduce</strong>:</li>
</ul>
<p dir="auto">I have retrained a mobilenet_v1_1.0_224 frozen_graph.pb model with the following script:</p>
<p dir="auto">export PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages<br>
export IMAGE_SIZE=224<br>
export WIDTH_MUL=1.0 # 0.75 0.50 0.25<br>
export ARCHITECTURE="mobilenet_${WIDTH_MUL}_${IMAGE_SIZE}"<br>
export BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &amp;&amp; pwd )"<br>
export TF_FILES_DIR="tf_files"<br>
python -m scripts.retrain <br>
--bottleneck_dir="${TF_FILES_DIR}"/bottlenecks <br>
--how_many_training_steps=4000 <br>
--model_dir="${TF_FILES_DIR}"/models/ <br>
--summaries_dir="${TF_FILES_DIR}"/training_summaries/"${ARCHITECTURE}" <br>
--output_graph="${TF_FILES_DIR}"/retrained_graph.pb <br>
--output_labels="${TF_FILES_DIR}"/retrained_labels.txt <br>
--architecture="${ARCHITECTURE}" <br>
--image_dir="${TF_FILES_DIR}"/flower_photos</p>
<p dir="auto">I copied "retrained_graph.pb" and "retrained_labels.txt" in the "assets" directory of the android demo app in tensorflow/examples/android and modified the source code in ClassifierActivity.java as follows:</p>
<p dir="auto">/* Original code:<br>
private static final String INPUT_NAME = "input";<br>
private static final String OUTPUT_NAME = "output";<br>
private static final String MODEL_FILE = "file:///android_asset/tensorflow_inception_graph.pb";<br>
private static final String LABEL_FILE = "file:///android_asset/imagenet_comp_graph_label_strings.txt";<br>
<em>/<br>
/</em> Replaced by: <em>/<br>
private static final String INPUT_NAME = "input";<br>
private static final String OUTPUT_NAME = "final_result";<br>
private static final String MODEL_FILE = "file:///android_asset/retrained_graph.pb";<br>
private static final String LABEL_FILE = "file:///android_asset/retrained_labels.txt";<br>
/</em> End */</p>
<p dir="auto">I cleaned and rebuilt the whole project in Android Studio, successfully.</p>
<p dir="auto">The app was then loaded on a Huawei P8 Lite (Android 7.0) and starting TF Classify, the following error occurs:</p>
<p dir="auto">E/tensorflow: CameraActivity: Exception!<br>
java.lang.RuntimeException: Failed to load model from 'file:///android_asset/retrained_graph.pb'<br>
at org.tensorflow.contrib.android.TensorFlowInferenceInterface.(TensorFlowInferenceInterface.java:113)<br>
at org.tensorflow.demo.TensorFlowImageClassifier.create(TensorFlowImageClassifier.java:103)<br>
at org.tensorflow.demo.ClassifierActivity.onPreviewSizeChosen(ClassifierActivity.java:118)<br>
at org.tensorflow.demo.CameraActivity.onPreviewFrame(CameraActivity.java:120)<br>
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1204)<br>
at android.os.Handler.dispatchMessage(Handler.java:105)<br>
at android.os.Looper.loop(Looper.java:156)<br>
at android.app.ActivityThread.main(ActivityThread.java:6523)<br>
at java.lang.reflect.Method.invoke(Native Method)<br>
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)<br>
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)<br>
<strong>Caused by: java.io.IOException: Not a valid TensorFlow Graph serialization: NodeDef mentions attr 'dilations' not in Op&lt;name=Conv2D; signature=input:T, filter:T -&gt; output:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]&gt;; NodeDef: MobilenetV1/MobilenetV1/Conv2d_0/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true](input, MobilenetV1/Conv2d_0/weights/read)</strong>. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).<br>
at org.tensorflow.contrib.android.TensorFlowInferenceInterface.loadGraph(TensorFlowInferenceInterface.java:535)<br>
at org.tensorflow.contrib.android.TensorFlowInferenceInterface.(TensorFlowInferenceInterface.java:105)<br>
at org.tensorflow.demo.TensorFlowImageClassifier.create(TensorFlowImageClassifier.java:103) <br>
at org.tensorflow.demo.ClassifierActivity.onPreviewSizeChosen(ClassifierActivity.java:118) <br>
at org.tensorflow.demo.CameraActivity.onPreviewFrame(CameraActivity.java:120) <br>
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1204) <br>
at android.os.Handler.dispatchMessage(Handler.java:105) <br>
at android.os.Looper.loop(Looper.java:156) <br>
at android.app.ActivityThread.main(ActivityThread.java:6523) <br>
at java.lang.reflect.Method.invoke(Native Method) <br>
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) <br>
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) <br>
Application terminated.</p>
<p dir="auto">How to fix this error?</p>