flutter - tflite颤动中detectObjectOnImage和runModelonImage的区别
问题描述
我正在尝试在颤动中制作一个 tflite 多对象检测器,我遇到了两个以图像路径作为输入的函数,这就是这个问题的原因。
这两个函数是detectObjectOnImage
,runModelOnImage
当我使用runModelOnImage
我的代码时,我的代码正在运行,如果我将它与解释器交换detectObjectOnImage
确实会初始化,但在调用该函数时,应用程序会自动关闭并显示Lost connection to device
这就是我的代码的运行方式
classifyImage(String imgpath) async {
var output = await Tflite.runModelOnImage(
path: imgpath,
imageMean: 0.0,
imageStd: 255.0,
threshold: 0.2,
numResults: 1,
asynch: true,
);
setState(() {
_loading = false;
outputs = output;
});
print(outputs);
print(outputs[0]["label"]);
}
我想我的假设是正确的,但我不知道为什么它不起作用,除了我从谷歌的 Teachable machine 创建了一个模型,它一次只检测一个对象,所以我的下一个问题是如何让它检测到更多超过 1 个对象
谢谢
解决方案
这两个函数的区别在于它们的用法:
对于对象检测,您使用 Tflite.detectObjectOnImage()
对于图像分类(查找对象周围没有打印框),您使用 Tflite.runModelOnImage()
这两种方法返回不同大小的张量。当张量无法映射到预期输出时,应用程序将按照您的描述断开连接。
关于你的第二个问题:
您将限制结果数量的参数 numResults 设置为 1。增加此数字以获得更多结果。(来源:https ://pub.dev/packages/tflite#Example )
推荐阅读
- flow-project - FLOW中关于MLP策略的问题
- r - 如何在 valueBox() 中将图像设置为背景而不是 shinyApp 中的颜色?
- ios - 从 fmdb 中的本地数据库访问数据
- c - 如何在 cmd.exe 而不是“MS VS 调试控制台”中进行调试
- vba - 如何防止在 Form_Delete 事件中重复触发 MsgBox?
- javascript - 按时间顺序排列的打字稿字符串日期格式
- android - 主要活动背景视频
- sql - 汇总多个计数联合查询的 SQL 查询
- java - 转换数据集中的向量数据类型“概率”列
对数组的预测?
- ruby-on-rails - 如何连接到数字海洋服务器中的远程数据库