Reputation: 137
getting this error while trying to load a tf model I converted to tflite so I can use it in my app
I did what the message suggests and added the org.tensorflow:tensorflow-lite-select-tf-ops
dep in the app/build.gradle but still no luck, when I try to load a much simpler model it loaded no problem but this model it just wont load.
Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. For the Android, it can be resolved by adding "org.tensorflow:tensorflow-lite-select-tf-ops" dependency. See instructions: https://www.tensorflow.org/lite/guide/ops_select
this model itself is not complex at all, it is just a NER
model
this is the model
MAX_SEQ_LEN = 128
VOCAB_SIZE = 10000
EMBEDDING_DIM = 128
RNN_UNITS = 64
NUM_TAGS = 10
model = tf.keras.Sequential([
tf.keras.layers.Embedding(VOCAB_SIZE, EMBEDDING_DIM, input_length=MAX_SEQ_LEN), # Static shape
tf.keras.layers.Bidirectional(tf.keras.layers.GRU(RNN_UNITS, return_sequences=True)), # No dynamic TensorArray
tf.keras.layers.TimeDistributed(tf.keras.layers.Dense(NUM_TAGS)) # Output per token
])
this is the conversion
converter = tf.lite.TFLiteConverter.from_saved_model("ner_model")
converter.experimental_enable_resource_variables = True
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]
converter._experimental_lower_tensor_list_ops = False
tflite_model = converter.convert()
with open("ner_model.tflite", "wb") as f:
f.write(tflite_model)
tflite package version used in flutter project
tflite_flutter: ^0.10.4
tflite lib version used in the conversion
2.18.0
Upvotes: 0
Views: 26