0
votes

While converting model to tflite getting this error

""" Some of the operators in the model are not supported by the standard TensorFlow Lite runtime and are not recognized by TensorFlow. If you have a custom implementation for them you can disable this error with --allow_custom_ops, or by setting allow_custom_ops=True when calling tf.lite.TFLiteConverter(). Here is a list of builtin operators you are using: ABS, ADD, CONV_2D, MAX_POOL_2D, MUL, RELU, SOFTMAX, SQUEEZE, SUB. Here is a list of operators for which you will need custom implementations: AdjustContrastv2, AdjustHue, AdjustSaturation, RandomUniform. """

How to resolve this? tensorflow version: 1.13.1

2
Is there a readon you are not using a more updated version of tensorflow? You should be able to convert this model using the guide here: tensorflow.org/lite/guide/ops_select - daverim

2 Answers

0
votes

You can use TF ops directly by selecting TF ops. I've confirmed that AdjustContrastv2, AdjustHue, AdjustSaturation are available via FlexDelegate. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/flex/allowlisted_flex_ops.cc#L35

To use this feature, you need to use TF 2.4 or higher. Since TF 2.4 is not available yet, you need to use tf-nightly release.

FYI, regarding migration TF1 to TF2, please check https://www.tensorflow.org/guide/migrate

0
votes

You may try adding following lines to specify your model can use ops in both TF Lite built in and in TF.

converter.experimental_new_converter=True
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
                                   tf.lite.OpsSet.SELECT_TF_OPS]

Or better you should rewrite ops not supported in TF Lite built in by ops available in TF built in