在 flutter 中,如何将 tflite 添加为 pubspec.yaml 中的依赖项?文件?

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

我对此有点困惑。现在我有 .tflitelabel.txt,但现在我想使用 Flutter Plugin 访问 TensorFlow lite。 在这里,我对在 pubspec.yaml

中添加 tflite 作为依赖感到困惑

您需要在资产部分提供:

  assets:
    - path/to/your/file

要访问您的资产:

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

cupertino_icons 下方添加 tflite: ^1.0.4: ^0.1.2

  1. 在您的项目中创建一个名为 assets.
  2. 的新目录
  3. 将您的文件复制到 assets 文件夹中。
  4. 将以下资产添加到 uses-material-design:true 到您的 pubspec.yaml 例如。
    资产:
    - assets/label.txt

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  

Asset 文件夹中是您的 .tflite 文件,这些文件可以生成您自己的训练、标签和推论,也可以从 GitHub 文件中手动复制,因为它们是由 TensorFlow 图像专门生成的数据。 See here for more details

资产文件夹