tensorflow / flutter-tflite

Apache License 2.0
468 stars 125 forks source link

Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter #175

Open utkukozan opened 9 months ago

utkukozan commented 9 months ago

I am getting this error when i am using my custom tflite model which detects pose and running in python successfully. My app level build.gradle file contains:

dependencies {
      implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly-SNAPSHOT'
      implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly-SNAPSHOT'
  }
  defaultConfig {
          ndk {
              abiFilters 'armeabi-v7a', 'arm64-v8a'
          }
      }

    aaptOptions {
        noCompress 'tflite'
        noCompress 'lite'
    }

And when i tried to initialize this model with this code :

tfl.Interpreter? interpreter = await tfl.Interpreter.fromAsset('assets/ml/model.tflite');

I am getting this error :

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
Node number 3 (FlexTensorListReserve) failed to prepare.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: failed precondition

Also my python TFLite convert method includes supported ops that see in tensorflow documents

converter.target_spec.supported_ops = [
  tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
  tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]

Could you please help me for solve this problem ?

jonasscheffner commented 9 months ago

Hey, I have the same issue, have you already resolved it?

utkukozan commented 9 months ago

Hey, I have the same issue, have you already resolved it?

No unfortunately I couldn't solve it

ghost commented 9 months ago

This is because this library does not currently support Flex delegate.

OysterQAQ commented 9 months ago

same problem

gianlucasama commented 8 months ago

Can we add support for the flex delegate? How would we go about doing it?

aidemHJC commented 4 months ago

same problem +1 who can share the answer, thanks

iorixxx commented 4 months ago

Can we add support for the flex delegate? How would we go about doing it?

So this is a 'new feature' or 'enhancement' or 'wish list' type issue rather than a bug-issue? If you think this is a bug, a failing test case (aligned with the existing tests) would be useful to demonstrate the bug. Does the documentation clearly state this unsupportiveness? The contributions to the documentation are invaluable. Can someone with the permissions add appropriate label(s) to this issue?

shuizhuyu1015 commented 2 months ago

Ilooked it up, but I still can't find the answer. Has anyone solved it?

lukaskris commented 1 month ago

+1 Same problem with me Node number 47 (FlexMatMul) failed to prepare.