Path is correct, folder structure too. Still getting problem message "The asset file xxx.tflite doesn't exist"

90 Views Asked by At

In Flutter (VS Studio 2022) I am trying to use a .tflite model. This is my pubspec.yaml file;

name: linked_post_ai_v1
description: A description about your project.
version: 1.0.0

environment:
  sdk: '^3.2.0-65.0.dev'

dependencies:
  flutter:
    sdk: flutter
  path_provider: ^2.0.11
  sqflite: ^2.0.0
  http: ^1.1.0
  tflite_flutter: ^0.10.1

dev_dependencies:
  flutter_lints: ^1.0.4
  sqflite_common_ffi: ^2.3.0+2

flutter:
  uses-material-design: true
  assets:
    - assets/distilgpt2-small-64-fp16.tflite

This is my folder structure:

root

-assets

-lib

--pubspec.yaml

--other.dart files

The model I want to use is in the assets folder, I checked the path a gazillion times by now. I tried other models too so I dont think the file is the problem. I tried about anything I could think of. Still getting this error:

The asset file 'assets\distilgpt2-small-64-fp16.tflite' doesn't exist.
Try creating the file or fixing the path to the file.

I also tried \ and / in the path, neither work.

Any suggestions?

1

There are 1 best solutions below

2
Somasundaram R On

can you please try removing the '-' from your file name?

It worked when I faced this issue.