Sachu
Sachu

Reputation: 187

Having an issue loading a TFLite model into Flutter (issue with file-path)

I'm trying to load a TFLite model / it's labels into flutter but I keep getting a file not found error. Is it possibly a mistake in my code for loading the model:

Code:

loadModel() async{
    String res = await Tflite.loadModel(
    model: "lib\assets\image_classifier.tflite",
    labels: "lib\assets\image_labels.txt",
    );
  }

File-Path:

enter image description here

Resource I'm using: https://pub.dev/packages/tflite

Upvotes: 0

Views: 734

Answers (2)

Ndongmo christian
Ndongmo christian

Reputation: 101

It's not advicable to put your assets inside you lib directory. Always put at the same level with the lib directory

Upvotes: 0

Lucky
Lucky

Reputation: 2082

You should use / in file path instead of \

loadModel() async{
  String res = await Tflite.loadModel(
  model: "lib/assets/image_classifier.tflite",
  labels: "lib/assets/image_labels.txt",
  );
}

Upvotes: 1

Related Questions