JieHe96 / iOS_Tensorflow_ObjectDetection_Example

An iOS application of Tensorflow Object Detection with different models: SSD with Mobilenet, SSD with InceptionV2, Faster-RCNN-resnet101

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid argument: No OpKernel was registered to support Op 'FusedBatchNorm' with these attrs. Registered devices: [CPU], Registered kernels: <no registered kernels>

paawan01 opened this issue · comments

Thanks for this awesome project !
After following the process mentioned in readme and other issues on this repo, I was able to run the SSD MobileNet model present in your tf_resource repo.
Following runtime error comes when I try to run my own custom trained SSD model (trained using tensorflow object detection api itself):

Invalid argument: No OpKernel was registered to support Op 'FusedBatchNorm' with these attrs. Registered devices: [CPU], Registered kernels:

[[Node: FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/FusedBatchNorm = FusedBatchNorm[T=DT_FLOAT, data_format="NHWC", epsilon=0.001, is_training=false](FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/convolution, FeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/gamma/read, FeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/beta/read, FeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/moving_mean/read, FeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/moving_variance/read)]]

Now I looked for 'FusedBatchNorm' in "ops_to_register.h" provided by you and as suspected that operation was missing. So I generated ops_to_register.h file by myself using $TF_ROOT/tensor flow/python/tools/print_selective_registration_header.py and then replaced that header file in $TF_ROOT/tensorflow/core/framework/ and rebuild everything again. Also "tensorflow/core/kernels/fused_batch_norm_op.cc" is present there in tf_op_files.txt
But the error still persists.

After building many times the error wouldn't go.

FYI - I tried stripping unnecessary ops by using $TF_ROOT/tensor flow/python/tools/strip_unused.py and using this stripped graph for detection. Then the above error is no longer there and the following error is produced.

Invalid argument: Input 0 of node ToFloat was passed float from image_tensor:0 incompatible with expected uint8.

Another thing I found while manually setting breakpoint and debugging is that both the errors are produced while loading the graphs and not while actually running for inference. That is at line 378 of tensorflow_utils.mm.

Any pointers will be appreciated. Thanks !

Thanks for your answer to the " No OpKernel" issue! And I met the "Invalid argument" issue when I tried to use my own custom method to run the models.

Invalid argument: Input 0 of node ToFloat was passed float from image_tensor:0 incompatible with expected uint8.

This means the Tensor object we create is incompatible with the model expected.You can check following code in the function 'ReadTensorFromImageFile':

tensorflow::uint8* in = image_data.data()

Whether the pointer type of var in is uint8.Hope this could help.

Hey Thanks for the response man.
Actually I figured it out long back but forgot to update it here.
Thanks anyways.

@paawan01 can you share the solution?

@chaine09 It was long back and I don't exactly remember how I fixed this. But as far as I remember my operations file was missing the fused batch norm operation. Once I added that. This issue was gone.