我使用tflite_flutter包加载tflite模型。我安装软件包
颤振酒吧添加tflite_flutter
sh install.sh -d用于使用GpuDelegateV2
下面是我从文档中复制的代码示例。
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“参数上给出了红线。
发布于 2021-11-08 05:10:38
可能文档没有更新,因为构造函数只允许命名参数,因此代码如下
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);,现在它工作得很好。
https://stackoverflow.com/questions/69878397
复制相似问题