Export tflite
malik-anhar opened this issue · comments
Hello, i'm trying to export the model into tflite as well, but i got an error like this
loc(callsite("yolov3_tiny/yolo_nms/combined_non_max_suppression/CombinedNonMaxSuppression"("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/ops/image_ops_impl.py":4335:0) at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py":201:0 at callsite("/home/user/Malik/Object Detection/Inside-Tag-Detection/yolov3/models.py":194:0 at callsite("/home/user/Malik/Object Detection/Inside-Tag-Detection/yolov3/models.py":249:0 at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/layers/core.py":903:0 at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py":985:0 at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py":508:0 at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py":386:0 at callsite("/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py":985:0 at "/home/user/miniconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/keras/saving/saving_utils.py":134:0)))))))))): error: 'tf.CombinedNonMaxSuppression' op is neither a custom op nor a flex op
I'm using tensorflow 2.3.0 for the conversion
Seems to be ok if you add this to your script, after the saved model path line, above the converter.convert() line
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
Insight from here : tensorflow/tensorflow#46285
Thank you for replying this, yes the issue was resolved by adding the code you are mention above. And for the android implementation I have to add the select-tf-ops dependency like this
implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly'
The size of the app will getting bigger due to the size of select-tf-ops dependency for android, so to reduce the size I built my own select-tf-ops .aar by following this tutorial https://www.tensorflow.org/lite/guide/build_android#build_and_install