1

I need to reference my TFLite model and the labels in my flutter app:

  static Future<String> loadModel() async {
    AppHelper.log("loadModel", "Loading model..");

    return Tflite.loadModel(
      model: "assets/model_unquant.tflite", //HERE
      labels: "assets/labels.txt", //AND HERE
    );
  }

Right now I keep getting this exception:

E/MethodChannel#tflite(29061): java.lang.IllegalArgumentException: Unsupported value: java.io.FileNotFoundException: flutter_assets/./assets/model_unquant.tflite

What's the right way for me to reference these files? My filing is as follows:

Project Folder
-> Assets
   -> labels.txt
   -> model_unquant.tflite
-> lib
   -> File where I assign the model

It works in this guy's project: https://github.com/umair13adil/tensorflow_lite_flutter/blob/master/lib/helpers/tflite_helper.dart, but it won't work for mine. I believe the only difference to be versions but they are not wildly different (this project was published this March)

Edit: I am using the latest versions of everything, Tflite, flutter, and the Camera plugin for flutter

ZKJ
  • 167
  • 4
  • 15

1 Answers1

1

add tffile in pubspec.yaml file

  assets:
    - assets/model_unquant.tflite
    - assets/labels.txt
Junsu Cho
  • 826
  • 7
  • 16
  • 1
    That worked, I should have paid more attention to documentation! Thank you! After I did this I got a new error saying the file is compressed - anyone else having the same issue please follow the instructions from this post: https://stackoverflow.com/a/57249432/13758089 – ZKJ Jul 30 '20 at 02:46