flutter-tflite icon indicating copy to clipboard operation
flutter-tflite copied to clipboard

ArgumentError (Invalid argument(s): Unable to create interpreter.)

Open YashOEncureIT opened this issue 1 year ago • 1 comments

I am facing this issue with plugin , please check files and everything .

void _loadModel() async { // Enable delegates final options = InterpreterOptions();

if (Platform.isAndroid) {
  options.addDelegate(XNNPackDelegate());
}

// doesn't work on emulator
// if (Platform.isAndroid) {
//   options.addDelegate(GpuDelegateV2());
// }

if (Platform.isIOS) {
  options.addDelegate(GpuDelegate());
}

// Creating the interpreter using Interpreter.fromAsset
_interpreter = await Interpreter.fromAsset(
  'assets/models/model_float16.tflite',
  options: options,
);

debugPrint('Interpreter loaded successfully');

}

Assets ->> assets/models/model_float16.tflite

please let me know if I miss anything with configuration .

YashOEncureIT avatar Jun 20 '25 12:06 YashOEncureIT

I’m seeing the same issue and resolved it by converting with TensorFlow 2.14 and creating the TFLite model again.

Issue: A model trained and converted with TF 2.20 loads fine with tf.lite.Interpreter in Python but fails in Flutter with tflite_flutter 0.11: Invalid argument(s): Unable to create interpreter.

Workaround: Re-convert the same Keras model with TF 2.14 (no retraining). The resulting .tflite loads correctly in tflite_flutter 0.11.

Note: If the model was trained under TF 2.20 (with newer NumPy/ml-dtypes), converting under TF 2.14 can fail due to dependency mismatches—but those errors are more actionable. Pinning numpy==1.26.4 and ml-dtypes==0.2.0 fixed it for me.

Endifly avatar Sep 24 '25 12:09 Endifly