简体   繁体   中英

In flutter, How to add tflite as a dependency in pubspec.yaml ?file?

I am little bit confused with this. Now I have .tflite and label.txt but right now I want to access TensorFlow lite using Flutter Plugin . In here I am confused with adding tflite as a dependency in pubspec.yaml

You need provide in assets section:

  assets:
    - path/to/your/file

To access your asset:

import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;

Future<String> loadAsset() async {
  return await rootBundle.loadString('path/to/your/file');
}

Adding assets and images

add tflite: ^1.0.4 below cupertino_icons: ^0.1.2

https://i.stack.imgur.com/iV9lo.png

  1. make a new directory in your project called assets .
  2. copy your file in assets folder.
  3. add asset below uses-material-design:true to your pubspec.yaml for eg.
    assets:
    - assets/label.txt https://i.stack.imgur.com/CjOIP.png

Pubspec.yaml

version: 1.0.0+1
environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  camera: 0.4.0

  tflite: 1.0.4  

And in Asset folder is your .tflite files which, can be generated your own training, labels, and inferences or from manual copying from a GitHub file as they are specifically generated by TensorFlow image data. See here for more details

Assets folder

tflite

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM