tensorflow: Loading the newer inception model in Android demo example and No OpKernel was registered to support Op error

Steps to reproduce

  1. Load the model in the asset folder from here: http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz rather than here: https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip This step loads the model which is used in image_retrain, label_image and classify examples. The link for the model in the android demo is old and has some differences that don’t work with the other demos as mentioned in #1253
  2. Change the input_width and input_mean in TensorflowImageListener.java
  3. Change the input tensor name and output tensor name as follows in the tensorflow_jni.cc

What have you tried?

  1. I changed the input_width from 224 to 299 and input_mean from 117 to 128.
  2. When the input tensor name was input:0 and output tensor name was output:0 I got the following node not found error

02-23 23:56:11.066 15084-15105/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:271 Width: 299 02-23 23:56:11.066 15084-15105/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:272 Stride: 1196 02-23 23:56:11.066 15084-15105/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:176 Tensorflow: Copying Data. 02-23 23:56:11.070 15084-15105/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:194 Start computing. 02-23 23:56:11.157 15084-15105/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:205 End computing. Ran in 86ms (91ms avg over 7 runs) 02-23 23:56:11.157 15084-15105/org.tensorflow.demo E/native: tensorflow/examples/android/jni/tensorflow_jni.cc:210 Error during inference: Not found: FetchOutputs node output:0: not found

  1. When the input tensor name was Mul:0 and output tensor name was softmax:0 I got the following error

02-24 00:07:46.149 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:270 Height: 299 02-24 00:07:46.149 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:271 Width: 299 02-24 00:07:46.149 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:272 Stride: 1196 02-24 00:07:46.149 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:176 Tensorflow: Copying Data. 02-24 00:07:46.152 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:194 Start computing. 02-24 00:07:46.222 23093-23123/org.tensorflow.demo I/native: tensorflow/examples/android/jni/tensorflow_jni.cc:205 End computing. Ran in 70ms (77ms avg over 35 runs) 02-24 00:07:46.222 23093-23123/org.tensorflow.demo E/native: tensorflow/examples/android/jni/tensorflow_jni.cc:210 Error during inference: Invalid argument: No OpKernel was registered to support Op 'BatchNormWithGlobalNormalization' with these attrs [[Node: conv/batchnorm = BatchNormWithGlobalNormalization[T=DT_FLOAT, scale_after_normalization=false, variance_epsilon=0.001](conv/Conv2D, conv/batchnorm/moving_mean, conv/batchnorm/moving_variance, conv/batchnorm/beta, conv/batchnorm/gamma)]]

That’s good news that the android demo code is finding the nodes in the new model after the changes. However, I have no idea what this error means. I would really appreciate if someone can explain. (Although this issue is being taken care of in #1253, I am still doing it myself in an attempt to learn more about tensorflow) No OpKernel was registered to support Op 'BatchNormWithGlobalNormalization' with these attrs [[Node: conv/batchnorm = BatchNormWithGlobalNormalization[T=DT_FLOAT, scale_after_normalization=false, variance_epsilon=0.001](conv/Conv2D, conv/batchnorm/moving_mean, conv/batchnorm/moving_variance, conv/batchnorm/beta, conv/batchnorm/gamma)]]

Looking at the main.cc in the label_image example, I see something about “normalized” in the ReadTensorFromImage function. Don’t know if that’s helpful information.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 45 (19 by maintainers)

Most upvoted comments

@dmirk Here are the steps how I build the Android demo project with a retrained model:

  1. Retrained an Inception v3 model by tensorflow/examples/image_retraining/retrain.py.

  2. Go to the root directory of the Android example (tensorflow/examples/android).

  3. Put the retrained model and its label list into the assets directory

  4. Strip the retrained model by the commend:

    python strip_unused.py
    --input_graph=<retrained-pb-file> \
    --output_graph=<your-stripped-pb-file> \
    --input_node_names="Mul" \
    --output_node_names="final_result" \
    --input_binary=true
    
  5. Modify src/org/tensorflow/demo/TensorflowImageListener.java by modifying these variables:

    # in class TensorflowImageListener
    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";
    
  6. Build the project.

@dmirk I’m not sure that label_image will work if the decodejpeg op has been stripped out of the graph. Similarly it won’t work on android unless you have stripped it out, so the symptoms point to it not having been removed. Can you double check that you’re using the right output graph in both places please?

@natanielruiz You should be able to use strip_unused like so to remove the DecodeJpeg node:

bazel build tensorflow/python/tools:strip_unused
bazel-bin/tensorflow/python/tools/strip_unused --input_graph=inception.pb --output_graph=/tmp/stripped_inception.pb --input_node_names="Mul" --output_node_names="final_result" --input_binary=true

Hello, I followed the steps listed above, but I’m facing this issue:

06-06 12:41:59.923 24534 24552 E native : tensorflow_jni.cc:303 Error during inference: Invalid argument: No OpKernel was registered to support Op ‘DecodeJpeg’ with these attrs 06-06 12:41:59.923 24534 24552 E native : [[Node: DecodeJpeg = DecodeJpegacceptable_fraction=1, channels=3, fancy_upscaling=true, ratio=1, try_recover_truncated=false]]

Does anyone faced this before?

hi everybody,

I’m a old developper from Paris. I’m interesting by tensorflow, so I can to build and test. But : I have a some problem. I have read all the forum, but I have not idea of my mistake.

I have trained image and unstripped (It’s work fine), I have created the file “TensorFlowImageListener.java” and put it in my Android-studio in the right place (I think) but when I launch a build…I have this

Error:(66, 57) error: TensorFlowImageClassifier() has private access in TensorFlowImageClassifier Error:(86, 15) error: cannot find symbol method initializeTensorflow(AssetManager,String,String,int,int,int)

I’m not used before Java…so I learn…But If you have a idea…I’m very interesting. Thanks for everythings. P

Hello, I was able to use the strip_graph script finally but I have exactly the same problem as @dmirk It just seems that the script doesn’t strip the JPEGDecoder.