首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GpuDelegateV2 Tflite不接受任何参数

GpuDelegateV2 Tflite不接受任何参数
EN

Stack Overflow用户
提问于 2021-11-08 03:34:05
回答 1查看 210关注 0票数 0

我使用tflite_flutter包加载tflite模型。我安装软件包

颤振酒吧添加tflite_flutter

sh install.sh -d用于使用GpuDelegateV2

下面是我从文档中复制的代码示例。

代码语言:javascript
复制
final gpuDelegateV2 = GpuDelegateV2(
    options: GpuDelegateOptionsV2(
    false,
    TfLiteGpuInferenceUsage.fastSingleAnswer,
    TfLiteGpuInferencePriority.minLatency,
    TfLiteGpuInferencePriority.auto,
    TfLiteGpuInferencePriority.auto,
));

var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegateV2);
final interpreter = await Interpreter.fromAsset('your_model.tflite',
    options: interpreterOptions);

但是它给了异常太多的位置参数:0预期,5找到。尝试删除额外的位置参数,或者指定命名参数的名称-- linter还在"false“参数上给出了红线。

EN

回答 1

Stack Overflow用户

发布于 2021-11-08 05:10:38

可能文档没有更新,因为构造函数只允许命名参数,因此代码如下

代码语言:javascript
复制
getModel() async {
  final gpuDelegateV2 = GpuDelegateV2(
    options: GpuDelegateOptionsV2(
      isPrecisionLossAllowed: false,
      inferencePriority1: TfLiteGpuInferencePriority.minLatency,
      inferencePriority2: TfLiteGpuInferencePriority.auto,
      inferencePriority3: TfLiteGpuInferencePriority.auto,
    ),
  );

  var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegateV2);
final interpreter = await Interpreter.fromAsset('your_model.tflite',
options: interpreterOptions);

,现在它工作得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69878397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档