ZKJ
ZKJ

Reputation: 167

How do I reference this TFLite file in my Flutter App

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

Upvotes: 1

Views: 573

Answers (1)

Junsu Cho
Junsu Cho

Reputation: 854

add tffile in pubspec.yaml file

  assets:
    - assets/model_unquant.tflite
    - assets/labels.txt

Upvotes: 1

Related Questions