How to set Padding Type for CoreML Delegate on Tensorflow Lite to fix `PoolingLayerBuilder (MEAN)_1' is not set.`?

Viewed 198

I recently trained an object detection model on Google's Vision platform and exported it to a TensorFlow Lite edge model.

I receive this error in Xcode when running on an iOS device with a CoreML delegate:

validator error: Padding type for the pooling layer 'PoolingLayerBuilder (MEAN)_1' is not set.

When running on iOS using TensorFlow lite with a CoreML delegate I get this error:

Error compiling model Error reading protobuf spec. validator error: Padding type for the pooling layer 'PoolingLayerBuilder (MEAN)_1' is not set.

Here's what I've tried so far:

  • Updating my pods to make sure I'm on the TensorFlowLiteSwift nightly build
  • Running on CPU only (the model works, so I know its a CoreML delegate problem)
  • Making sure CoreMLDelegate is using the latest version of CoreML (3)

Next Steps?

Is that the right approach or is there an easier solution I'm not seeing?

2 Answers

In order to edit a TFlite model, I recommend you to use this python library called Netron. I did not tested this with an object detection model yet [I will update this comment along the day], however, I managed to have access to the model itself and to modify its configuration.

When you install Netron, and call the model.tflite as netron 'model.tflite',a server link will show up in your command shell. When you click it, you will have access to the graphic mode of your model. When you click a layer, a set of properties will show up, which you can modify there. I managed to notice this thanks to this github comments. I think this will let you solve your issue.

Meanwhile, I will try to modify the CoreML version of my model as soon as I've a new deployed model of an object detection case. I will keep you updated!

Let me know if this has helped you so far.

Some things you could try:

  1. Convert the model to .onnx format using tensorflow-onnx.
  2. Instead of converting .tflite to CoreML model, you can try convert tensorflow model(.h5, SavedModel, tf.keras.Model, concrete function) directly to CoreML. Ref: Tensorflow 2 Conversion
Related