am15h / tflite_flutter_plugin

TensorFlow Lite Flutter Plugin
https://pub.dev/packages/tflite_flutter
Apache License 2.0
508 stars 353 forks source link

Didn't find op for builtin opcode 'FULLY_CONNECTED' version '9' #96

Open sayannath opened 3 years ago

sayannath commented 3 years ago

Loading Model in Flutter

  void _loadModel() async {
    _interpreter = await Interpreter.fromAsset('asl.tflite');

    var inputShape = _interpreter.getInputTensor(0).shape;
    var outputShape = _interpreter.getOutputTensor(0).shape;
    print(inputShape);
    print(outputShape);
    print('Load Model - $inputShape / $outputShape');
  }

Conversion Code

converter = tf.lite.TFLiteConverter.from_saved_model("asl_model")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [
    tf.lite.OpsSet.TFLITE_BUILTINS,
    tf.lite.OpsSet.SELECT_TF_OPS 
]
tflite_model = converter.convert()
open("asl.tflite", 'wb').write(tflite_model)
print('Model size is %f MBs.' % (len(tflite_model) / 1024 / 1024.0))
am15h commented 3 years ago

Looks like there is a version mismatch between the TensorFlow version you are using to convert and the tflite binary version.

sayannath commented 3 years ago

I am using tf-nightly to build my model and convert my model into tflite file.

am15h commented 3 years ago

Please use tensorflow version 2.4.1 and follow this https://github.com/am15h/tflite_flutter_plugin/issues/101#issuecomment-821781506 to use flex delegate.

sayannath commented 3 years ago

Sure will try that!

am15h commented 3 years ago

@sayannath Did it work?

sayannath commented 3 years ago

I will try it asap

1saifj commented 3 years ago

@sayannath Did it work?

I'm facing the same problem, it didn't work till now, is there is another fix?